Class: Location

Inherits:
Struct show all
Defined in:
lib/models/location.rb

Overview

Class Location represents structure of location:

location = Location.new
location.countryRank # => Integer
location.country     # => String
location.cityRank    # => Integer
location.city        # => String
location.stateCode   # => String
location.stateName   # => String
location.code        # => String
location.latitude    # => Float
location.longitude   # => Float

location.from_array(array) # =>  Array of Location objects

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

from_hash

Instance Attribute Details

#cityObject

Returns the value of attribute city

Returns:

  • (Object)

    the current value of city



16
17
18
# File 'lib/models/location.rb', line 16

def city
  @city
end

#cityRankObject

Returns the value of attribute cityRank

Returns:

  • (Object)

    the current value of cityRank



16
17
18
# File 'lib/models/location.rb', line 16

def cityRank
  @cityRank
end

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



16
17
18
# File 'lib/models/location.rb', line 16

def code
  @code
end

#countryObject

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



16
17
18
# File 'lib/models/location.rb', line 16

def country
  @country
end

#countryRankObject

Returns the value of attribute countryRank

Returns:

  • (Object)

    the current value of countryRank



16
17
18
# File 'lib/models/location.rb', line 16

def countryRank
  @countryRank
end

#latitudeObject

Returns the value of attribute latitude

Returns:

  • (Object)

    the current value of latitude



16
17
18
# File 'lib/models/location.rb', line 16

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude

Returns:

  • (Object)

    the current value of longitude



16
17
18
# File 'lib/models/location.rb', line 16

def longitude
  @longitude
end

#stateCodeObject

Returns the value of attribute stateCode

Returns:

  • (Object)

    the current value of stateCode



16
17
18
# File 'lib/models/location.rb', line 16

def stateCode
  @stateCode
end

#stateNameObject

Returns the value of attribute stateName

Returns:

  • (Object)

    the current value of stateName



16
17
18
# File 'lib/models/location.rb', line 16

def stateName
  @stateName
end

Class Method Details

.from_array(array) ⇒ Object

Method from_array returns array of locations(create from json). Takes value of array objects as json parameter array.

Example:

Location.from_array([...array of JSON objects...]) # => Array of Location


25
26
27
28
29
# File 'lib/models/location.rb', line 25

def self.from_array(array)
  array.collect do |element|
    Location.new(element)
  end
end