Class: Quarry::Markup::Comment
Overview
Comment
Instance Attribute Summary collapse
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#spec ⇒ Object
(also: #parent)
readonly
Returns the value of attribute spec.
-
#text ⇒ Object
(also: #description)
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(spec, text, lineno) ⇒ Comment
constructor
A new instance of Comment.
-
#run(runner, spec, context, output) ⇒ Object
“run” comment.
- #to_s ⇒ Object
-
#to_script ⇒ Object
As could appear in stand-alone script.
-
#type ⇒ Object
(also: #macro?)
Matches the beginning of text to determine if this defines a macro section.
Constructor Details
#initialize(spec, text, lineno) ⇒ Comment
Returns a new instance of Comment.
13 14 15 16 17 |
# File 'lib/quarry/markup/comment.rb', line 13 def initialize(spec, text, lineno) @spec = spec @text = text.strip @lineno = lineno end |
Instance Attribute Details
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
11 12 13 |
# File 'lib/quarry/markup/comment.rb', line 11 def lineno @lineno end |
#spec ⇒ Object (readonly) Also known as: parent
Returns the value of attribute spec.
9 10 11 |
# File 'lib/quarry/markup/comment.rb', line 9 def spec @spec end |
#text ⇒ Object (readonly) Also known as: description
Returns the value of attribute text.
10 11 12 |
# File 'lib/quarry/markup/comment.rb', line 10 def text @text end |
Instance Method Details
#run(runner, spec, context, output) ⇒ Object
“run” comment.
31 32 33 |
# File 'lib/quarry/markup/comment.rb', line 31 def run(runner, spec, context, output) output.report_comment(self) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/quarry/markup/comment.rb', line 36 def to_s text.to_s end |
#to_script ⇒ Object
As could appear in stand-alone script.
41 42 43 |
# File 'lib/quarry/markup/comment.rb', line 41 def to_script text.to_s.gsub(/^/m, '# ') end |
#type ⇒ Object Also known as: macro?
Matches the beginning of text to determine if this defines a macro section.
24 25 26 27 |
# File 'lib/quarry/markup/comment.rb', line 24 def type /\A(\w{1,9})[:]\ /i =~ text $1.downcase.to_sym if $1 end |