Module: Metro::Draws::ClassMethods
- Defined in:
- lib/metro/models/draws.rb
Instance Method Summary collapse
-
#draw(actor_name, options = {}) ⇒ Object
Define an actor with the given name and options.
-
#drawings ⇒ Object
(also: #actors)
All of the model factories that have been defined.
-
#draws(*actor_names) ⇒ Object
Define several actors to be drawn.
-
#play(song_name, options = {}) ⇒ Object
Define a sound actor with the given anem and options.
Instance Method Details
#draw(actor_name, options = {}) ⇒ Object
Define an actor with the given name and options.
As a convenience the draw method will define getter and setter methods for the specified actor.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/metro/models/draws.rb', line 32 def draw(actor_name, = {}) view_content_for_actor = view.content[actor_name.to_s] actor_data = view_content_for_actor.merge() actor_data[:name] = actor_name scene_actor = ModelFactory.new actor_name, actor_data define_method actor_name do instance_variable_get("@#{actor_name}") end define_method "#{actor_name}=" do |value| instance_variable_set("@#{actor_name}",value) end drawings.push scene_actor end |
#drawings ⇒ Object Also known as: actors
All of the model factories that have been defined.
77 78 79 |
# File 'lib/metro/models/draws.rb', line 77 def drawings @drawings ||= [] end |
#draws(*actor_names) ⇒ Object
Define several actors to be drawn.
64 65 66 67 68 69 70 71 72 |
# File 'lib/metro/models/draws.rb', line 64 def draws(*actor_names) actor_names = actor_names.flatten.compact actor_names.each do |actor_name| draw actor_name end drawings end |
#play(song_name, options = {}) ⇒ Object
Define a sound actor with the given anem and options.
57 58 59 |
# File 'lib/metro/models/draws.rb', line 57 def play(song_name,={}) draw song_name, .merge(model: "metro::audio::song") end |