Class: HumanizeFraction::Humanizer

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#denominatorObject (readonly)

Returns the value of attribute denominator.



9
10
11
# File 'lib/humanize_fraction/humanizer.rb', line 9

def denominator
  @denominator
end

#numeratorObject (readonly)

Returns the value of attribute numerator.



9
10
11
# File 'lib/humanize_fraction/humanizer.rb', line 9

def numerator
  @numerator
end

#whole_partObject (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