Class: Zomato2::EntityBase

Inherits:
Object
  • Object
show all
Defined in:
lib/zomato2/entity_base.rb

Instance Method Summary collapse

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_sObject



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