Class: Bgg::Search::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/bgg/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/bgg/search_result.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/bgg/search_result.rb', line 4

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/bgg/search_result.rb', line 4

def type
  @type
end

#year_publishedObject (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

#gameObject



13
14
15
# File 'lib/bgg/search_result.rb', line 13

def game
  Bgg::Game.find_by_id(self.id)
end