mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix indent and add empty line method
This commit is contained in:
parent
f73a51ae0c
commit
8cdc5f0b3f
1 changed files with 10 additions and 5 deletions
|
@ -20,7 +20,7 @@ module Spectator::Formatting
|
||||||
# The *io* is the stream to output to.
|
# The *io* is the stream to output to.
|
||||||
# The *indent_size* is how much (number of spaces) to indent at each level.
|
# The *indent_size* is how much (number of spaces) to indent at each level.
|
||||||
# The *initial_indent* is what the ident should be set to.
|
# The *initial_indent* is what the ident should be set to.
|
||||||
def initialize(@io : IO, @indent_size = INDENT_SIZE, @inital_indent = 0)
|
def initialize(@io : IO, @indent_size = INDENT_SIZE, inital_indent @indent = 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indents the text and yields.
|
# Indents the text and yields.
|
||||||
|
@ -30,15 +30,20 @@ module Spectator::Formatting
|
||||||
|
|
||||||
# Indents the text by a specified amount and yields.
|
# Indents the text by a specified amount and yields.
|
||||||
def increase(amount) : Nil
|
def increase(amount) : Nil
|
||||||
@indent_size += amount
|
@indent += amount
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
@indent_size -= amount
|
@indent -= amount
|
||||||
|
end
|
||||||
|
|
||||||
|
# Produces an empty line.
|
||||||
|
def line
|
||||||
|
@io.puts
|
||||||
end
|
end
|
||||||
|
|
||||||
# Produces a line of indented text.
|
# Produces a line of indented text.
|
||||||
def line(text)
|
def line(text)
|
||||||
@indent_size.times { io << ' ' }
|
@indent.times { @io << ' ' }
|
||||||
@io.puts text
|
@io.puts text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue