Class: Sunwatch::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/sunwatch/response.rb

Defined Under Namespace

Classes: Hour

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#cityObject

Returns the value of attribute city.



5
6
7
# File 'lib/sunwatch/response.rb', line 5

def city
  @city
end

#hoursObject

Returns the value of attribute hours.



5
6
7
# File 'lib/sunwatch/response.rb', line 5

def hours
  @hours
end

#stateObject

Returns the value of attribute state.



5
6
7
# File 'lib/sunwatch/response.rb', line 5

def state
  @state
end

#uv_alertObject

Returns the value of attribute uv_alert.



5
6
7
# File 'lib/sunwatch/response.rb', line 5

def uv_alert
  @uv_alert
end

#uv_indexObject

Returns the value of attribute uv_index.



5
6
7
# File 'lib/sunwatch/response.rb', line 5

def uv_index
  @uv_index
end

#zipcodeObject

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/sunwatch/response.rb', line 25

def daily?
  @hours == nil
end

#hourly?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/sunwatch/response.rb', line 21

def hourly?
  @hours != nil
end