Sha256: 86d39a6997170e9cc7608e87067ca647f69f6c6f3b678af4c2d7f8b10fca60fe

Contents?: true

Size: 565 Bytes

Versions: 2

Compression:

Stored size: 565 Bytes

Contents

module Wod
  module Helpers
    def home_directory
      ENV['HOME']
    end
        
    def error(msg)
      STDERR.puts(msg)
      exit 1
    end
    
    def ask
      gets.strip
    end
    
    def display_formatted hashes, columns
      column_lengths = columns.map do |c|
        hashes.map { |h| h[c].length }.max
      end
      sorted = hashes.sort_by {|h| h[columns.first] }
      
      sorted.each.with_index do |h, i|
        puts " " + columns.map.with_index{ |c, i| h[c].ljust(column_lengths[i]) }.join(" | ")
      end
    end
    
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wod-0.0.2 lib/wod/helpers.rb
wod-0.0.1 lib/wod/helpers.rb