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.
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, #rest?
Constructor Details
#initialize(desc, src, context) ⇒ Compiled
Returns a new instance of Compiled.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/patm.rb', line 51 def initialize(desc, src, context) @desc = desc @context = context singleton_class = class <<self; self; end @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.
64 65 66 |
# File 'lib/patm.rb', line 64 def src @src end |
Instance Method Details
#compile_internal(free_index, target_name = "_obj") ⇒ Object
66 67 68 |
# File 'lib/patm.rb', line 66 def compile_internal(free_index, target_name = "_obj") raise "Already compiled" end |
#inspect ⇒ Object
69 |
# File 'lib/patm.rb', line 69 def inspect; "<compiled>#{@desc}"; end |