Class: Patm::Pattern::Compiled
- Inherits:
-
Patm::Pattern
- Object
- Patm::Pattern
- Patm::Pattern::Compiled
- Defined in:
- lib/patm.rb
Instance Attribute Summary collapse
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#src_body ⇒ Object
readonly
Returns the value of attribute src_body.
Instance Method Summary collapse
- #compile_internal(free_index, target_name = "_obj") ⇒ Object
-
#initialize(desc, src, context) ⇒ Compiled
constructor
A new instance of Compiled.
- #inspect ⇒ Object
Methods inherited from Patm::Pattern
#&, #[], build_from, build_from_array, build_from_hash, #compile, #execute, #opt, #opt?, #rest?
Constructor Details
#initialize(desc, src, context) ⇒ Compiled
Returns a new instance of Compiled.
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/patm.rb', line 104 def initialize(desc, src, context) @desc = desc @context = context singleton_class = class <<self; self; end @src_body = src @src = <<-RUBY def execute(_match, _obj) _ctx = @context #{src} end RUBY singleton_class.class_eval(@src) end |
Instance Attribute Details
#src ⇒ Object (readonly)
Returns the value of attribute src.
119 120 121 |
# File 'lib/patm.rb', line 119 def src @src end |
#src_body ⇒ Object (readonly)
Returns the value of attribute src_body.
118 119 120 |
# File 'lib/patm.rb', line 118 def src_body @src_body end |
Instance Method Details
#compile_internal(free_index, target_name = "_obj") ⇒ Object
121 122 123 |
# File 'lib/patm.rb', line 121 def compile_internal(free_index, target_name = "_obj") raise "already compiled" end |
#inspect ⇒ Object
124 |
# File 'lib/patm.rb', line 124 def inspect; "<compiled>#{@desc}"; end |