Class: Unparser::Preprocessor::Infinity

Inherits:
Unparser::Preprocessor show all
Defined in:
lib/unparser/preprocessor.rb

Overview

Preprocessor transforming numeric nodes with infinity as value to round trippable aequivalent.

Constant Summary collapse

NEG_INFINITY =
- 1)

Constants inherited from Unparser::Preprocessor

EMPTY, REGISTRY

Instance Method Summary collapse

Methods inherited from Unparser::Preprocessor

run

Methods included from NodeHelpers

#n, #s

Instance Method Details

#resultObject

Return preprocessor result

Parameters:

  • (Parser::AST::Node)


195
196
197
198
199
200
201
202
203
204
205
# File 'lib/unparser/preprocessor.rb', line 195

def result
  value = node.children.first
  case value
  when Float::INFINITY
    s(:const, s(:const, nil, :Float), :INFINITY)
  when NEG_INFINITY
    s(:send, s(:const, s(:const, nil, :Float), :INFINITY), :-@)
  else
    node
  end
end