Class: HumanizeFraction::Humanizer
- Inherits:
-
Object
- Object
- HumanizeFraction::Humanizer
- Defined in:
- lib/humanize_fraction/humanizer.rb
Constant Summary collapse
- NUMBERS_STARTING_WITH_SILENT_VOWEL =
Numbers that should be prefixed with ‘a` instead of `an` even though they start with a vowel.
[ "one", ]
Instance Attribute Summary collapse
-
#denominator ⇒ Object
readonly
Returns the value of attribute denominator.
-
#numerator ⇒ Object
readonly
Returns the value of attribute numerator.
-
#whole_part ⇒ Object
readonly
Returns the value of attribute whole_part.
Instance Method Summary collapse
Instance Attribute Details
#denominator ⇒ Object (readonly)
Returns the value of attribute denominator.
9 10 11 |
# File 'lib/humanize_fraction/humanizer.rb', line 9 def denominator @denominator end |
#numerator ⇒ Object (readonly)
Returns the value of attribute numerator.
9 10 11 |
# File 'lib/humanize_fraction/humanizer.rb', line 9 def numerator @numerator end |
#whole_part ⇒ Object (readonly)
Returns the value of attribute whole_part.
9 10 11 |
# File 'lib/humanize_fraction/humanizer.rb', line 9 def whole_part @whole_part end |
Instance Method Details
#to_s(shorthand: false, quarter: false) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/humanize_fraction/humanizer.rb', line 18 def to_s(shorthand: false, quarter: false) humanized_denominator = humanize_denominator(shorthand: shorthand, quarter: quarter) words = [] words << humanize_whole_part if !whole_part.nil? words << humanize_numerator(humanized_denominator, shorthand: shorthand) words << humanized_denominator words.join(" ") end |