Class: Bgg::Search::Result
- Inherits:
-
Object
- Object
- Bgg::Search::Result
- Defined in:
- lib/bgg/search_result.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#year_published ⇒ Object
readonly
Returns the value of attribute year_published.
Instance Method Summary collapse
- #game ⇒ Object
-
#initialize(result_item) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(result_item) ⇒ Result
Returns a new instance of Result.
6 7 8 9 10 11 |
# File 'lib/bgg/search_result.rb', line 6 def initialize(result_item) @id = result_item['id'].to_i @name = result_item['name'][0]['value'] @type = result_item['type'] @year_published = result_item.fetch('yearpublished', [{'value' => '0'}])[0]['value'].to_i end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/bgg/search_result.rb', line 4 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/bgg/search_result.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/bgg/search_result.rb', line 4 def type @type end |
#year_published ⇒ Object (readonly)
Returns the value of attribute year_published.
4 5 6 |
# File 'lib/bgg/search_result.rb', line 4 def year_published @year_published end |
Instance Method Details
#game ⇒ Object
13 14 15 |
# File 'lib/bgg/search_result.rb', line 13 def game Bgg::Game.find_by_id(self.id) end |