class KPeg::CharRange
Attributes
fin[R]
start[R]
Public Class Methods
new(start, fin)
click to toggle source
Calls superclass method
KPeg::Operator::new
# File lib/kpeg/grammar.rb, line 158 def initialize(start, fin) super() @start = start @fin = fin @regexp = Regexp.new "[#{Regexp.quote start}-#{Regexp.quote fin}]" end
Public Instance Methods
==(obj)
click to toggle source
Calls superclass method
# File lib/kpeg/grammar.rb, line 179 def ==(obj) case obj when CharRange @start == obj.start and @fin == obj.fin else super end end
inspect()
click to toggle source
# File lib/kpeg/grammar.rb, line 188 def inspect inspect_type 'range', "#{@start}-#{@fin}" end
match(x)
click to toggle source
# File lib/kpeg/grammar.rb, line 171 def match(x) if str = x.scan(@regexp) MatchString.new(self, str) else x.fail(self) end end
string()
click to toggle source
# File lib/kpeg/grammar.rb, line 167 def string @regexp.source end