Class: Songsterr::Data::Base
- Inherits:
-
Object
- Object
- Songsterr::Data::Base
- Defined in:
- lib/songsterr/data/base.rb
Direct Known Subclasses
Artist, Instrument, SongRevision, Track, TrackAudio, TrackLayoutImage, Song
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #attachment_url(key) ⇒ Object
- #info(key) ⇒ Object
-
#initialize(data) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(data) ⇒ Base
Returns a new instance of Base.
6 7 8 |
# File 'lib/songsterr/data/base.rb', line 6 def initialize(data) @data = data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
18 19 20 |
# File 'lib/songsterr/data/base.rb', line 18 def method_missing(method, *args, &block) info(method) or raise NoMethodError, "Method or attribute '#{method}' not exists on #{self.class.name}." end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/songsterr/data/base.rb', line 4 def data @data end |
Instance Method Details
#attachment_url(key) ⇒ Object
14 15 16 |
# File 'lib/songsterr/data/base.rb', line 14 def (key) info(key)['attachmentUrl'] end |
#info(key) ⇒ Object
10 11 12 |
# File 'lib/songsterr/data/base.rb', line 10 def info(key) @data[key.to_s.camelize(:lower)] end |