Class: SM::Line
- Inherits:
-
Object
- Object
- SM::Line
- Defined in:
- lib/rdoc/markup/simple_markup/lines.rb
Constant Summary collapse
- INFINITY =
9999
- BLANK =
:BLANK
- HEADING =
:HEADING
- LIST =
:LIST
- RULE =
:RULE
- PARAGRAPH =
:PARAGRAPH
- VERBATIM =
:VERBATIM
Instance Attribute Summary collapse
-
#deleted ⇒ Object
true if this line has been deleted from the list of lines.
-
#flag ⇒ Object
A flag.
-
#leading_spaces ⇒ Object
the number of leading spaces.
-
#level ⇒ Object
The indentation nesting level.
-
#param ⇒ Object
A prefix or parameter.
-
#text ⇒ Object
The contents.
-
#type ⇒ Object
line type.
Instance Method Summary collapse
-
#initialize(text) ⇒ Line
constructor
A new instance of Line.
-
#isBlank? ⇒ Boolean
Return true if this line is blank.
-
#stamp(type, level, param = "", flag = nil) ⇒ Object
stamp a line with a type, a level, a prefix, and a flag.
-
#strip_leading(size) ⇒ Object
Strip off the leading margin.
- #to_s ⇒ Object
Constructor Details
#initialize(text) ⇒ Line
Returns a new instance of Line.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 42 def initialize(text) @text = text.dup @deleted = false # expand tabs 1 while @text.gsub!(/\t+/) { ' ' * (8*$&.length - $`.length % 8)} && $~ #` # Strip trailing whitespace @text.sub!(/\s+$/, '') # and look for leading whitespace if @text.length > 0 @text =~ /^(\s*)/ @leading_spaces = $1.length else @leading_spaces = INFINITY end end |
Instance Attribute Details
#deleted ⇒ Object
true if this line has been deleted from the list of lines
39 40 41 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 39 def deleted @deleted end |
#flag ⇒ Object
A flag. For list lines, this is the type of the list
33 34 35 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 33 def flag @flag end |
#leading_spaces ⇒ Object
the number of leading spaces
36 37 38 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 36 def leading_spaces @leading_spaces end |
#level ⇒ Object
The indentation nesting level
23 24 25 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 23 def level @level end |
#param ⇒ Object
A prefix or parameter. For LIST lines, this is the text that introduced the list item (the label)
30 31 32 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 30 def param @param end |
#text ⇒ Object
The contents
26 27 28 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 26 def text @text end |
#type ⇒ Object
line type
20 21 22 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 20 def type @type end |
Instance Method Details
#isBlank? ⇒ Boolean
Return true if this line is blank
62 63 64 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 62 def isBlank? @text.length.zero? end |
#stamp(type, level, param = "", flag = nil) ⇒ Object
stamp a line with a type, a level, a prefix, and a flag
67 68 69 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 67 def stamp(type, level, param="", flag=nil) @type, @level, @param, @flag = type, level, param, flag end |
#strip_leading(size) ⇒ Object
Strip off the leading margin
75 76 77 78 79 80 81 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 75 def strip_leading(size) if @text.size > size @text[0,size] = "" else @text = "" end end |
#to_s ⇒ Object
83 84 85 |
# File 'lib/rdoc/markup/simple_markup/lines.rb', line 83 def to_s "#@type#@level: #@text" end |