class Eggshell::Line

Encapsulates core parts of a line. Handler can use whatever parts are needed to construct final output. Line number is provided for error reporting.

Attributes

indent_lvl[R]
line[R]
line_num[R]
tab_str[R]

Public Class Methods

new(line, tab_str, indent_lvl, line_num, raw = nil) click to toggle source
# File lib/eggshell.rb, line 10
def initialize(line, tab_str, indent_lvl, line_num, raw = nil)
        @line = line
        @tab_str = tab_str || ''
        @indent_lvl = indent_lvl
        @line_num = line_num
        @raw = raw
end

Public Instance Methods

match(regex) click to toggle source
# File lib/eggshell.rb, line 32
def match(regex)
        @line.match(regex)
end
raw() click to toggle source
# File lib/eggshell.rb, line 23
def raw
        @raw ? @raw : to_s
end
replace(line, raw = nil) click to toggle source

Creates a new instance of this line, replacing the actual contents with the supplied line.

# File lib/eggshell.rb, line 28
def replace(line, raw = nil)
        Line.new(line, @tab_str, @indent_lvl, @line_num, raw)
end
to_s() click to toggle source

Returns the raw line with indents.

# File lib/eggshell.rb, line 19
def to_s
        "#{@tab_str*@indent_lvl}#{@line}"
end