Class: Bitgen::Generator

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(catalog) ⇒ Generator

Returns a new instance of Generator.



98
99
100
# File 'lib/bitgen.rb', line 98

def initialize( catalog )
  @catalog = catalog
end

Instance Attribute Details

#catalogObject (readonly)

Returns the value of attribute catalog.



96
97
98
# File 'lib/bitgen.rb', line 96

def catalog
  @catalog
end

Class Method Details

.read(path) ⇒ Object



91
92
93
94
# File 'lib/bitgen.rb', line 91

def self.read( path )
  catalog = Catalog.read( path )
  new( catalog )
end

Instance Method Details

#cheatObject

more convenience helpers



123
# File 'lib/bitgen.rb', line 123

def cheat() @catalog.cheat; end

#generate(**kwargs) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/bitgen.rb', line 102

def generate( **kwargs )
   img = nil
   kwargs.each do |category, name|
      cat = @catalog[ category.to_s] 
      attribute_img = cat[name.to_s]

      if attribute_img.nil?
        puts "!! WARN - attribute >#{name}< in >#{category}< not found; sorry"
        puts "  availbable options in #{category}:"
        pp cat.keys
      end

      img = Image.new( attribute_img.width, attribute_img.height )  if img.nil?

      img.compose!( attribute_img )
   end
   img
end