Class: AvatarOMatic::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/avatar_o_matic/config.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.image_libObject

Returns the value of attribute image_lib.



7
8
9
# File 'lib/avatar_o_matic/config.rb', line 7

def image_lib
  @image_lib
end

Class Method Details

.image_dataObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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) ⇒ Object



21
22
23
# File 'lib/avatar_o_matic/config.rb', line 21

def options_for(type, prop)
  image_data[type.to_sym][prop.to_sym]
end

.propertiesObject



13
14
15
# File 'lib/avatar_o_matic/config.rb', line 13

def properties
  [:background, :face, :clothes, :head, :eye, :mouth]
end

.typesObject



17
18
19
# File 'lib/avatar_o_matic/config.rb', line 17

def types
  [:male, :female]
end