Class: BagOfHolding::Dice::ConstantResult

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

Overview

Internal: Present the ‘result’ of a constant with a result API so it can be used interchangeably with an OperationResult or a PoolResult

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value: nil) ⇒ ConstantResult

Returns a new instance of ConstantResult.



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

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

Instance Attribute Details

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
# File 'lib/bag_of_holding/dice/constant_result.rb', line 20

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

#inspectObject



16
17
18
# File 'lib/bag_of_holding/dice/constant_result.rb', line 16

def inspect
  value.to_s
end

#to_sObject



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

def to_s
  value.to_s
end