Class: HeadlineResponse::HeadlineItem
- Inherits:
-
Object
- Object
- HeadlineResponse::HeadlineItem
- Defined in:
- lib/espn_rb/headline_item.rb
Instance Attribute Summary collapse
-
#headline ⇒ Object
readonly
Returns the value of attribute headline.
Instance Method Summary collapse
-
#api_url ⇒ String
Api_url for Item.
-
#athlete_ids ⇒ Object
Provides access to categories sub-hash.
-
#athletes ⇒ Object
Provides access to categories sub-hash.
- #categories ⇒ Object
- #collect_category(sym) ⇒ Object
-
#id ⇒ Integer
Id for Item.
-
#initialize(opts) ⇒ HeadlineItem
constructor
A new instance of HeadlineItem.
-
#leagues ⇒ Object
Provides access to categories sub-hash.
-
#title ⇒ String
Title for Item.
-
#web_url(mobile = false) ⇒ String
Web_url for Item.
Constructor Details
#initialize(opts) ⇒ HeadlineItem
5 6 7 |
# File 'lib/espn_rb/headline_item.rb', line 5 def initialize(opts) @headline = opts end |
Instance Attribute Details
#headline ⇒ Object (readonly)
Returns the value of attribute headline.
3 4 5 |
# File 'lib/espn_rb/headline_item.rb', line 3 def headline @headline end |
Instance Method Details
#api_url ⇒ String
Returns api_url for Item.
38 39 40 |
# File 'lib/espn_rb/headline_item.rb', line 38 def api_url @headline["links"]["api"]["news"]["href"] end |
#athlete_ids ⇒ Object
Provides access to categories sub-hash. If available
#=> [“123”, “132”, “123”]
73 74 75 |
# File 'lib/espn_rb/headline_item.rb', line 73 def athlete_ids return collect_category(:athleteId) end |
#athletes ⇒ Object
Provides access to categories sub-hash. If available
#=> [“Johnny B”, “Freddie Flintstone”, “Etc”]
53 54 55 |
# File 'lib/espn_rb/headline_item.rb', line 53 def athletes return collect_category(:description) end |
#categories ⇒ Object
77 78 79 |
# File 'lib/espn_rb/headline_item.rb', line 77 def categories @headline["categories"] end |
#collect_category(sym) ⇒ Object
43 44 45 |
# File 'lib/espn_rb/headline_item.rb', line 43 def collect_category(sym) @headline["categories"].inject([]) {|m, i| m << i[sym.to_s] unless i[sym.to_s].nil?; m} end |
#id ⇒ Integer
Returns id for Item.
30 31 32 |
# File 'lib/espn_rb/headline_item.rb', line 30 def id @headline["id"] end |
#leagues ⇒ Object
Provides access to categories sub-hash. If available
#=> [“46”]
63 64 65 |
# File 'lib/espn_rb/headline_item.rb', line 63 def leagues return collect_category(:leagueId) end |
#title ⇒ String
Returns title for Item.
21 22 23 |
# File 'lib/espn_rb/headline_item.rb', line 21 def title @headline["headline"] end |
#web_url(mobile = false) ⇒ String
Returns web_url for Item.
13 14 15 |
# File 'lib/espn_rb/headline_item.rb', line 13 def web_url(mobile=false) (mobile == true) ? @headline["links"]["mobile"]["href"] : @headline["links"]["web"]["href"] end |