Class SM::Line
In: markup/simple_markup/lines.rb
Parent: Object

Methods

isBlank?   new   stamp   strip_leading   to_s  

Constants

INFINITY = 9999
BLANK = :BLANK
HEADING = :HEADING
LIST = :LIST
RULE = :RULE
PARAGRAPH = :PARAGRAPH
VERBATIM = :VERBATIM

Attributes

deleted  [RW]  true if this line has been deleted from the list of lines
flag  [RW]  A flag. For list lines, this is the type of the list
leading_spaces  [RW]  the number of leading spaces
level  [RW]  The indentation nesting level
param  [RW]  A prefix or parameter. For LIST lines, this is the text that introduced the list item (the label)
text  [RW]  The contents
type  [RW]  line type

Public Class methods

[Source]

    # File markup/simple_markup/lines.rb, line 42
42:     def initialize(text)
43:       @text    = text.dup
44:       @deleted = false
45: 
46:       # expand tabs
47:       1 while @text.gsub!(/\t+/) { ' ' * (8*$&.length - $`.length % 8)}  && $~ #`
48: 
49:       # Strip trailing whitespace
50:       @text.sub!(/\s+$/, '')
51: 
52:       # and look for leading whitespace
53:       if @text.length > 0
54:         @text =~ /^(\s*)/
55:         @leading_spaces = $1.length
56:       else
57:         @leading_spaces = INFINITY
58:       end
59:     end

Public Instance methods

Return true if this line is blank

[Source]

    # File markup/simple_markup/lines.rb, line 62
62:     def isBlank?
63:       @text.length.zero?
64:     end

stamp a line with a type, a level, a prefix, and a flag

[Source]

    # File markup/simple_markup/lines.rb, line 67
67:     def stamp(type, level, param="", flag=nil)
68:       @type, @level, @param, @flag = type, level, param, flag
69:     end

Strip off the leading margin

[Source]

    # File markup/simple_markup/lines.rb, line 75
75:     def strip_leading(size)
76:       if @text.size > size
77:         @text[0,size] = ""
78:       else
79:         @text = ""
80:       end
81:     end

[Source]

    # File markup/simple_markup/lines.rb, line 83
83:     def to_s
84:       "#@type#@level: #@text"
85:     end

[Validate]