Class: Patm::Pattern::Compiled

Inherits:
Patm::Pattern show all
Defined in:
lib/patm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#srcObject (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

#inspectObject



69
# File 'lib/patm.rb', line 69

def inspect; "<compiled>#{@desc}"; end