Class: MaRuKu::In::Markdown::BlockLevelParser::LineSource

### Home Classes Methods

### In Files

- lib/maruku/input/linesource.rb

### Parent

Object

### Methods

- ::new
- #cur_index
- #cur_line
- #describe
- #ignore_line
- #next_line
- #original_line_number
- #shift_line
- #tell_me_the_future

### Class/Module Index

Quicksearch

- MaRuKu
- MaRuKu::AttributeList
- MaRuKu::Errors
- MaRuKu::Exception
- MaRuKu::HTMLElement
- MaRuKu::HTMLFragment
- 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::MDHTMLElement
- MaRuKu::MDLine
- MaRuKu::NokogiriHTMLFragment
- MaRuKu::Out
- MaRuKu::Out::EntityTable
- MaRuKu::Out::HTML
- MaRuKu::Out::HTML::HTMLElement
- MaRuKu::Out::Latex
- MaRuKu::Out::Latex::MDDocumentExtensions
- MaRuKu::Out::Markdown
- MaRuKu::REXMLHTMLFragment
- MaRuKu::Section
- MaRuKu::Strings
- Maruku
- Maruku::In
- Maruku::In::Markdown
- Maruku::In::Markdown::FencedCode
- Object
- String
- Textile2Signature

No matching classes.

# MaRuKu::In::Markdown::BlockLevelParser::LineSource

This represents a source of lines that can be consumed.

It is the twin of CharSource.

### Attributes

parent[R]

### Public Class Methods

new(lines, parent=nil, parent_offset=nil) click to toggle source

    # File lib/maruku/input/linesource.rb, line 11
    def initialize(lines, parent=nil, parent_offset=nil)
      raise "NIL lines? " unless lines
      @lines = lines.map {|l| l.kind_of?(MaRuKu::MDLine) ? l : MaRuKu::MDLine.new(l) }
      @lines_index = 0
      @parent = parent
      @parent_offset = parent_offset
    end

### Public Instance Methods

cur_index() click to toggle source

    # File lib/maruku/input/linesource.rb, line 66
    def cur_index
      @lines_index
    end

cur_line() click to toggle source

    # File lib/maruku/input/linesource.rb, line 19
    def cur_line
      @lines[@lines_index]
    end

describe() click to toggle source

    # File lib/maruku/input/linesource.rb, line 39
    def describe
      s = "At line #{original_line_number(@lines_index)}\n"

      context = 3 # lines
      from = [@lines_index - context, 0].max
      to   = [@lines_index + context, @lines.size - 1].min

      from.upto(to) do |i|
        prefix = (i == @lines_index) ? '--> ' : '    ';
        l = @lines[i]
        s += "%10s %4s|%s" %
          [@lines[i].md_type.to_s, prefix, l]

        s += "|\n"
      end

      s
    end

ignore_line() click to toggle source

    # File lib/maruku/input/linesource.rb, line 34
    def ignore_line
      raise "Over the rainbow" if @lines_index >= @lines.size
      @lines_index += 1
    end

next_line() click to toggle source

    # File lib/maruku/input/linesource.rb, line 23
    def next_line
      @lines[@lines_index + 1]
    end

original_line_number(index) click to toggle source

    # File lib/maruku/input/linesource.rb, line 58
    def original_line_number(index)
      if @parent
        index + @parent.original_line_number(@parent_offset)
      else
        1 + index
      end
    end

shift_line() click to toggle source

    # File lib/maruku/input/linesource.rb, line 27
    def shift_line
      raise "Over the rainbow" if @lines_index >= @lines.size
      l = @lines[@lines_index]
      @lines_index += 1
      l
    end

tell_me_the_future() click to toggle source

Returns the type of next line as a string breaks at first :definition

    # File lib/maruku/input/linesource.rb, line 72
    def tell_me_the_future
      s = ""
      num_e = 0

      @lines_index.upto(@lines.size - 1) do |i|
        c = case @lines[i].md_type
            when :text; "t"
            when :empty; num_e += 1; "e"
            when :definition; "d"
            else "o"
            end
        s << c
        break if c == "d" or num_e > 1
      end
      s
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.