Class: Wunderground::Location
- Inherits:
-
Object
- Object
- Wunderground::Location
- Defined in:
- lib/wunderground/location.rb
Instance Attribute Summary collapse
-
#airport ⇒ Object
Returns the value of attribute airport.
-
#autoip ⇒ Object
Returns the value of attribute autoip.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#long ⇒ Object
Returns the value of attribute long.
-
#pws ⇒ Object
Returns the value of attribute pws.
-
#state ⇒ Object
Returns the value of attribute state.
-
#zip ⇒ Object
Returns the value of attribute zip.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Location
constructor
A new instance of Location.
- #location ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Location
Returns a new instance of Location.
5 6 7 8 9 10 |
# File 'lib/wunderground/location.rb', line 5 def initialize( = {}) raise ArgumentError, "No Location Options Provided" if .empty? .each do |key, value| instance_variable_set("@#{key}".to_sym, value) end end |
Instance Attribute Details
#airport ⇒ Object
Returns the value of attribute airport.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def airport @airport end |
#autoip ⇒ Object
Returns the value of attribute autoip.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def autoip @autoip end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def country @country end |
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def lat @lat end |
#long ⇒ Object
Returns the value of attribute long.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def long @long end |
#pws ⇒ Object
Returns the value of attribute pws.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def pws @pws end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def state @state end |
#zip ⇒ Object
Returns the value of attribute zip.
3 4 5 |
# File 'lib/wunderground/location.rb', line 3 def zip @zip end |
Instance Method Details
#location ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wunderground/location.rb', line 12 def location if zip zip elsif state && city "#{state}/#{city.gsub(' ', '_')}" elsif country && city "#{country.gsub(' ', '_')}/#{city.gsub(' ', '_')}" elsif airport airport elsif lat && long "#{lat},#{long}" elsif pws "pws:#{pws}" elsif autoip "autoip" else raise ArgumentError, "Invalid Location Options" end end |