Class: Quarry::Markup::Macro
Overview
Macro
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
-
#spec ⇒ Object
(also: #parent)
readonly
def self.types @types ||= [] end.
Instance Method Summary collapse
-
#initialize(spec, code, lineno, ioc = {}) ⇒ Macro
constructor
A new instance of Macro.
-
#run(runner, spec, context, output) ⇒ Object
Run macro.
- #tab ⇒ Object
- #to_s ⇒ Object
-
#to_script ⇒ Object
As could appear in stand-alone script.
Constructor Details
#initialize(spec, code, lineno, ioc = {}) ⇒ Macro
Returns a new instance of Macro.
21 22 23 24 25 |
# File 'lib/quarry/markup/macro.rb', line 21 def initialize(spec, code, lineno, ioc={}) @spec = spec @code = code.rstrip @lineno = lineno end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
18 19 20 |
# File 'lib/quarry/markup/macro.rb', line 18 def code @code end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
19 20 21 |
# File 'lib/quarry/markup/macro.rb', line 19 def lineno @lineno end |
#spec ⇒ Object (readonly) Also known as: parent
def self.types
@types ||= []
end
17 18 19 |
# File 'lib/quarry/markup/macro.rb', line 17 def spec @spec end |
Instance Method Details
#run(runner, spec, context, output) ⇒ Object
Run macro.
30 31 32 33 |
# File 'lib/quarry/markup/macro.rb', line 30 def run(runner, spec, context, output) context.instance_eval(code, spec.file, lineno) output.report_macro(self) end |
#tab ⇒ Object
36 37 38 |
# File 'lib/quarry/markup/macro.rb', line 36 def tab @tab ||= to_s.index(/\S/) end |
#to_s ⇒ Object
41 |
# File 'lib/quarry/markup/macro.rb', line 41 def to_s ; code ; end |
#to_script ⇒ Object
As could appear in stand-alone script.
44 45 46 |
# File 'lib/quarry/markup/macro.rb', line 44 def to_script code.to_s end |