Class: Eskimo::ASCII::Indent

Inherits:
Component show all
Defined in:
gems/eskimo-ascii/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 'gems/eskimo-ascii/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 'gems/eskimo-ascii/lib/eskimo/ascii/components/indent.rb', line 12

def width
  @width
end

Instance Method Details

#renderObject



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

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