Class: Rsec::OneOf_

Inherits:
Unary
  • Object
show all
Defined in:
lib/rsec/parsers/misc.rb

Overview

one of char in string

Instance Attribute Summary

Attributes inherited from Unary

#some

Attributes included from Parser

#name

Instance Method Summary collapse

Methods included from Parser

#&, #*, #<<, #>>, #^, #cached, #eof, #fail, #inspect, #join, #map, #maybe, #parse, #parse!, #star, #|

Instance Method Details

#_parse(ctx) ⇒ Object



141
142
143
144
145
146
147
148
149
150
# File 'lib/rsec/parsers/misc.rb', line 141

def _parse ctx
  ctx.skip /\s*/
  return INVALID if ctx.eos?
  chr = ctx.getch
  unless some().index(chr)
    return INVALID
  end
  ctx.skip /\s*/
  chr
end