Class: RiotSetBuilder::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/riot_set_builder/item.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  count: 1
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Item

Returns a new instance of Item


9
10
11
12
13
14
15
16
# File 'lib/riot_set_builder/item.rb', line 9

def initialize(options = {})
  options = DEFAULT_OPTIONS.merge(options)

  @id = options[:id]
  @count = options[:count]

  verify_attributes
end

Instance Attribute Details

#countObject

Returns the value of attribute count


3
4
5
# File 'lib/riot_set_builder/item.rb', line 3

def count
  @count
end

#idObject

Returns the value of attribute id


3
4
5
# File 'lib/riot_set_builder/item.rb', line 3

def id
  @id
end

Instance Method Details

#verify_attributesObject


18
19
20
21
# File 'lib/riot_set_builder/item.rb', line 18

def verify_attributes
  raise "Item requires an ID" unless id
  raise "Item's count must be a number >= 0"  unless count >= 0
end