Module: TurkishNumeric::NumberPresenter
- Included in:
- TrNum
- Defined in:
- lib/turkish_numeric/number_presenter.rb
Overview
Responsible for providing helper methods to present numbers as text
Instance Method Summary collapse
-
#text_non_spaced(*parts) ⇒ String
Creates non-spaced string representation of the argument.
-
#text_spaced(*parts) ⇒ String
Creates single spaced string representation of the argument.
-
#thousands_separated(numeric, sep: '.') ⇒ String
Create thousand seperated representaion of numeric value.
-
#to_pennies(numeric) ⇒ Integer
Extracts pennies from the argument.
Instance Method Details
#text_non_spaced(*parts) ⇒ String
Creates non-spaced string representation of the argument
27 28 29 |
# File 'lib/turkish_numeric/number_presenter.rb', line 27 def text_non_spaced(*parts) parts.join end |
#text_spaced(*parts) ⇒ String
Creates single spaced string representation of the argument
19 20 21 |
# File 'lib/turkish_numeric/number_presenter.rb', line 19 def text_spaced(*parts) parts.flatten.compact.join(' ') end |
#thousands_separated(numeric, sep: '.') ⇒ String
Create thousand seperated representaion of numeric value
11 12 13 |
# File 'lib/turkish_numeric/number_presenter.rb', line 11 def thousands_separated(numeric, sep: '.') numeric.digits.each_slice(3).map(&:join).join(sep).reverse end |
#to_pennies(numeric) ⇒ Integer
Extracts pennies from the argument
35 36 37 38 39 |
# File 'lib/turkish_numeric/number_presenter.rb', line 35 def to_pennies(numeric) return numeric if numeric < 100 numeric.to_s[0, 2].to_i end |