Class: OpenWeather::Base

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Defined in:
lib/open_weather/api.rb,
lib/open_weather/base.rb

Direct Known Subclasses

Current, Forecast

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

city, city_id, geocode

Constructor Details

#initialize(url, options) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
# File 'lib/open_weather/base.rb', line 9

def initialize url, options
  @status = false
  @url = url
  @options = extract_options!(options)
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/open_weather/base.rb', line 7

def message
  @message
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/open_weather/base.rb', line 7

def options
  @options
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/open_weather/base.rb', line 7

def status
  @status
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/open_weather/base.rb', line 7

def url
  @url
end

#weather_infoObject (readonly)

Returns the value of attribute weather_info.



7
8
9
# File 'lib/open_weather/base.rb', line 7

def weather_info
  @weather_info
end

Instance Method Details

#retriveObject



15
16
17
18
# File 'lib/open_weather/base.rb', line 15

def retrive
  @response = send_request(self) unless @options.empty?
  parse_response if @response
end

#success?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/open_weather/base.rb', line 20

def success?
  @status == 200
end