Class: NumberMuncher::Token::Fraction

Inherits:
Base
  • Object
show all
Defined in:
lib/number_muncher/token/fraction.rb

Instance Attribute Summary

Attributes inherited from Base

#text, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, captures, #float?, #initialize, #inspect, #int?, scan, #to_a

Constructor Details

This class inherits a constructor from NumberMuncher::Token::Base

Class Method Details

.regexObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/number_muncher/token/fraction.rb', line 4

def self.regex
  %r{
    (?<sign>-)?
    (?:(?<whole>#{Int.regex})(?:-|\s*))??
    (
      (?<numerator>\d+)\s*/\s*(?<denominator>\d+)
      |
      (?<unicode>#{Unicode::REGEX})
    )
  }x
end

Instance Method Details

#fraction?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/number_muncher/token/fraction.rb', line 16

def fraction?
  true
end