Class: RubyNext::Language::Rewriters::Abstract
- Inherits:
-
Parser::TreeRewriter
- Object
- Parser::TreeRewriter
- RubyNext::Language::Rewriters::Abstract
- Defined in:
- lib/ruby-next/language/rewriters/abstract.rb
Constant Summary collapse
- NAME =
"custom-rewriter"
- SYNTAX_PROBE =
"1 = [}"
- MIN_SUPPORTED_VERSION =
Gem::Version.new(RubyNext::NEXT_VERSION)
Class Method Summary collapse
- .ast? ⇒ Boolean
- .text? ⇒ Boolean
-
.unsupported_syntax? ⇒ Boolean
Returns true if the syntax is not supported by the current Ruby (performs syntax check, not version check).
-
.unsupported_version?(version) ⇒ Boolean
Returns true if the syntax is supported by the specified version.
Instance Method Summary collapse
-
#initialize(context) ⇒ Abstract
constructor
A new instance of Abstract.
Constructor Details
#initialize(context) ⇒ Abstract
Returns a new instance of Abstract.
46 47 48 49 |
# File 'lib/ruby-next/language/rewriters/abstract.rb', line 46 def initialize(context) @context = context super() end |
Class Method Details
.ast? ⇒ Boolean
35 36 37 |
# File 'lib/ruby-next/language/rewriters/abstract.rb', line 35 def ast? false end |
.text? ⇒ Boolean
31 32 33 |
# File 'lib/ruby-next/language/rewriters/abstract.rb', line 31 def text? false end |
.unsupported_syntax? ⇒ Boolean
Returns true if the syntax is not supported by the current Ruby (performs syntax check, not version check)
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby-next/language/rewriters/abstract.rb', line 14 def unsupported_syntax? save_verbose, $VERBOSE = $VERBOSE, nil eval_mid = Kernel.respond_to?(:eval_without_ruby_next) ? :eval_without_ruby_next : :eval Kernel.send eval_mid, self::SYNTAX_PROBE, nil, __FILE__, __LINE__ false rescue SyntaxError, StandardError true ensure $VERBOSE = save_verbose end |
.unsupported_version?(version) ⇒ Boolean
Returns true if the syntax is supported by the specified version
27 28 29 |
# File 'lib/ruby-next/language/rewriters/abstract.rb', line 27 def unsupported_version?(version) version < self::MIN_SUPPORTED_VERSION end |