Class: Songsterr::Data::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/songsterr/data/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (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 attachment_url(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