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, #compile, #execute, #opt, #opt?, #rest?
Constructor Details
#initialize(desc, src, context) ⇒ Compiled
Returns a new instance of Compiled.
96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/patm.rb', line 96 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.
111 112 113 |
# File 'lib/patm.rb', line 111 def src @src end |
#src_body ⇒ Object (readonly)
Returns the value of attribute src_body.
110 111 112 |
# File 'lib/patm.rb', line 110 def src_body @src_body end |
Instance Method Details
#compile_internal(free_index, target_name = "_obj") ⇒ Object
113 114 115 |
# File 'lib/patm.rb', line 113 def compile_internal(free_index, target_name = "_obj") raise "already compiled" end |
#inspect ⇒ Object
116 |
# File 'lib/patm.rb', line 116 def inspect; "<compiled>#{@desc}"; end |