Class: TripIt::WeatherObject
- Inherits:
-
BaseObject
- Object
- Base
- BaseObject
- TripIt::WeatherObject
- Defined in:
- lib/trip_it/classes/objects/weather_object.rb
Instance Attribute Summary
Attributes inherited from BaseObject
#id, #is_client_traveler, #relative_url
Instance Method Summary collapse
-
#initialize(client, obj_id = nil, source = nil) ⇒ WeatherObject
constructor
A new instance of WeatherObject.
- #populate(source) ⇒ Object
- #sequence ⇒ Object
Methods inherited from BaseObject
Methods inherited from Base
#Boolean, #camelize, #chkAndPopulate, #chkObjAndPopulate, #convertDT, #to_hash, #to_json, #to_xml
Methods included from ParamUtil
#address_param, #airportcode_param, #array_param, #boolean_param, #boolean_read_param, #camelize, #date_param, #datetime_param, #exceptions, #float_param, #integer_param, #string_param, #time_param, #traveler_array_param, #traveler_param
Constructor Details
#initialize(client, obj_id = nil, source = nil) ⇒ WeatherObject
Returns a new instance of WeatherObject.
7 8 9 10 11 12 13 |
# File 'lib/trip_it/classes/objects/weather_object.rb', line 7 def initialize(client, obj_id = nil, source = nil) @client = client unless obj_id.nil? @obj_id = obj_id populate(source) end end |
Instance Method Details
#populate(source) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trip_it/classes/objects/weather_object.rb', line 15 def populate(source) info = source || @client.get("/weather", :id => @obj_id)["WeatherObject"] super(info) @date = Date.parse(info["date"]) unless info["date"].nil? @location = info["location"] @avg_high_temp_c = info["avg_high_temp_c"].to_f @avg_low_temp_c = info["avg_low_temp_c"].to_f @avg_wind_speed_kn = info["avg_wind_speed_kn"].to_f @avg_precipitation_cm = info["avg_precipitation_cm"].to_f @avg_snow_depth_cm = info["avg_snow_depth_cm"].to_f end |
#sequence ⇒ Object
27 28 29 30 |
# File 'lib/trip_it/classes/objects/weather_object.rb', line 27 def sequence arr = super arr + ["@date", "@location", "@avg_high_temp_c", "@avg_low_temp_c", "@avg_wind_speed_kn", "@avg_precipitation_cm", "@avg_snow_depth_cm"] end |