Class: Clio::Layout::List

Inherits:
Clio::Layout show all
Defined in:
lib/clio/layout/list.rb

Overview

List of items.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Clio::Layout

#screen_width

Constructor Details

#initialize(*items) ⇒ List

Returns a new instance of List.



12
13
14
15
16
17
# File 'lib/clio/layout/list.rb', line 12

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

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

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



10
11
12
# File 'lib/clio/layout/list.rb', line 10

def items
  @items
end

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
# File 'lib/clio/layout/list.rb', line 19

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