Class: BagOfHolding::Dice::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/bag_of_holding/dice/constant.rb

Overview

Internal: Stores a constant value with a rollable API so that this object can be called like a pool or operation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:) ⇒ Constant

Returns a new instance of Constant.



8
9
10
# File 'lib/bag_of_holding/dice/constant.rb', line 8

def initialize(value:)
  self.value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/bag_of_holding/dice/constant.rb', line 6

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
# File 'lib/bag_of_holding/dice/constant.rb', line 16

def ==(other)
  return false unless other.respond_to? :value
  return false unless value == other.value
  true
end

#rollObject



12
13
14
# File 'lib/bag_of_holding/dice/constant.rb', line 12

def roll
  BagOfHolding::Dice::ConstantResult.new value: value
end