Class: KPeg::NotPredicate

Inherits:
Rule
  • Object
show all
Defined in:
lib/vendor/kpeg/lib/kpeg.rb

Instance Attribute Summary collapse

Attributes inherited from Rule

#action, #name

Instance Method Summary collapse

Methods inherited from Rule

#detect_tags, #inspect_type, #prune_values, #set_action, #|

Constructor Details

#initialize(rule) ⇒ NotPredicate

Returns a new instance of NotPredicate



580
581
582
583
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 580

def initialize(rule)
  super()
  @rule = rule
end

Instance Attribute Details

#ruleObject (readonly)

Returns the value of attribute rule



585
586
587
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 585

def rule
  @rule
end

Instance Method Details

#==(obj) ⇒ Object



595
596
597
598
599
600
601
602
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 595

def ==(obj)
  case obj
  when NotPredicate
    @rule == obj.rule
  else
    super
  end
end

#inspectObject



604
605
606
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 604

def inspect
  inspect_type "notp", @rule.inspect
end

#match(x) ⇒ Object



587
588
589
590
591
592
593
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 587

def match(x)
  pos = x.pos
  m = @rule.match(x)
  x.pos = pos

  return m ? nil : Match.new(self, "")
end