Class: MeteofranceApi::Place

Inherits:
Object
  • Object
show all
Defined in:
lib/meteofrance_api/models/place.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Place

Returns a new instance of Place.



20
21
22
23
24
25
26
27
28
29
# File 'lib/meteofrance_api/models/place.rb', line 20

def initialize(data)
  @insee = data["insee"]
  @name = data["name"]
  @latitude = data["lat"]
  @longitude = data["lon"]
  @country = data["country"]
  @province = data["admin"]
  @province_code = data["admin2"]
  @postal_code = data["postCode"]
end

Instance Attribute Details

#countryObject (readonly)

country code of the place.



12
13
14
# File 'lib/meteofrance_api/models/place.rb', line 12

def country
  @country
end

#inseeObject (readonly)

INSEE ID of the place.



4
5
6
# File 'lib/meteofrance_api/models/place.rb', line 4

def insee
  @insee
end

#latitudeObject (readonly)

latitude of the place.



8
9
10
# File 'lib/meteofrance_api/models/place.rb', line 8

def latitude
  @latitude
end

#longitudeObject (readonly)

longitude of the place.



10
11
12
# File 'lib/meteofrance_api/models/place.rb', line 10

def longitude
  @longitude
end

#nameObject (readonly)

name of the place.



6
7
8
# File 'lib/meteofrance_api/models/place.rb', line 6

def name
  @name
end

#postal_codeObject (readonly)

postal code of the place.



18
19
20
# File 'lib/meteofrance_api/models/place.rb', line 18

def postal_code
  @postal_code
end

#provinceObject (readonly)

Province/Region of the place.



14
15
16
# File 'lib/meteofrance_api/models/place.rb', line 14

def province
  @province
end

#province_codeObject (readonly)

Province/Region’s numerical code of the place.



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

def province_code
  @province_code
end

Instance Method Details

#to_sObject



31
32
33
34
35
36
37
# File 'lib/meteofrance_api/models/place.rb', line 31

def to_s
  if country == "FR"
    "#{name} - #{admin} (#{admin2}) - #{country}"
  else
    "#{name} - #{admin} - #{country}"
  end
end