Class: Eskimo::ASCII::Indent

Inherits:
Component show all
Defined in:
lib/eskimo/ascii/components/indent.rb

Overview

Indent text from the left.

Indent.new(width: 8) do
  [ "Hello", SoftBreak.new, "World!" ]
end
# => "        Hello"
#    "        World!"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width: 4, &children) ⇒ Indent

Returns a new instance of Indent.



14
15
16
17
# File 'lib/eskimo/ascii/components/indent.rb', line 14

def initialize(width: 4, &children)
  @width = width
  super
end

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width.



12
13
14
# File 'lib/eskimo/ascii/components/indent.rb', line 12

def width
  @width
end

Instance Method Details

#renderObject



19
20
21
# File 'lib/eskimo/ascii/components/indent.rb', line 19

def render(**)
  Strings.pad(super, [0,0,0,width])
end