CodeWriter
Inherits Reference < Object
TODO: Write documentation for CodeWriter
Constants
Constructors
Class methods
Instance methods
Add a blank line to the internal buffer, only if the last character written was not a newline.
Create a block using the current language's block syntax. Sets the correct opening and closing characters, and indents the block contents.
writer.puts("def foo").block do
writer.puts("# do something")
end
This will output:
def foo
# do something
end
Create a single comment using the current language's comment syntax.
writer.comment("This is a comment")
This will output:
# This is a comment
Create a multiline comment using the current language's comment syntax.
writer.comment do
writer.print("This is a comment")
writer.print("This is another comment")
end
This will output:
# This is a comment
# This is another comment
Subtract from the indentation level for the given block, then reset it once the block exits.
Set the indentation level for the given block, then reset it once the block exits.
Create an inline block using the current language's block syntax. Sets the correct opening and closing characters, and keeps the block contents on the same line.
writer.print("foo.bar").inline_block do
writer.print("|x| x + 1")
end
This will output:
foo.bar { |x| x + 1 }
Add a newline to the internal buffer, only if the last character written was not a newline.
Write text to the internal buffer. Respects the current indentation level, and will indent the line if the
last_newline flag is set.
Write text to the internal buffer, using additional args as format arguments.
Respects the current indentation level, and will indent the line if the
last_newline flag is set.
Write text with a trailing newline, assuming the text doesn't already end with a newline.
Write text with a trailing newline, assuming the text doesn't already end with a newline. Uses additional args as format arguments.