Class: Markdownplus::CodeBlock
- Inherits:
-
Block
- Object
- Block
- Markdownplus::CodeBlock
show all
- Defined in:
- lib/markdownplus/parser.rb
Instance Attribute Summary collapse
Attributes inherited from Block
#block_number
Instance Method Summary
collapse
Methods inherited from Block
#append, #errors, #input, #input=, #lines, #warnings
Constructor Details
#initialize(block_number, value = nil) ⇒ CodeBlock
Returns a new instance of CodeBlock.
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/markdownplus/parser.rb', line 148
def initialize(block_number, value=nil)
@block_number = block_number
@directive = value
if @directive.match(/\(/)
begin
@program ||= Markdownplus::DirectiveParser.parse(@directive)
rescue => e
errors << e.message
end
end
end
|
Instance Attribute Details
#directive ⇒ Object
Returns the value of attribute directive.
145
146
147
|
# File 'lib/markdownplus/parser.rb', line 145
def directive
@directive
end
|
#output ⇒ Object
Returns the value of attribute output.
146
147
148
|
# File 'lib/markdownplus/parser.rb', line 146
def output
@output
end
|
#program ⇒ Object
Returns the value of attribute program.
145
146
147
|
# File 'lib/markdownplus/parser.rb', line 145
def program
@program
end
|
Instance Method Details
#executable? ⇒ Boolean
165
166
167
|
# File 'lib/markdownplus/parser.rb', line 165
def executable?
(functions!=nil && functions.size>0)
end
|
#execute(variables) ⇒ Object
169
170
171
172
173
174
175
176
177
|
# File 'lib/markdownplus/parser.rb', line 169
def execute(variables)
self.output = self.input
if functions
self.functions.each do |function|
self.output = function.execute(self.output, variables, self.warnings, self.errors)
end
end
self.output
end
|
#functions ⇒ Object
161
162
163
|
# File 'lib/markdownplus/parser.rb', line 161
def functions
program.functions if program!=nil
end
|
179
180
181
182
183
184
185
186
|
# File 'lib/markdownplus/parser.rb', line 179
def input_markdown
s = input
if s.end_with?("\n")
result = "```#{directive}\n#{input}```\n"
else
result = "```#{directive}\n#{input}\n```\n"
end
end
|
#output_lines ⇒ Object
192
193
194
|
# File 'lib/markdownplus/parser.rb', line 192
def output_lines
self.output.split("\n") if self.output
end
|
#output_markdown ⇒ Object
188
189
190
|
# File 'lib/markdownplus/parser.rb', line 188
def output_markdown
self.output
end
|