Class: RWeatherCurrentCondition

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#barObject

Returns the value of attribute bar.



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

def bar
  @bar
end

#dewpObject

Returns the value of attribute dewp.



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

def dewp
  @dewp
end

#flikObject

Returns the value of attribute flik.



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

def flik
  @flik
end

#hmidObject

Returns the value of attribute hmid.



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

def hmid
  @hmid
end

#iconObject

Returns the value of attribute icon.



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

def icon
  @icon
end

#lsupObject

Returns the value of attribute lsup.



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

def lsup
  @lsup
end

#moonObject

Returns the value of attribute moon.



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

def moon
  @moon
end

#obstObject

Returns the value of attribute obst.



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

def obst
  @obst
end

#tObject

Returns the value of attribute t.



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

def t
  @t
end

#tmpObject

Returns the value of attribute tmp.



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

def tmp
  @tmp
end

#uvObject

Returns the value of attribute uv.



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

def uv
  @uv
end

#visObject

Returns the value of attribute vis.



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

def vis
  @vis
end

#windObject

Returns the value of attribute wind.



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

def wind
  @wind
end

Class Method Details

.element_value(key, value) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/r_weather_current_condition.rb', line 19

def element_value(key, value)
  if value.size == 1 && !value.first.is_a?(Hash)
    value.first
  else
    data = const_get(:"RWeather#{key.capitalize}").new
    value.first.each do |key, value|
      data.send(:"#{key}=", value.first)
    end
    data
  end
end

.parse(simple_xml) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/r_weather_current_condition.rb', line 9

def self.parse(simple_xml)
  current_condition = new
  cc = simple_xml['cc'].first
  cc.each do |key, value|
    current_condition.send(:"#{key}=", element_value(key, value))
  end
  current_condition
end