Class: GhostWheel::Expression::Literal
- Inherits:
-
GhostWheel::Expression
- Object
- GhostWheel::Expression
- GhostWheel::Expression::Literal
- Defined in:
- lib/ghost_wheel/expression/literal.rb
Instance Attribute Summary collapse
-
#literal ⇒ Object
readonly
Returns the value of attribute literal.
-
#skip ⇒ Object
(also: #skip?)
readonly
Returns the value of attribute skip.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(literal, skip = false) ⇒ Literal
constructor
A new instance of Literal.
- #uncached_parse(scanner, cache) ⇒ Object
Methods inherited from GhostWheel::Expression
Constructor Details
#initialize(literal, skip = false) ⇒ Literal
Returns a new instance of Literal.
6 7 8 9 10 11 12 13 |
# File 'lib/ghost_wheel/expression/literal.rb', line 6 def initialize(literal, skip = false) @literal = case literal when Regexp then literal when Fixnum then /#{Regexp.escape(literal.chr)}/ else /#{Regexp.escape(literal.to_s)}/ end @skip = skip end |
Instance Attribute Details
#literal ⇒ Object (readonly)
Returns the value of attribute literal.
15 16 17 |
# File 'lib/ghost_wheel/expression/literal.rb', line 15 def literal @literal end |
#skip ⇒ Object (readonly) Also known as: skip?
Returns the value of attribute skip.
15 16 17 |
# File 'lib/ghost_wheel/expression/literal.rb', line 15 def skip @skip end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 |
# File 'lib/ghost_wheel/expression/literal.rb', line 26 def ==(other) super and @literal.to_s == other.literal.to_s and @skip == other.skip end |
#uncached_parse(scanner, cache) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ghost_wheel/expression/literal.rb', line 18 def uncached_parse(scanner, cache) if scanner.scan(@literal) @skip ? EmptyParseResult.instance : ParseResult.new(scanner.matched) else FailedParseResult.instance end end |