Module: NumberMuncher
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/number_muncher.rb,
lib/number_muncher/loader.rb,
lib/number_muncher/parser.rb,
lib/number_muncher/numeric.rb,
lib/number_muncher/unicode.rb,
lib/number_muncher/version.rb,
lib/number_muncher/token/int.rb,
lib/number_muncher/tokenizer.rb,
lib/number_muncher/token/base.rb,
lib/number_muncher/to_fraction.rb,
lib/number_muncher/token/float.rb,
lib/number_muncher/token/fraction.rb
Defined Under Namespace
Modules: Loader, Token, Unicode
Classes: IllegalRoundValue, InvalidNumber, InvalidParseExpression, Numeric, Parser, ToFraction, Tokenizer
Constant Summary
collapse
- VERSION =
'0.5.0'.freeze
Class Method Summary
collapse
Class Method Details
.parse(str) ⇒ Object
17
18
19
|
# File 'lib/number_muncher.rb', line 17
def self.parse(str)
Numeric.new(str)
end
|
.scan(str) ⇒ Object
21
22
23
|
# File 'lib/number_muncher.rb', line 21
def self.scan(str)
Tokenizer.new(str).tokenize
end
|
.to_fraction(value, round_to: nil, **opts) ⇒ Object
25
26
27
|
# File 'lib/number_muncher.rb', line 25
def self.to_fraction(value, round_to: nil, **opts)
parse(value).round(round_to).to_fraction(**opts)
end
|