Class: Songdrop::Base
- Inherits:
-
Object
- Object
- Songdrop::Base
- Defined in:
- lib/songdrop/objects/base.rb
Instance Attribute Summary collapse
-
#_properties ⇒ Object
readonly
Returns the value of attribute _properties.
Instance Method Summary collapse
- #errors? ⇒ Boolean
-
#initialize(properties = {}) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(properties = {}) ⇒ Base
5 6 7 |
# File 'lib/songdrop/objects/base.rb', line 5 def initialize(properties={}) @_properties = properties end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/songdrop/objects/base.rb', line 9 def method_missing(method, *args, &block) method = $1 if method =~ /(\S+)\?/ method = method.to_sym result = @_properties[method] result = Time.at(result.to_i) if result and method =~ /_at/ result = Time.at(result.to_i).to_date if result and method =~ /_on/ result end |
Instance Attribute Details
#_properties ⇒ Object (readonly)
Returns the value of attribute _properties.
3 4 5 |
# File 'lib/songdrop/objects/base.rb', line 3 def _properties @_properties end |
Instance Method Details
#errors? ⇒ Boolean
18 19 20 |
# File 'lib/songdrop/objects/base.rb', line 18 def errors? !self.errors.nil? end |