Class: OpenWeatherMap::City

Inherits:
Object
  • Object
show all
Defined in:
lib/openweathermap/classes.rb

Overview

Represents a city

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, lon, lat, country) ⇒ City

Create a new City object

Parameters:

  • name (String)

    City’s name

  • lon (Float)

    Longitude of the city

  • lat (Float)

    Latitude of the city

  • country (String)

    Country in which the city is



19
20
21
22
23
# File 'lib/openweathermap/classes.rb', line 19

def initialize(name, lon, lat, country)
  @name = name
  @coordinates = OpenWeatherMap::Coordinates.new(lon, lat)
  @country = country
end

Instance Attribute Details

#coordinatesCoordinates (readonly)

Returns City’s coordinates.

Returns:



8
9
10
# File 'lib/openweathermap/classes.rb', line 8

def coordinates
  @coordinates
end

#countryString (readonly)

Returns Country in which the city is.

Returns:

  • (String)

    Country in which the city is



11
12
13
# File 'lib/openweathermap/classes.rb', line 11

def country
  @country
end

#nameString (readonly)

Returns City’s name.

Returns:

  • (String)

    City’s name



5
6
7
# File 'lib/openweathermap/classes.rb', line 5

def name
  @name
end