Class: Kosi::Align

Inherits:
Object
  • Object
show all
Defined in:
lib/kosi/align.rb

Overview

Align

Defined Under Namespace

Modules: TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Align

Returns a new instance of Align.



17
18
19
# File 'lib/kosi/align.rb', line 17

def initialize(options)
  @value = options[OptionKeys::ALIGN] || TYPE::DEFAULT
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



8
9
10
# File 'lib/kosi/align.rb', line 8

def value
  @value
end

Instance Method Details

#apply(text, max_value, diff) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kosi/align.rb', line 21

def apply(text, max_value, diff)
  pos = max_value - diff
  case @value
  when TYPE::CENTER
    text.center(pos)
  when TYPE::RIGHT
    text.rjust(pos)
  when TYPE::LEFT
    text.ljust(pos)
  end
end