Class: Sunwatch::Response
- Inherits:
-
Object
- Object
- Sunwatch::Response
- Defined in:
- lib/sunwatch/response.rb
Defined Under Namespace
Classes: Hour
Instance Attribute Summary collapse
-
#city ⇒ Object
Returns the value of attribute city.
-
#hours ⇒ Object
Returns the value of attribute hours.
-
#state ⇒ Object
Returns the value of attribute state.
-
#uv_alert ⇒ Object
Returns the value of attribute uv_alert.
-
#uv_index ⇒ Object
Returns the value of attribute uv_index.
-
#zipcode ⇒ Object
Returns the value of attribute zipcode.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #daily? ⇒ Boolean
- #hourly? ⇒ Boolean
-
#initialize(opts) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(opts) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sunwatch/response.rb', line 7 def initialize(opts) @city = opts[:city] @state = opts[:state] @zipcode = opts[:zipcode] @uv_index = opts[:uv_index] @uv_alert = opts[:uv_alert] if opts[:hours] @hours = [] opts[:hours].each do |hour| @hours << Hour.new(to_datetime(hour[:datetime]), hour[:uv_value]) end end end |
Instance Attribute Details
#city ⇒ Object
Returns the value of attribute city.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def city @city end |
#hours ⇒ Object
Returns the value of attribute hours.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def hours @hours end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def state @state end |
#uv_alert ⇒ Object
Returns the value of attribute uv_alert.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def uv_alert @uv_alert end |
#uv_index ⇒ Object
Returns the value of attribute uv_index.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def uv_index @uv_index end |
#zipcode ⇒ Object
Returns the value of attribute zipcode.
5 6 7 |
# File 'lib/sunwatch/response.rb', line 5 def zipcode @zipcode end |
Instance Method Details
#==(other) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/sunwatch/response.rb', line 29 def ==(other) self.class == other.class && @city == other.city && @state == other.state && @zipcode == other.zipcode && @uv_index == other.uv_index && @uv_alert == other.uv_alert && @hours == other.hours end |
#daily? ⇒ Boolean
25 26 27 |
# File 'lib/sunwatch/response.rb', line 25 def daily? @hours == nil end |
#hourly? ⇒ Boolean
21 22 23 |
# File 'lib/sunwatch/response.rb', line 21 def hourly? @hours != nil end |