Class RDoc::Markup::Line
In: markup/lines.rb
Parent: Object

We store the lines we‘re working on as objects of class Line. These contain the text of the line, along with a flag indicating the line type, and an indentation level.

Methods

blank?   new   stamp   strip_leading   to_s  

Public Class methods

[Source]

    # File 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/lines.rb, line 62
62:     def blank?
63:       @text.empty?
64:     end

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

[Source]

    # File 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/lines.rb, line 74
74:     def strip_leading(size)
75:       if @text.size > size
76:         @text[0,size] = ""
77:       else
78:         @text = ""
79:       end
80:     end

[Source]

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

[Validate]