Class: Peggy::Optional

Inherits:
Multiple show all
Defined in:
lib/parse/builder.rb

Overview

Matcher of 0 or 1 time.

Constant Summary

Constants inherited from Multiple

Multiple::MANY

Instance Attribute Summary

Attributes inherited from Multiple

#range

Attributes included from OneChild

#child

Instance Method Summary collapse

Methods inherited from Multiple

#match

Methods included from OneChild

#wrap

Methods inherited from Element

build, #match, #report

Constructor Details

#initializeOptional

Returns a new instance of Optional.



174
175
176
# File 'lib/parse/builder.rb', line 174

def initialize
  super 0..1
end

Instance Method Details

#to_sObject

Convert element to String.



179
180
181
# File 'lib/parse/builder.rb', line 179

def to_s
  "#{wrap}?"
end