Sha256: d83013cd522cead8dee35660c145deaa6432da285f34812606e54d3d22736251
Contents?: true
Size: 928 Bytes
Versions: 4
Compression:
Stored size: 928 Bytes
Contents
class StringParser attr_reader :line, :eos, :i, :len def initialize(line) raise NilValue if line.nil? raise ExpectedString unless String === line @line = line @len = @line.length @eos = @len == 0 ? true : false @i = 0 end def grab return nil if @eos char = @line[@i] @i += 1 @eos = true if @i > @len char end def ungrab @i -= 1 # FIXME what about eos...? end def next! @line[@i + 1] end def prev return nil if @i <= 0 @line[@i-1] end def last? @i > @len - 1 end def eos? @eos = true if last? # duh? @eos end def peek return nil if @eos @line[@i] end def skip_spaces char = nil loop do char = peek break if eos? break if char != " " grab end char end end =begin skip next! skip! peek!(?) expect_alpha expect_number skip_spaces expect_eos =end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
livetext-0.9.20 | lib/parser/string.rb |
livetext-0.9.19 | lib/parser/string.rb |
livetext-0.9.17 | lib/parser/string.rb |
livetext-0.9.15 | lib/parser/string.rb |