class Sunwatch::Response

Constants

Hour

Attributes

city[RW]
hours[RW]
state[RW]
uv_alert[RW]
uv_index[RW]
zipcode[RW]

Public Class Methods

new(opts) click to toggle source
# 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

Public Instance Methods

==(other) click to toggle source
# 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?() click to toggle source
# File lib/sunwatch/response.rb, line 25
def daily?
  @hours == nil
end
hourly?() click to toggle source
# File lib/sunwatch/response.rb, line 21
def hourly?
  @hours != nil
end

Private Instance Methods

to_datetime(str_datetime) click to toggle source
# File lib/sunwatch/response.rb, line 41
def to_datetime(str_datetime)
  # OCT/19/2014 05 AM
  DateTime.strptime(str_datetime, "%b/%d/%Y %I %p")
end