class Clio::Layout::Split

TODO: name LeftRight instead?

Constants

FILL
PAD
RATIO

Attributes

fill[RW]
left[RW]
pad[RW]
ratio[RW]
right[RW]

Public Class Methods

new(left, right, options={}) click to toggle source
# File lib/clio/layout/split.rb, line 26
def initialize(left, right, options={})
  @left    = left
  @right   = right

  @fill    = FILL
  @ratio   = RATIO
  @pad     = PAD

  options.each do |k,v|
    send("#{k}=",v) if respond_to?("#{k}=")
  end
end

Public Instance Methods

fill=(letter) click to toggle source
# File lib/clio/layout/split.rb, line 51
def fill=(letter)
  case letter
  when '', nil
    letter = ' '
  else
    letter = letter[0,1]
  end
  @fill = letter
end
print() click to toggle source
ratio=(value) click to toggle source
# File lib/clio/layout/split.rb, line 43
def ratio=(value)
  if value < 0
    @ratio = 1 + value
  else
    @ratio = value
  end
end
to_s() click to toggle source
# File lib/clio/layout/split.rb, line 61
def to_s
  print_justified(left, right)
end

Private Instance Methods

print_justified(left, rite) click to toggle source

Print a justified line with left and right entries.

A fill option can be given to fill in any empty space between the two. And a ratio option can be given which defaults to 0.8 (eg. 80/20)

screen_width() click to toggle source
# File lib/clio/layout/split.rb, line 99
def screen_width
  @screen_width ||= Terminal.screen_width
end