Class: Quarry::Markup::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/quarry/markup/comment.rb

Overview

Comment

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#linenoObject (readonly)

Returns the value of attribute lineno.



11
12
13
# File 'lib/quarry/markup/comment.rb', line 11

def lineno
  @lineno
end

#specObject (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

#textObject (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_sObject



36
37
38
# File 'lib/quarry/markup/comment.rb', line 36

def to_s
  text.to_s
end

#to_scriptObject

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

#typeObject 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