Class: Prism::RationalNode
Instance Method Summary collapse
-
#numeric ⇒ Object
Returns the value of the node as an IntegerNode or a FloatNode.
-
#value ⇒ Object
Returns the value of the node as a Ruby Rational.
Methods inherited from Node
#deprecated, #newline_flag!, #newline_flag?
Instance Method Details
#numeric ⇒ Object
Returns the value of the node as an IntegerNode or a FloatNode. This method is deprecated in favor of #value or #numerator/#denominator.
120 121 122 123 124 125 126 127 128 |
# File 'lib/prism/node_ext.rb', line 120 def numeric deprecated("value", "numerator", "denominator") if denominator == 1 IntegerNode.new(source, -1, location.chop, flags, numerator) else FloatNode.new(source, -1, location.chop, 0, numerator.to_f / denominator) end end |
#value ⇒ Object
Returns the value of the node as a Ruby Rational.
114 115 116 |
# File 'lib/prism/node_ext.rb', line 114 def value Rational(numerator, denominator) end |