Class: Stratify::Garmin::RssItemAdapter
- Inherits:
-
Object
- Object
- Stratify::Garmin::RssItemAdapter
- Defined in:
- lib/stratify-garmin/rss_item_adapter.rb
Instance Attribute Summary collapse
-
#item ⇒ Object
readonly
Returns the value of attribute item.
Instance Method Summary collapse
- #activity_type ⇒ Object
- #created_at ⇒ Object
- #description ⇒ Object
- #distance_in_miles ⇒ Object
- #elevation_gain_in_feet ⇒ Object
- #event_type ⇒ Object
- #guid ⇒ Object
-
#initialize(item) ⇒ RssItemAdapter
constructor
A new instance of RssItemAdapter.
- #starting_latitude ⇒ Object
- #starting_longitude ⇒ Object
- #time_in_seconds ⇒ Object
- #title ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(item) ⇒ RssItemAdapter
Returns a new instance of RssItemAdapter.
8 9 10 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 8 def initialize(item) @item = item end |
Instance Attribute Details
#item ⇒ Object (readonly)
Returns the value of attribute item.
6 7 8 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 6 def item @item end |
Instance Method Details
#activity_type ⇒ Object
12 13 14 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 12 def activity_type description_content_in_table_row(4) end |
#created_at ⇒ Object
16 17 18 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 16 def created_at item.pubDate end |
#description ⇒ Object
20 21 22 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 20 def description description_as_nokogiri_doc.at_xpath('//table/tr[1]/td[1]').content end |
#distance_in_miles ⇒ Object
24 25 26 27 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 24 def distance_in_miles distance_string = description_content_in_table_row(6) distance_string.to_f end |
#elevation_gain_in_feet ⇒ Object
29 30 31 32 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 29 def elevation_gain_in_feet elevation_gain_string = description_content_in_table_row(8) elevation_gain_string.to_i end |
#event_type ⇒ Object
34 35 36 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 34 def event_type description_content_in_table_row(5) end |
#guid ⇒ Object
38 39 40 41 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 38 def guid guid_url = item.guid guid_url.slice(/\d*$/) # parse the id out of the url ".../activity/12345678" end |
#starting_latitude ⇒ Object
43 44 45 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 43 def starting_latitude starting_location[:latitude] end |
#starting_longitude ⇒ Object
47 48 49 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 47 def starting_longitude starting_location[:longitude] end |
#time_in_seconds ⇒ Object
51 52 53 54 55 56 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 51 def time_in_seconds time_string = description_content_in_table_row(7) time_components = time_string.split(':').map(&:to_i) hours, minutes, seconds = time_components[0], time_components[1], time_components[2] (hours * 3600) + (minutes * 60) + seconds end |
#title ⇒ Object
58 59 60 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 58 def title item.title end |
#username ⇒ Object
62 63 64 |
# File 'lib/stratify-garmin/rss_item_adapter.rb', line 62 def username description_content_in_table_row(2) end |