Class: Patm::Pattern::Or

Inherits:
LogicalOp show all
Defined in:
lib/patm.rb

Instance Method Summary collapse

Methods inherited from LogicalOp

#compile_internal

Methods inherited from Patm::Pattern

#&, build_from, #compile, #compile_internal

Constructor Details

#initialize(pats) ⇒ Or

Returns a new instance of Or.



237
238
239
# File 'lib/patm.rb', line 237

def initialize(pats)
  super(pats, '||')
end

Instance Method Details

#execute(mmatch, obj) ⇒ Object



240
241
242
243
244
# File 'lib/patm.rb', line 240

def execute(mmatch, obj)
  @pats.any? do|pat|
    pat.execute(mmatch, obj)
  end
end

#inspectObject



248
249
250
# File 'lib/patm.rb', line 248

def inspect
  "OR(#{@pats.map(&:inspect).join(',')})"
end

#rest?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/patm.rb', line 245

def rest?
  @pats.any?(&:rest?)
end