Class: Taxger::Lohnsteuer::BigDecimal
- Inherits:
-
Numeric::BigDecimal
- Object
- Numeric::BigDecimal
- Taxger::Lohnsteuer::BigDecimal
- Defined in:
- lib/taxger/lohnsteuer/bigdecimal.rb
Class Method Summary collapse
- .ONE ⇒ Object
- .ROUND_DOWN ⇒ Object
- .ROUND_UP ⇒ Object
- .TEN ⇒ Object
- .value_of(float) ⇒ Object
- .ZERO ⇒ Object
Instance Method Summary collapse
- #add(value) ⇒ Object
- #compare_to(value) ⇒ Object
- #divide(value, scale = nil, rounding = nil) ⇒ Object
- #multiply(value) ⇒ Object
- #set_scale(scale, rounding = nil) ⇒ Object
- #subtract(value) ⇒ Object
Class Method Details
.ONE ⇒ Object
52 53 54 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 52 def self.ONE new(1) end |
.ROUND_DOWN ⇒ Object
64 65 66 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 64 def self.ROUND_DOWN BigDecimal::ROUND_DOWN end |
.ROUND_UP ⇒ Object
60 61 62 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 60 def self.ROUND_UP BigDecimal::ROUND_UP end |
.TEN ⇒ Object
56 57 58 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 56 def self.TEN new(10) end |
.value_of(float) ⇒ Object
44 45 46 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 44 def self.value_of(float) new(float, 16) end |
.ZERO ⇒ Object
48 49 50 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 48 def self.ZERO new(0) end |
Instance Method Details
#add(value) ⇒ Object
22 23 24 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 22 def add(value) BigDecimal.new(self + value) end |
#compare_to(value) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 34 def compare_to(value) if self < value -1 elsif self == value 0 elsif self > value 1 end end |
#divide(value, scale = nil, rounding = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 12 def divide(value, scale = nil, rounding=nil) if scale && rounding BigDecimal.new(self / value).set_scale(scale, rounding) elsif scale BigDecimal.new(self / value).set_scale(scale) else BigDecimal.new(self / value) end end |
#multiply(value) ⇒ Object
4 5 6 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 4 def multiply(value) BigDecimal.new(self * value) end |
#set_scale(scale, rounding = nil) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 26 def set_scale(scale, rounding=nil) if rounding BigDecimal.new(self.round(scale, rounding)) else BigDecimal.new(self.round(scale)) end end |
#subtract(value) ⇒ Object
8 9 10 |
# File 'lib/taxger/lohnsteuer/bigdecimal.rb', line 8 def subtract(value) BigDecimal.new(self - value) end |