Class: HeadlineResponse::HeadlineItem
- Inherits:
-
Object
- Object
- HeadlineResponse::HeadlineItem
- Defined in:
- lib/espn_rb/headline_item.rb,
lib/espn_rb/headline_image.rb
Defined Under Namespace
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
-
#description ⇒ String
Description for Item.
-
#id ⇒ Integer
Id for Item.
-
#images ⇒ Images
Images class containing the collection of images associated with the item.
-
#initialize(opts) ⇒ HeadlineItem
constructor
A new instance of HeadlineItem.
-
#last_modified ⇒ String
Title for Item.
-
#leagues ⇒ Object
Provides access to categories sub-hash.
-
#source ⇒ String
Source for Item.
-
#title ⇒ String
Title for Item.
-
#web_url(mobile = false) ⇒ String
Web_url for Item.
Constructor Details
#initialize(opts) ⇒ HeadlineItem
Returns a new instance of 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.
69 70 71 |
# File 'lib/espn_rb/headline_item.rb', line 69 def api_url @headline["links"]["api"]["news"]["href"] end |
#athlete_ids ⇒ Object
Provides access to categories sub-hash. If available
#=> [“123”, “132”, “123”]
104 105 106 |
# File 'lib/espn_rb/headline_item.rb', line 104 def athlete_ids return collect_category(:athleteId) end |
#athletes ⇒ Object
Provides access to categories sub-hash. If available
#=> [“Johnny B”, “Freddie Flintstone”, “Etc”]
84 85 86 |
# File 'lib/espn_rb/headline_item.rb', line 84 def athletes return collect_category(:description) end |
#categories ⇒ Object
108 109 110 |
# File 'lib/espn_rb/headline_item.rb', line 108 def categories @headline["categories"] end |
#collect_category(sym) ⇒ Object
74 75 76 |
# File 'lib/espn_rb/headline_item.rb', line 74 def collect_category(sym) @headline["categories"].inject([]) {|m, i| m << i[sym.to_s] unless i[sym.to_s].nil?; m} end |
#description ⇒ String
Returns description for Item.
29 30 31 |
# File 'lib/espn_rb/headline_item.rb', line 29 def description @headline["description"] end |
#id ⇒ Integer
Returns id for Item.
61 62 63 |
# File 'lib/espn_rb/headline_item.rb', line 61 def id @headline["id"] end |
#images ⇒ Images
Returns Images class containing the collection of images associated with the item.
53 54 55 |
# File 'lib/espn_rb/headline_item.rb', line 53 def images Images.new @headline["images"] end |
#last_modified ⇒ String
Returns title for Item.
45 46 47 |
# File 'lib/espn_rb/headline_item.rb', line 45 def last_modified @headline["lastModified"] end |
#leagues ⇒ Object
Provides access to categories sub-hash. If available
#=> [“46”]
94 95 96 |
# File 'lib/espn_rb/headline_item.rb', line 94 def leagues return collect_category(:leagueId) end |
#source ⇒ String
Returns source for Item.
37 38 39 |
# File 'lib/espn_rb/headline_item.rb', line 37 def source @headline["source"] 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 |