Class: KPeg::Tag

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

- (Tag) initialize(rule, tag_name)



647
648
649
650
651
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 647

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

Instance Attribute Details

- (Object) rule (readonly)

Returns the value of attribute rule



653
654
655
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 653

def rule
  @rule
end

- (Object) tag_name (readonly)

Returns the value of attribute tag_name



653
654
655
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 653

def tag_name
  @tag_name
end

Instance Method Details

- (Object) ==(obj)



661
662
663
664
665
666
667
668
669
670
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 661

def ==(obj)
  case obj
  when Tag
    @rule == obj.rule and @tag_name == obj.tag_name
  when Rule
    @rule == obj
  else
    super
  end
end

- (Object) inspect



672
673
674
675
676
677
678
679
680
681
682
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 672

def inspect
  if @tag_name
    body = "@#{tag_name} "
  else
    body = ""
  end

  body << @rule.inspect

  inspect_type "tag", body
end

- (Object) match(x)



655
656
657
658
659
# File 'lib/vendor/kpeg/lib/kpeg.rb', line 655

def match(x)
  if m = @rule.match(x)
    Match.new(self, [m])
  end
end