class Tins::Unit::FormatParser
Public Class Methods
new(format, unit_parser)
click to toggle source
Calls superclass method
# File lib/tins/unit.rb, line 123 def initialize(format, unit_parser) super format @unit_parser = unit_parser end
Public Instance Methods
parse()
click to toggle source
# File lib/tins/unit.rb, line 139 def parse reset until eos? || @unit_parser.eos? case when scan(/%f/) @unit_parser.scan_number or raise ParserError, "\"%f\" expected at #{location}" when scan(/%U/) @unit_parser.scan_unit or raise ParserError, "\"%U\" expected at #{location}" when scan(/%%/) @unit_parser.scan_char(?%) or raise ParserError, "#{?%.inspect} expected at #{location}" else char = scan(/./) @unit_parser.scan_char(char) or raise ParserError, "#{char.inspect} expected at #{location}" end end unless eos? && @unit_parser.eos? raise ParserError, "format #{string.inspect} and string "\ "#{@unit_parser.string.inspect} do not match" end @unit_parser.number end
reset()
click to toggle source
Calls superclass method
# File lib/tins/unit.rb, line 128 def reset super @unit_parser.reset end
Private Instance Methods
location()
click to toggle source
# File lib/tins/unit.rb, line 133 def location @unit_parser.peek(10).inspect end