Module: Peggy::OneChild

Included in:
Multiple, Predicate, Production
Defined in:
lib/parse/builder.rb

Overview

An element with a single child element.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#childObject

The single child



37
38
39
# File 'lib/parse/builder.rb', line 37

def child
  @child
end

Instance Method Details

#to_sObject

Convert to String.



43
44
45
# File 'lib/parse/builder.rb', line 43

def to_s
  wrap
end

#wrapObject

Enclose child in parentheses if appropriate.



48
49
50
# File 'lib/parse/builder.rb', line 48

def wrap
  result = child.respond_to?(:each) ? "(#{child})" : child.to_s
end