Class: MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual

### Home Classes Methods

### In Files

- lib/maruku/input/charsource.rb

### Parent

Object

### Methods

- ::new
- #consume_whitespace
- #cur_char
- #cur_chars
- #cur_chars_are
- #current_remaining_buffer
- #describe
- #ignore_char
- #ignore_chars
- #next_char
- #next_matches
- #read_regexp
- #read_regexp3
- #read_text_chars
- #shift_char

### Included Modules

- MaRuKu::Strings
- MaRuKu::In::Markdown::SpanLevelParser

### Class/Module Index

Quicksearch

- MaRuKu
- MaRuKu::Errors
- MaRuKu::Exception
- MaRuKu::Helpers
- MaRuKu::In
- MaRuKu::In::Markdown
- MaRuKu::In::Markdown::BlockLevelParser
- MaRuKu::In::Markdown::BlockLevelParser::BlockContext
- MaRuKu::In::Markdown::BlockLevelParser::LineSource
- MaRuKu::In::Markdown::SpanExtension
- MaRuKu::In::Markdown::SpanLevelParser
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- MaRuKu::In::Markdown::SpanLevelParser::HTMLHelper
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- MaRuKu::MDDocument
- MaRuKu::MDElement
- MaRuKu::Out
- MaRuKu::Out::HTML
- MaRuKu::Out::Latex
- MaRuKu::Out::Latex::LatexEntity
- MaRuKu::Out::Markdown
- MaRuKu::Section
- MaRuKu::Strings
- MaRuKu::Tests
- Array
- Hash
- Maruku
- Module
- NilClass
- Object
- String
- Textile2Signature

No matching classes.

# MaRuKu::In::Markdown::SpanLevelParser::CharSourceManual

a string scanner coded by me

CharSource = CharSourceStrscan CharSource = CharSourceDebug

### Public Class Methods

new(s, parent=nil) click to toggle source

    # File lib/maruku/input/charsource.rb, line 44
    def initialize(s, parent=nil)
            raise "Passed #{s.class}" if not s.kind_of? String
            @buffer = s
            @buffer_index = 0
            @parent = parent
    end

### Public Instance Methods

consume_whitespace() click to toggle source

    # File lib/maruku/input/charsource.rb, line 123
            def consume_whitespace
                    while c = cur_char
                      if (c == \s\ || c == \t\)
    #                               puts "ignoring #{c}"
                                    ignore_char
                            else
    #                               puts "#{c} is not ws: "<<c
                                    break
                            end
                    end
            end

cur_char() click to toggle source

Return current char as a FixNum (or nil).

    # File lib/maruku/input/charsource.rb, line 52
    def cur_char; @buffer[@buffer_index]   end

cur_chars(n) click to toggle source

Return the next n chars as a String.

    # File lib/maruku/input/charsource.rb, line 55
    def cur_chars(n); @buffer[@buffer_index,n]  end

cur_chars_are(string) click to toggle source

    # File lib/maruku/input/charsource.rb, line 80
    def cur_chars_are(string)
            # There is a bug here
            if false
                    r2 = /^.{#{@buffer_index}}#{Regexp.escape string}/
                    @buffer =~ r2
            else
                    cur_chars(string.size) == string
            end
    end

current_remaining_buffer() click to toggle source

    # File lib/maruku/input/charsource.rb, line 76
    def current_remaining_buffer
            @buffer[@buffer_index, @buffer.size-@buffer_index]
    end

describe() click to toggle source

    # File lib/maruku/input/charsource.rb, line 144
    def describe
            s = describe_pos(@buffer, @buffer_index)
            if @parent
                    s += "\n\n" + @parent.describe
            end
            s
    end

ignore_char() click to toggle source

    # File lib/maruku/input/charsource.rb, line 66
    def ignore_char
            @buffer_index+=1
            nil
    end

ignore_chars(n) click to toggle source

    # File lib/maruku/input/charsource.rb, line 71
    def ignore_chars(n)
            @buffer_index+=n
            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 58
    def next_char; @buffer[@buffer_index+1] end

next_matches(r) click to toggle source

    # File lib/maruku/input/charsource.rb, line 90
    def next_matches(r)
            r2 = /^.{#{@buffer_index}}#{r}/
            md = r2.match @buffer
            return !!md
    end

read_regexp(r) click to toggle source

    # File lib/maruku/input/charsource.rb, line 112
                    def read_regexp(r)
                            r2 = /^#{r}/
                            rest = current_remaining_buffer
                            m = r2.match(rest)
                            if m
                                    @buffer_index += m.to_s.size
    #                               puts "#{r} matched #{rest.inspect}: #{m.to_s.inspect}"
                            end
                            return m
                    end

read_regexp3(r) click to toggle source

    # File lib/maruku/input/charsource.rb, line 96
            def read_regexp3(r)
                    r2 = /^.{#{@buffer_index}}#{r}/
                    m = r2.match @buffer
                    if m
                            consumed = m.to_s.size - @buffer_index
    #                       puts "Consumed #{consumed} chars (entire is #{m.to_s.inspect})"
                            ignore_chars consumed
                    else
    #                       puts "Could not read regexp #{r2.inspect} from buffer "+
    #                       " index=#{@buffer_index}"
    #                       puts "Cur chars = #{cur_chars(20).inspect}"
    #                       puts "Matches? = #{cur_chars(20) =~ r}"
                    end
                    m
            end

read_text_chars(out) click to toggle source

    # File lib/maruku/input/charsource.rb, line 135
    def read_text_chars(out)
            s = @buffer.size; c=nil
            while @buffer_index < s && (c=@buffer[@buffer_index]) &&
                     ((c>=aa && c<=zz) || (c>=AA && c<=ZZ))
                            out << c
                            @buffer_index += 1
            end
    end

shift_char() click to toggle source

    # File lib/maruku/input/charsource.rb, line 60
    def shift_char
            c = @buffer[@buffer_index]
            @buffer_index+=1
            c
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.