Class: Waqi::StationData
- Inherits:
-
Object
- Object
- Waqi::StationData
- Defined in:
- lib/waqi/models/station_data.rb
Instance Attribute Summary collapse
-
#aqi ⇒ Object
readonly
Returns the value of attribute aqi.
-
#dominant_pollution ⇒ Object
readonly
Returns the value of attribute dominant_pollution.
-
#idx ⇒ Object
readonly
Returns the value of attribute idx.
-
#station ⇒ Object
readonly
Returns the value of attribute station.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#weather_condition ⇒ Object
readonly
Returns the value of attribute weather_condition.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ StationData
constructor
A new instance of StationData.
Constructor Details
#initialize(args = {}) ⇒ StationData
Returns a new instance of StationData.
22 23 24 25 26 27 28 29 30 |
# File 'lib/waqi/models/station_data.rb', line 22 def initialize(args = {}) @aqi = args[:aqi] @idx = args[:idx] @uid = args[:uid] @station = args[:station] @dominant_pollution = args[:dominant_pollution] @weather_condition = args[:weather_condition] @timestamp = args[:timestamp] end |
Instance Attribute Details
#aqi ⇒ Object (readonly)
Returns the value of attribute aqi.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def aqi @aqi end |
#dominant_pollution ⇒ Object (readonly)
Returns the value of attribute dominant_pollution.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def dominant_pollution @dominant_pollution end |
#idx ⇒ Object (readonly)
Returns the value of attribute idx.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def idx @idx end |
#station ⇒ Object (readonly)
Returns the value of attribute station.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def station @station end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def @timestamp end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def uid @uid end |
#weather_condition ⇒ Object (readonly)
Returns the value of attribute weather_condition.
3 4 5 |
# File 'lib/waqi/models/station_data.rb', line 3 def weather_condition @weather_condition end |
Class Method Details
.parse(data) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/waqi/models/station_data.rb', line 4 def self.parse(data) wheather_condition = data[:iaqi] ? WeatherCondition.new(data[:iaqi]) : nil station = data[:station] ? Station.parse(data[:station]) : Station.parse(data) new( aqi: data[:aqi], idx: data[:idx], uid: data[:uid], dominant_pollution: data[:dominentpol], station: station, weather_condition: wheather_condition, timestamp: parse_time(data[:time]) ) end |
.parse_time(time_data) ⇒ Object
18 19 20 |
# File 'lib/waqi/models/station_data.rb', line 18 def self.parse_time(time_data) DateTime.parse("#{time_data[:s] || time_data[:stime]}#{time_data[:tz]}") rescue nil end |