Class: HumanizeFraction::FractionStringParser
- Inherits:
-
Object
- Object
- HumanizeFraction::FractionStringParser
- Defined in:
- lib/humanize_fraction/fraction_string_parser.rb
Constant Summary collapse
- SINGLE_FRACTION =
/\A\s*(\-?\d+)\s*\/\s*(\-?\d+)\s*\z/- MIXED_FRACTION =
/\A\s*(\-?\d*)\s+(\d+)\s*\/\s*(\d+)\s*\z/
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
9 10 11 |
# File 'lib/humanize_fraction/fraction_string_parser.rb', line 9 def string @string end |
Instance Method Details
#fraction_components ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/humanize_fraction/fraction_string_parser.rb', line 15 def fraction_components @fraction_components ||= begin if string_is_mixed_fraction? mixed_fraction_components elsif string_is_single_fraction? single_fraction_components else raise ArgumentError, "Unable to extract fraction from string #{string}" end end end |