Class: MyShows::Item
- Inherits:
-
Object
- Object
- MyShows::Item
- Defined in:
- lib/myshows/item.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(id, data) ⇒ Item
constructor
A new instance of Item.
- #method_missing(name, *args) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/myshows/item.rb', line 12 def method_missing(name, *args) return super(name, *args) if args.count > 0 # convert to camel case cc_name = name.to_s.gsub(/_[a-z]/) {|a| a.upcase }.gsub '_', '' @data[cc_name] or super(name) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/myshows/item.rb', line 3 def id @id end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/myshows/item.rb', line 21 def ==(other) self.class == other.class && self.id == other.id end |