diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-05-21 14:33:37 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-05-21 18:43:56 +0000 |
| commit | 12386d36f072527cbd623aabd4df9948cf46c616 (patch) | |
| tree | 2813eb7680c90263e8e8158a9e9c36c52a679c15 /lib | |
| parent | 7a8f797cd4bf7bec1c6d9cba48971b63b1cb839c (diff) | |
[ruby/prism] Provide deprecated numeric method
https://github.com/ruby/prism/commit/77bf9038a2
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/node_ext.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb index 4761e5b9b2..cdc4b2bf08 100644 --- a/lib/prism/node_ext.rb +++ b/lib/prism/node_ext.rb @@ -105,6 +105,18 @@ module Prism def value Rational(numerator, denominator) end + + # Returns the value of the node as an IntegerNode or a FloatNode. This + # method is deprecated in favor of #value or #numerator/#denominator. + def numeric + deprecated("value", "numerator", "denominator") + + if denominator == 1 + IntegerNode.new(source, flags, numerator, location.chop) + else + FloatNode.new(source, numerator.to_f / denominator, location.chop) + end + end end class ConstantReadNode < Node |
