Class: Barometer::Response::Base
- Inherits:
-
Object
- Object
- Barometer::Response::Base
- Defined in:
- lib/barometer/response/base.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#forecast ⇒ Object
Returns the value of attribute forecast.
Instance Method Summary collapse
- #add_query(query) ⇒ Object
- #complete? ⇒ Boolean
- #for(date = nil) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #metric? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
22 23 24 25 |
# File 'lib/barometer/response/base.rb', line 22 def initialize super @requested_at = Time.now.utc end |
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
20 21 22 |
# File 'lib/barometer/response/base.rb', line 20 def current @current end |
#forecast ⇒ Object
Returns the value of attribute forecast.
20 21 22 |
# File 'lib/barometer/response/base.rb', line 20 def forecast @forecast end |
Instance Method Details
#add_query(query) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/barometer/response/base.rb', line 39 def add_query(query) return unless query @query = query.to_s @format = query.format @metric = query.metric? end |
#complete? ⇒ Boolean
31 32 33 |
# File 'lib/barometer/response/base.rb', line 31 def complete? current && current.complete? end |
#for(date = nil) ⇒ Object
35 36 37 |
# File 'lib/barometer/response/base.rb', line 35 def for(date=nil) forecast.for(date || today) end |
#metric? ⇒ Boolean
46 47 48 |
# File 'lib/barometer/response/base.rb', line 46 def metric? !!@metric end |
#success? ⇒ Boolean
27 28 29 |
# File 'lib/barometer/response/base.rb', line 27 def success? status_code == 200 end |