module Tabulo::Util

@!visibility private

Constants

NEWLINE

Public Class Methods

condense_lines(lines) click to toggle source

@!visibility private

# File lib/tabulo/util.rb, line 9
def self.condense_lines(lines)
  join_lines(lines.reject(&:empty?))
end
divides?(smaller, larger) click to toggle source

@!visibility private

# File lib/tabulo/util.rb, line 14
def self.divides?(smaller, larger)
  larger % smaller == 0
end
join_lines(lines) click to toggle source

@!visibility private

# File lib/tabulo/util.rb, line 19
def self.join_lines(lines)
  lines.join($/)
end
max(x, y) click to toggle source

@!visibility private

# File lib/tabulo/util.rb, line 24
def self.max(x, y)
  x > y ? x : y
end
slice_hash(hash, *keys) click to toggle source

@!visibility private

# File lib/tabulo/util.rb, line 29
def self.slice_hash(hash, *keys)
  new_hash = {}
  keys.each { |k| new_hash[k] = hash[k] if hash.include?(k) }
  new_hash
end
wrapped_width(str) click to toggle source

@!visibility private @return [Integer] the length of the longest segment of str when split by newlines

# File lib/tabulo/util.rb, line 37
def self.wrapped_width(str)
  return 0 if str.empty?
  segments = str.split(NEWLINE)
  segments.inject(1) do |longest_length_so_far, segment|
    Util.max(longest_length_so_far, Unicode::DisplayWidth.of(segment))
  end
end