Class: Eskimo::Components::Indent

Inherits:
Eskimo::Component show all
Defined in:
lib/eskimo/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



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

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

Instance Attribute Details

#widthObject (readonly)

Returns the value of attribute width



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

def width
  @width
end

Instance Method Details

#renderObject



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

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