Class: FormatEngine::FormatLiteral

Inherits:
Object
  • Object
show all
Defined in:
lib/format_engine/format_spec/literal.rb

Overview

A format engine literal specification.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(literal) ⇒ FormatLiteral

Set up a literal format specification.



10
11
12
# File 'lib/format_engine/format_spec/literal.rb', line 10

def initialize(literal)
  @literal = literal
end

Instance Attribute Details

#literalObject (readonly)

The literal text of this literal specification.



7
8
9
# File 'lib/format_engine/format_spec/literal.rb', line 7

def literal
  @literal
end

Instance Method Details

#do_format(spec_info) ⇒ Object

Format onto the output string



20
21
22
# File 'lib/format_engine/format_spec/literal.rb', line 20

def do_format(spec_info)
  spec_info.dst << @literal
end

#do_parse(spec_info) ⇒ Object

Parse from the input string



25
26
27
# File 'lib/format_engine/format_spec/literal.rb', line 25

def do_parse(spec_info)
  spec_info.parse!(literal)
end

#inspectObject

Inspect for debugging.



30
31
32
# File 'lib/format_engine/format_spec/literal.rb', line 30

def inspect
  "Literal(#{literal.inspect})"
end

#validate(_engine) ⇒ Object

Is this literal supported by the engine? YES!



15
16
17
# File 'lib/format_engine/format_spec/literal.rb', line 15

def validate(_engine)
  self
end