Module: PrintMembers::Ext::String

Defined in:
lib/print_members/extensions.rb

Instance Method Summary collapse

Instance Method Details

#left_fixed(n, pad = ' ') ⇒ Object

Return a string of length n, containing self left-justified and either padded with pad or truncated, depending on its size relative to n.



43
44
45
46
47
48
49
# File 'lib/print_members/extensions.rb', line 43

def left_fixed n, pad=' '
  if n > size
    ljust n, pad
  else
    slice 0...n
  end
end

#to_color_stringObject

Create a ColorString from this String



52
53
54
# File 'lib/print_members/extensions.rb', line 52

def to_color_string
  ::PrintMembers::ColorString.new self
end