Class: KPeg::Choice
Instance Attribute Summary collapse
-
#ops ⇒ Object
readonly
Returns the value of attribute ops.
Attributes inherited from Operator
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(*many) ⇒ Choice
constructor
A new instance of Choice.
- #inspect ⇒ Object
- #match(x) ⇒ Object
- #|(other) ⇒ Object
Methods inherited from Operator
#detect_tags, #inspect_type, #prune_values, #set_action
Constructor Details
#initialize(*many) ⇒ Choice
Returns a new instance of Choice.
194 195 196 197 |
# File 'lib/kpeg/grammar.rb', line 194 def initialize(*many) super() @ops = many end |
Instance Attribute Details
#ops ⇒ Object (readonly)
Returns the value of attribute ops.
199 200 201 |
# File 'lib/kpeg/grammar.rb', line 199 def ops @ops end |
Instance Method Details
#==(obj) ⇒ Object
220 221 222 223 224 225 226 227 |
# File 'lib/kpeg/grammar.rb', line 220 def ==(obj) case obj when Choice @ops == obj.ops else super end end |
#inspect ⇒ Object
229 230 231 |
# File 'lib/kpeg/grammar.rb', line 229 def inspect inspect_type "any", @ops.map { |i| i.inspect }.join(' | ') end |
#match(x) ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/kpeg/grammar.rb', line 206 def match(x) pos = x.pos @ops.each do |c| if m = c.match(x) return m end x.pos = pos end return nil end |