Class: Metro::Model::SongProperty
- Defined in:
- lib/metro/models/properties/song_property.rb
Overview
A song property maintains a Gosu::Song.
A song is stored in the properties as the path in the assets folder and is converted into a Gosu::Song when it is retrieved within the system. When retrieving a song the Song Property will attempt to use a song that already exists that meets that criteria.
The songs are cached within the song property to help performance by reducing the unncessary creation of similar song.
Constant Summary
Constants included from Units
Instance Attribute Summary
Attributes inherited from Property
Class Method Summary collapse
-
.song_for(options) ⇒ Object
Returns a Metro::Song.
Instance Method Summary collapse
-
#default_song ⇒ Object
The default song for the song property.
-
#default_song_name ⇒ Object
A string song name that is default.
Methods inherited from Property
define_property, defined_properties, get, #get, get_or_set, gets, hash_with_default_to_nil, inherited, #initialize, properties, properties_hash, property, #set, set, sets
Constructor Details
This class inherits a constructor from Metro::Model::Property
Class Method Details
.song_for(options) ⇒ Object
Returns a Metro::Song. This is composed of the metadata provided and a Gosu::Song.
Songs are cached within the property to increase performance.
83 84 85 |
# File 'lib/metro/models/properties/song_property.rb', line 83 def self.song_for() Song.find_or_create() end |
Instance Method Details
#default_song ⇒ Object
Returns the default song for the song property. This is based on the default song name.
63 64 65 |
# File 'lib/metro/models/properties/song_property.rb', line 63 def default_song self.class.song_for path: default_song_name, window: model.window end |
#default_song_name ⇒ Object
Returns a string song name that is default. If the property was not created with a default value the the default song is the missing song found in Metro.
71 72 73 |
# File 'lib/metro/models/properties/song_property.rb', line 71 def default_song_name [:path] or 'missing.ogg' end |