Sha256: 0b5af74c8a5fccacbc91f6f4f1b4735f47b36b9831e22d41daf118510b8f4c39

Contents?: true

Size: 592 Bytes

Versions: 12

Compression:

Stored size: 592 Bytes

Contents

require 'highline'

module CollinsShell

  module PrinterUtil

    def format_datetime value
      if !value.is_a?(DateTime) then
        val = DateTime.parse(value)
      else
        val = value
      end
      val.strftime('%Y-%m-%d %H:%M:%S')
    end

    def wrap_text(txt, col = 80)
      txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n") 
    end

    def dynamic_terminal_width
      highline_width = HighLine::SystemExtensions.terminal_size[1].to_i
      thor_width = Thor::Shell::Basic.new.terminal_width.to_i
      [highline_width,thor_width,80].max
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
collins_shell-0.2.26 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.24 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.23 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.22 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.21 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.20 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.19 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.18 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.17 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.16 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.15 lib/collins_shell/util/printer_util.rb
collins_shell-0.2.14 lib/collins_shell/util/printer_util.rb