Class: Patm::Pattern::Group

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, #rest?

Constructor Details

#initialize(index) ⇒ Group

Returns a new instance of Group.



195
196
197
# File 'lib/patm.rb', line 195

def initialize(index)
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



198
199
200
# File 'lib/patm.rb', line 198

def index
  @index
end

Instance Method Details

#compile_internal(free_index, target_name = "_obj") ⇒ Object



204
205
206
207
208
209
210
# File 'lib/patm.rb', line 204

def compile_internal(free_index, target_name = "_obj")
  [
    "_match[#{@index}] = #{target_name}; true",
    [],
    free_index
  ]
end

#execute(mmatch, obj) ⇒ Object



199
200
201
202
# File 'lib/patm.rb', line 199

def execute(mmatch, obj)
  mmatch[@index] = obj
  true
end

#inspectObject



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

def inspect; "GROUP(#{@index})"; end