Sha256: c802b7e87050ca302a27c93c945000dd58a2ae6be75b174e210eaf63dceb7252

Contents?: true

Size: 512 Bytes

Versions: 2

Compression:

Stored size: 512 Bytes

Contents

require 'clio/layout'

module Clio

  class Layout

    # List of items.
    class List < Layout

      attr :items

      def initialize(*items)
        options = Hash===items.last ? items.pop : {}

        @items  = items
        @mark   = options[:mark]
      end

      def to_s
        s = [""]
        n = (items.size / 10).to_i + 1
        items.each_with_index do |item, index|
          s << "%#{n}s. %s" % [index+1, item]
        end
        s << ""
        s.join("\n")
      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clio-0.2.0 lib/clio/layout/list.rb
clio-0.3.0 lib/clio/layout/list.rb