Class: GhostWheel::Expression::Optional
- Inherits:
-
GhostWheel::Expression
- Object
- GhostWheel::Expression
- GhostWheel::Expression::Optional
- Defined in:
- lib/ghost_wheel/expression/optional.rb
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(expression) ⇒ Optional
constructor
A new instance of Optional.
- #uncached_parse(scanner, cache) ⇒ Object
Methods inherited from GhostWheel::Expression
Constructor Details
#initialize(expression) ⇒ Optional
Returns a new instance of Optional.
6 7 8 |
# File 'lib/ghost_wheel/expression/optional.rb', line 6 def initialize(expression) @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
10 11 12 |
# File 'lib/ghost_wheel/expression/optional.rb', line 10 def expression @expression end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/ghost_wheel/expression/optional.rb', line 21 def ==(other) super and @expression == other.expression end |
#uncached_parse(scanner, cache) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ghost_wheel/expression/optional.rb', line 12 def uncached_parse(scanner, cache) result = @expression.parse(scanner, cache) if result.is_a? FailedParseResult EmptyParseResult.instance else result end end |