class FormatEngine::FormatLiteral
A format engine literal specification.
Attributes
literal[R]
The literal text of this literal specification.
Public Class Methods
new(literal)
click to toggle source
Set up a literal format specification.
# File lib/format_engine/format_spec/literal.rb, line 10 def initialize(literal) @literal = literal.gsub(/\\./) {|seq| seq[-1]} @head = @literal.rstrip @has_tail = @head != @literal end
Public Instance Methods
do_format(spec_info)
click to toggle source
Format onto the output string
# File lib/format_engine/format_spec/literal.rb, line 27 def do_format(spec_info) spec_info.dst << @literal end
do_parse(spec_info)
click to toggle source
Parse from the input string
# File lib/format_engine/format_spec/literal.rb, line 32 def do_parse(spec_info) spec_info.parse!(@head) unless @head.empty? spec_info.parse(/\s*/) if @has_tail end
inspect()
click to toggle source
Inspect for debugging.
# File lib/format_engine/format_spec/literal.rb, line 38 def inspect "Literal(#{literal.inspect})" end
validate(_engine)
click to toggle source
Is this format item supported by the engine's library?
# File lib/format_engine/format_spec/literal.rb, line 22 def validate(_engine) true end
width()
click to toggle source
The width parameter. Handled literally so this is always zero.
# File lib/format_engine/format_spec/literal.rb, line 17 def width 0 end