class MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan

a wrapper around StringScanner

Public Class Methods

new(s, parent=nil) click to toggle source
# File lib/maruku/input/charsource.rb, line 208
def initialize(s, parent=nil)
        @s = StringScanner.new(s)
        @parent = parent
end

Public Instance Methods

consume_whitespace() click to toggle source
# File lib/maruku/input/charsource.rb, line 264
def consume_whitespace
        @s.scan(%r\s+/)
        nil
end
cur_char() click to toggle source

Return current char as a FixNum (or nil).

# File lib/maruku/input/charsource.rb, line 214
def cur_char
         @s.peek(1)[0]
end
cur_chars(n) click to toggle source

Return the next n chars as a String.

# File lib/maruku/input/charsource.rb, line 219
def cur_chars(n); 
        @s.peek(n)
end
cur_chars_are(string) click to toggle source
# File lib/maruku/input/charsource.rb, line 246
def cur_chars_are(string)
        cur_chars(string.size) == string
end
current_remaining_buffer() click to toggle source
# File lib/maruku/input/charsource.rb, line 242
def current_remaining_buffer
        @s.rest #nil #@buffer[@buffer_index, @buffer.size-@buffer_index]
end
describe() click to toggle source
# File lib/maruku/input/charsource.rb, line 269
def describe
        describe_pos(@s.string, @s.pos)
end
ignore_char() click to toggle source
# File lib/maruku/input/charsource.rb, line 232
def ignore_char
        @s.get_byte
        nil
end
ignore_chars(n) click to toggle source
# File lib/maruku/input/charsource.rb, line 237
def ignore_chars(n)
        n.times do @s.get_byte end
        nil
end
next_char() click to toggle source

Return the char after current char as a FixNum (or nil).

# File lib/maruku/input/charsource.rb, line 224
def next_char; 
        @s.peek(2)[1]
end
next_matches(r) click to toggle source
# File lib/maruku/input/charsource.rb, line 250
def next_matches(r)
        len = @s.match?(r)
        return !!len
end
read_regexp(r) click to toggle source
# File lib/maruku/input/charsource.rb, line 255
def read_regexp(r)
        string = @s.scan(r)
        if string
                return r.match(string)
        else
                return nil
        end
end
shift_char() click to toggle source
# File lib/maruku/input/charsource.rb, line 228
def shift_char
        (@s.get_byte)[0]
end