class Troo::Formatter
Public Class Methods
error(value)
click to toggle source
@param [] @return []
# File lib/troo/presentation/formatter.rb, line 51 def error(value) new(value: value, options: { colour: Esc.red }).error end
highlight(value, options = {})
click to toggle source
@param [] @param [Hash] @return []
# File lib/troo/presentation/formatter.rb, line 45 def highlight(value, options = {}) new(value: value, options: options).highlight end
wordwrap(value, width = 70)
click to toggle source
@param [] @param [Integer] @return []
# File lib/troo/presentation/formatter.rb, line 59 def wordwrap(value, width = 70) new(value: value, options: { align: { width: width } }).wordwrap end
Public Instance Methods
error()
click to toggle source
@return [String]
# File lib/troo/presentation/formatter.rb, line 76 def error [ options.colour, formatted_value, options.reset ].join end
highlight()
click to toggle source
@return [String]
# File lib/troo/presentation/formatter.rb, line 66 def highlight [ options.colour, options.underline, formatted_value, options.reset ].join end
wordwrap()
click to toggle source
@return []
# File lib/troo/presentation/formatter.rb, line 85 def wordwrap Wordwrap.this(formatted_value, width: width) end
Private Instance Methods
alignment()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 95 def alignment { none: value, left: value.ljust(padding, spacer), right: value.rjust(padding, spacer) } end
formatted_value()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 91 def formatted_value alignment.fetch(position, :none) end
padding()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 111 def padding options.align.pad end
position()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 107 def position options.align.pos end
spacer()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 115 def spacer options.align.char end
width()
click to toggle source
# File lib/troo/presentation/formatter.rb, line 103 def width options.align.width end