lib/troo/presentation/formatter.rb in troo-0.0.10 vs lib/troo/presentation/formatter.rb in troo-0.0.11

- old
+ new

@@ -24,10 +24,11 @@ attribute :underline, Boolean, default: false attribute :reset, String, default: Esc.reset attribute :align, Troo::Align, default: Troo::Align.new end + # @return [String] def underline @underline ? Esc.underline : nil end end @@ -36,41 +37,52 @@ attribute :value, String attribute :options, Troo::Format class << self + # @param [] + # @param [Hash] + # @return [] def highlight(value, options = {}) new(value: value, options: options).highlight end + # @param [] + # @return [] def error(value) new(value: value, options: { colour: Esc.red }).error end + # @param [] + # @param [Integer] + # @return [] def wordwrap(value, width = 70) new(value: value, options: { align: { width: width } }).wordwrap end end + # @return [String] def highlight [ options.colour, options.underline, formatted_value, options.reset ].join end + # @return [String] def error [ options.colour, formatted_value, options.reset ].join end + # @return [] def wordwrap Wordwrap.this(formatted_value, width: width) end private