Class: RubyNext::Language::Rewriters::Dir
Overview
Special rewriter for Ruby <=2.3, which doesn’t support __dir__ in iseq.eval
Constant Summary collapse
- SYNTAX_PROBE =
"defined?(RubyVM::InstructionSequence) && RubyVM::InstructionSequence.compile('raise SyntaxError if __dir__.nil?', 'test.rb').eval"
- MIN_SUPPORTED_VERSION =
Gem::Version.new("2.4.0")
Constants inherited from Abstract
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Methods inherited from Abstract
ast?, #initialize, text?, unsupported_syntax?, unsupported_version?
Constructor Details
This class inherits a constructor from RubyNext::Language::Rewriters::Base
Instance Method Details
#on_send(node) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby-next/language/rewriters/2.4/dir.rb', line 11 def on_send(node) return super(node) unless node.children[1] == :__dir__ context.track! self replace(node.loc.expression, "File.dirname(__FILE__)") process( node.updated( nil, [ s(:const, nil, :File), :dirname, s(:send, nil, "__FILE__") ] ) ) end |