Class: Rundoc::CodeCommand::Write
- Inherits:
-
Rundoc::CodeCommand
- Object
- Rundoc::CodeCommand
- Rundoc::CodeCommand::Write
- Includes:
- FileUtil
- Defined in:
- lib/rundoc/code_command/write.rb
Constant Summary
Constants inherited from Rundoc::CodeCommand
Instance Attribute Summary
Attributes inherited from Rundoc::CodeCommand
#command, #contents, #keyword, #original_args, #render_command, #render_result
Instance Method Summary collapse
- #call(env = {}) ⇒ Object
-
#initialize(filename) ⇒ Write
constructor
A new instance of Write.
- #to_md(env) ⇒ Object
Methods included from FileUtil
Methods inherited from Rundoc::CodeCommand
Constructor Details
#initialize(filename) ⇒ Write
Returns a new instance of Write.
21 22 23 |
# File 'lib/rundoc/code_command/write.rb', line 21 def initialize(filename) @filename = filename end |
Instance Method Details
#call(env = {}) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/rundoc/code_command/write.rb', line 34 def call(env = {}) puts "Writing to: '#{filename}'" mkdir_p File.write(filename, contents) contents end |
#to_md(env) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/rundoc/code_command/write.rb', line 25 def to_md(env) if render_command? raise "must call write in its own code section" unless env[:commands].empty? env[:before] << "In file `#{filename}` write:" env[:before] << NEWLINE end nil end |