Class: GeoAPI::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/geoapi/entity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Entity

Instance methods



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/geoapi/entity.rb', line 9

def initialize(attrs)
  @raw_json = JSON.generate(attrs)
  @guid = attrs['guid']
  if attrs['meta']
    @name = attrs['meta']['name']
    @views = attrs['meta']['views'] || []
    @userviews = attrs['meta']['userviews'] || []
    @type = attrs['meta']['type'].to_sym
  end
  self
end

Instance Attribute Details

#geomObject (readonly)

Returns the value of attribute geom.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def geom
  @geom
end

#guidObject (readonly)

Returns the value of attribute guid.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def guid
  @guid
end

#latitudeObject (readonly) Also known as: lat

Returns the value of attribute latitude.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def latitude
  @latitude
end

#longitudeObject (readonly) Also known as: lon

Returns the value of attribute longitude.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def name
  @name
end

#raw_jsonObject (readonly)

Returns the value of attribute raw_json.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def raw_json
  @raw_json
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def type
  @type
end

#urlObject (readonly)

Returns the value of attribute url.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def url
  @url
end

#userviewsObject (readonly)

Returns the value of attribute userviews.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def userviews
  @userviews
end

#viewsObject (readonly)

Returns the value of attribute views.



3
4
5
# File 'lib/geoapi/entity.rb', line 3

def views
  @views
end

Instance Method Details

#to_jsonObject



25
26
27
# File 'lib/geoapi/entity.rb', line 25

def to_json
  self.raw_json
end

#to_sObject



21
22
23
# File 'lib/geoapi/entity.rb', line 21

def to_s
  self.name
end