Class: DoubleEntry::Reporting::Aggregate Private
- Inherits:
-
Object
- Object
- DoubleEntry::Reporting::Aggregate
- Defined in:
- lib/double_entry/reporting/aggregate.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #account ⇒ Object readonly private
- #code ⇒ Object readonly private
- #filter ⇒ Object readonly private
- #function ⇒ Object readonly private
- #options ⇒ Object readonly private
- #range ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #amount(force_recalculation = false) ⇒ Object private
- #formatted_amount ⇒ Object private
-
#initialize(function, account, code, options) ⇒ Aggregate
constructor
private
A new instance of Aggregate.
Constructor Details
#initialize(function, account, code, options) ⇒ Aggregate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Aggregate.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/double_entry/reporting/aggregate.rb', line 7 def initialize(function, account, code, ) @function = function.to_s raise AggregateFunctionNotSupported unless %w[sum count average].include?(@function) @account = account.to_s @code = code ? code.to_s : nil = @range = [:range] @filter = [:filter] end |
Instance Attribute Details
#account ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def account @account end |
#code ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def code @code end |
#filter ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def filter @filter end |
#function ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def function @function end |
#options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def end |
#range ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
5 6 7 |
# File 'lib/double_entry/reporting/aggregate.rb', line 5 def range @range end |
Class Method Details
.formatted_amount(function, amount) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/double_entry/reporting/aggregate.rb', line 31 def self.formatted_amount(function, amount) safe_amount = amount || 0 case function.to_s when 'count' safe_amount else Money.new(safe_amount) end end |
Instance Method Details
#amount(force_recalculation = false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 |
# File 'lib/double_entry/reporting/aggregate.rb', line 18 def amount(force_recalculation = false) if force_recalculation clear_old_aggregates calculate else retrieve || calculate end end |
#formatted_amount ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/double_entry/reporting/aggregate.rb', line 27 def formatted_amount Aggregate.formatted_amount(function, amount) end |