Class: TRuby::CodeEmitter::Base
- Inherits:
-
Object
- Object
- TRuby::CodeEmitter::Base
- Defined in:
- lib/t_ruby/code_emitter.rb
Overview
Base class for version-specific code emitters
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(version) ⇒ Base
constructor
A new instance of Base.
-
#numbered_params_error? ⇒ Boolean
Check if numbered parameters raise NameError in this version.
-
#supports_it? ⇒ Boolean
Check if this version supports the ‘it` implicit block parameter.
-
#transform(source) ⇒ String
Apply all transformations for this version.
-
#transform_block_forwarding(source) ⇒ String
Transform block forwarding syntax Default: no transformation.
-
#transform_numbered_params(source) ⇒ String
Transform numbered block parameters (_1, _2, etc.) Default: no transformation.
Constructor Details
#initialize(version) ⇒ Base
Returns a new instance of Base.
33 34 35 |
# File 'lib/t_ruby/code_emitter.rb', line 33 def initialize(version) @version = version end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
31 32 33 |
# File 'lib/t_ruby/code_emitter.rb', line 31 def version @version end |
Instance Method Details
#numbered_params_error? ⇒ Boolean
Check if numbered parameters raise NameError in this version
75 76 77 |
# File 'lib/t_ruby/code_emitter.rb', line 75 def numbered_params_error? false end |
#supports_it? ⇒ Boolean
Check if this version supports the ‘it` implicit block parameter
68 69 70 |
# File 'lib/t_ruby/code_emitter.rb', line 68 def supports_it? false end |
#transform(source) ⇒ String
Apply all transformations for this version
41 42 43 44 45 |
# File 'lib/t_ruby/code_emitter.rb', line 41 def transform(source) result = source.dup result = transform_numbered_params(result) transform_block_forwarding(result) end |
#transform_block_forwarding(source) ⇒ String
Transform block forwarding syntax Default: no transformation
61 62 63 |
# File 'lib/t_ruby/code_emitter.rb', line 61 def transform_block_forwarding(source) source end |
#transform_numbered_params(source) ⇒ String
Transform numbered block parameters (_1, _2, etc.) Default: no transformation
52 53 54 |
# File 'lib/t_ruby/code_emitter.rb', line 52 def transform_numbered_params(source) source end |