Class: Zomato2::EntityBase
- Inherits:
-
Object
- Object
- Zomato2::EntityBase
- Defined in:
- lib/zomato2/entity_base.rb
Direct Known Subclasses
Category, City, Collection, Cuisine, Establishment, Location, Menu, Restaurant, Review, User
Instance Method Summary collapse
- #get(endpoint, params) ⇒ Object
-
#initialize(zomato_conn) ⇒ EntityBase
constructor
A new instance of EntityBase.
- #to_s ⇒ Object
Constructor Details
#initialize(zomato_conn) ⇒ EntityBase
Returns a new instance of EntityBase.
4 5 6 |
# File 'lib/zomato2/entity_base.rb', line 4 def initialize(zomato_conn) @zom_conn = zomato_conn end |
Instance Method Details
#get(endpoint, params) ⇒ Object
8 9 10 |
# File 'lib/zomato2/entity_base.rb', line 8 def get(endpoint, params) @zom_conn.get(endpoint, params) end |
#to_s ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zomato2/entity_base.rb', line 12 def to_s #self.inspect vals = self.instance_variables.map do |att| next nil if att === :@zom_conn attstr = att.to_s.sub('@','') attstr+": #{self.instance_variable_get(att)}" end classname = self.class.name.sub(/.*:/,'') fields = vals.compact.join ', ' "#{classname}: { #{fields} }" end |