Class: ActsAsCalculator::Result

Inherits:
Data
  • Object
show all
Defined in:
lib/acts_as_calculator/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:, breakdown: {}, formula_version: nil, as_of: nil) ⇒ Result

Returns a new instance of Result.



5
6
7
# File 'lib/acts_as_calculator/result.rb', line 5

def initialize(value:, breakdown: {}, formula_version: nil, as_of: nil)
  super(value:, breakdown: deep_copy(breakdown), formula_version:, as_of:)
end

Instance Attribute Details

#as_ofObject (readonly)

Returns the value of attribute as_of

Returns:

  • (Object)

    the current value of as_of



4
5
6
# File 'lib/acts_as_calculator/result.rb', line 4

def as_of
  @as_of
end

#breakdownObject (readonly)

Returns the value of attribute breakdown

Returns:

  • (Object)

    the current value of breakdown



4
5
6
# File 'lib/acts_as_calculator/result.rb', line 4

def breakdown
  @breakdown
end

#formula_versionObject (readonly)

Returns the value of attribute formula_version

Returns:

  • (Object)

    the current value of formula_version



4
5
6
# File 'lib/acts_as_calculator/result.rb', line 4

def formula_version
  @formula_version
end

#valueObject (readonly)

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



4
5
6
# File 'lib/acts_as_calculator/result.rb', line 4

def value
  @value
end

Instance Method Details

#expressionObject



13
14
15
# File 'lib/acts_as_calculator/result.rb', line 13

def expression
  breakdown[:expression]
end

#inputsObject



9
10
11
# File 'lib/acts_as_calculator/result.rb', line 9

def inputs
  breakdown.fetch(:inputs, {})
end