io_indent.cr
IO::Indent
Wrap an IO with automatic indentation. When a character is written at the start of a line, indentation will be added. But only when a character is written, not after every EOL
character.
Installation
Add it to your shard.yml
:
dependencies:
io_indent:
github: plambert/io_indent.cr
Usage
Wrap an IO
with a new IO::Indent
, then write to it as normal. Any attempt to read will raise an exception.
io = IO::Indent.new(STDOUT)
io.puts "this is not indented"
io.indent do
io.puts "this is indented by two spaces"
io.indent
io.puts "one more level of indentation"
io.outdent
end
io.puts "back to the left"
This will produce:
this is not indented
this is indented by two spaces
one more level of indentation
back to the left
Contributing
- Fork it (https://github.com/plambert/io_indent.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Paul M. Lambert - creator and maintainer
Repository
io_indent.cr
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- 16 days ago
- October 22, 2024
License
Apache License 2.0
Links
Synced at
Thu, 07 Nov 2024 06:41:49 GMT
Languages