Class: Profitable::NumericResult
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Profitable::NumericResult
- Includes:
- ActionView::Helpers::NumberHelper
- Defined in:
- lib/profitable/numeric_result.rb
Instance Method Summary collapse
-
#initialize(value, type = :currency) ⇒ NumericResult
constructor
A new instance of NumericResult.
- #to_readable(precision = 0) ⇒ Object
Constructor Details
#initialize(value, type = :currency) ⇒ NumericResult
Returns a new instance of NumericResult.
5 6 7 8 |
# File 'lib/profitable/numeric_result.rb', line 5 def initialize(value, type = :currency) super(value) @type = type end |
Instance Method Details
#to_readable(precision = 0) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/profitable/numeric_result.rb', line 10 def to_readable(precision = 0) case @type when :currency "$#{price_in_cents_to_string(self, precision)}" when :percentage "#{number_with_precision(self, precision: precision)}%" when :integer number_with_delimiter(self) when :string self.to_s else to_s end end |