132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/tins/unit.rb', line 132
def parse
reset
until eos? || @unit_parser.eos?
case
when scan(/%f/)
@unit_parser.scan_number or
raise ArgumentError, "\"%f\" expected at #{location}"
when scan(/%U/)
@unit_parser.scan_unit or
raise ArgumentError, "\"%U\" expected at #{location}"
when scan(/%%/)
@unit_parser.scan_char(?%) or
raise ArgumentError, "#{?%.inspect} expected at #{location}"
else
char = scan(/./)
@unit_parser.scan_char(char) or
raise ArgumentError, "#{char.inspect} expected at #{location}"
end
end
unless eos? && @unit_parser.eos?
raise ArgumentError,
"format #{string.inspect} and string "\
"#{@unit_parser.string.inspect} do not match"
end
@unit_parser.number
end
|