Class: Smite::Object
- Inherits:
-
Object
- Object
- Smite::Object
- Defined in:
- lib/smite/object.rb
Direct Known Subclasses
Ability, Achievements, Friend, God, GodRank, GodStats, Item, ItemEffect, MOTD, Match, Player, Queue, RecentMatch, RecommendedItems
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(data) ⇒ Object
constructor
A new instance of Object.
- #method_missing(method) ⇒ Object
Constructor Details
#initialize(data) ⇒ Object
Returns a new instance of Object.
5 6 7 8 9 10 |
# File 'lib/smite/object.rb', line 5 def initialize(data) @data = data.each_with_object({}) do |(k, v), obj| next if k == 'ret_msg' obj[ActiveSupport::Inflector.underscore(k)] = v end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
16 17 18 19 |
# File 'lib/smite/object.rb', line 16 def method_missing(method) camel_method = ActiveSupport::Inflector.underscore(method.to_s) @data.include?(camel_method) ? @data[camel_method] : super end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
3 4 5 |
# File 'lib/smite/object.rb', line 3 def data @data end |
Instance Method Details
#attributes ⇒ Object
12 13 14 |
# File 'lib/smite/object.rb', line 12 def attributes @data.keys end |