class Warp::Dir::Formatter::StoreFormatter

Attributes

points[RW]

Public Class Methods

new(store_or_points) click to toggle source
# File lib/warp/dir/formatter.rb, line 58
def initialize(store_or_points)
  self.points = store_or_points.is_a?(::Array) ? store_or_points : store_or_points.points
end

Public Instance Methods

format(type = DEFAULT_FORMAT, sort_field = :name) click to toggle source

find the widest warp point name, and indent them all based on that. make it easy to extend to other types, and allow the caller to sort by one of the fields.

# File lib/warp/dir/formatter.rb, line 65
def format(type = DEFAULT_FORMAT, sort_field = :name)
  longest_key_length = points.map(&:name).map(&:length).sort.last
  Warp::Dir.sort_by(points, sort_field).map do |point|
    PointFormatter.new(point).format(type, longest_key_length)
  end.join("\n")
end