class AvatarOMatic::Config

Attributes

image_lib[RW]

Public Class Methods

image_data() click to toggle source
# File lib/avatar_o_matic/config.rb, line 25
def image_data
  return @_data if @_data

  @_data  = {}
  re_file = /
    \/
      (#{self.types.join('|')})
    \/
      (#{self.properties.join('|')})
      \d+
      \.png
  \Z/xo

  Find.find(image_lib) do |path|
    m = re_file.match(path) or next

    type = m[1].to_sym
    prop = m[2].to_sym

    @_data[type] ||= {}
    @_data[type][prop] ||= []
    @_data[type][prop] << path
  end

  @_data
end
options_for(type, prop) click to toggle source
# File lib/avatar_o_matic/config.rb, line 21
def options_for(type, prop)
  image_data[type.to_sym][prop.to_sym]
end
properties() click to toggle source
# File lib/avatar_o_matic/config.rb, line 13
def properties
  [:background, :face, :clothes, :head, :eye, :mouth]
end
types() click to toggle source
# File lib/avatar_o_matic/config.rb, line 17
def types
  [:male, :female]
end