Class: QED::Parser::TextSection
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#cont ⇒ Object
readonly
Returns the value of attribute cont.
Attributes inherited from Section
Instance Method Summary collapse
- #<<(text) ⇒ Object
-
#block_continuation(text) ⇒ Object
Block the text, removing white lines, triple quote brackets and indention.
-
#clean_continuation(text) ⇒ Object
Clean up the text, removing unccesseary white lines and triple quote brackets, but keep indention intact.
-
#initialize(text, line, *args) ⇒ TextSection
constructor
A new instance of TextSection.
-
#raw? ⇒ Boolean
TODO: Use ‘:’ or ‘…’ ?.
- #type ⇒ Object
Constructor Details
#initialize(text, line, *args) ⇒ TextSection
Returns a new instance of TextSection.
90 91 92 93 94 95 |
# File 'lib/qed/parser.rb', line 90 def initialize(text, line, *args) @text = text @line = line @args = args @cont = [] end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
88 89 90 |
# File 'lib/qed/parser.rb', line 88 def args @args end |
#cont ⇒ Object (readonly)
Returns the value of attribute cont.
89 90 91 |
# File 'lib/qed/parser.rb', line 89 def cont @cont end |
Instance Method Details
#<<(text) ⇒ Object
96 97 98 99 |
# File 'lib/qed/parser.rb', line 96 def <<(text) @cont << clean_continuation(text) @args << block_continuation(text) end |
#block_continuation(text) ⇒ Object
Block the text, removing white lines, triple quote brackets and indention.
121 122 123 124 125 126 127 |
# File 'lib/qed/parser.rb', line 121 def block_continuation(text) text = text.tabto(0).chomp.sub(/\A\n/,'') if md = /\A["]{3,}(.*?)["]{3,}\Z/.match(text) text = md[1] end text.rstrip end |
#clean_continuation(text) ⇒ Object
Clean up the text, removing unccesseary white lines and triple quote brackets, but keep indention intact.
111 112 113 114 115 116 117 |
# File 'lib/qed/parser.rb', line 111 def clean_continuation(text) text = text.chomp.sub(/\A\n/,'') if md = /\A["]{3,}(.*?)["]{3,}\Z/.match(text) text = md[1] end text.rstrip end |
#raw? ⇒ Boolean
TODO: Use ‘:’ or ‘…’ ?
104 105 106 107 |
# File 'lib/qed/parser.rb', line 104 def raw? #/\:\s*\Z/m =~ text /\.\.\.\s*\Z/m =~ text end |
#type ⇒ Object
100 101 102 |
# File 'lib/qed/parser.rb', line 100 def type :text end |