Class: Array

Inherits:
Object show all
Defined in:
lib/fOOrth/library/clone_library.rb,
lib/fOOrth/library/formatting/bullets.rb,
lib/fOOrth/library/formatting/columns.rb

Overview

Support for displaying an array in neat columns.

Instance Method Summary collapse

Instance Method Details

#foorth_bulletize(page_width) ⇒ Object

Convert the array to strings with bullet points.

  • An array of arrays of strings



92
93
94
95
96
97
98
99
100
# File 'lib/fOOrth/library/formatting/bullets.rb', line 92

def foorth_bulletize(page_width)
  builder = XfOOrth::BulletPoints.new(page_width)

  self.each do |pair|
    builder.add(*pair)
  end

  builder.render
end

#foorth_column_widthObject

Get the widest element of an array.



140
141
142
# File 'lib/fOOrth/library/formatting/columns.rb', line 140

def foorth_column_width
  (self.max_by {|item| item.length}).length
end

#foorth_columnize(page_length, page_width) ⇒ Object

Convert the array to strings with efficient columns.

  • An array of arrays of strings



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fOOrth/library/formatting/columns.rb', line 127

def foorth_columnize(page_length, page_width)
  index, pages, limit = 0, [], self.length
  builder = XfOOrth::ColumnizedPage.new(page_length, page_width)

  while index < limit
    index += 1 - (left_over = builder.add(self[index]))
    pages << builder.render if (left_over > 0) || (index == limit)
  end

  pages
end

#full_clone_excludeObject

The full clone data member clone exclusion control



54
55
56
57
58
# File 'lib/fOOrth/library/clone_library.rb', line 54

def full_clone_exclude
  vm = Thread.current[:vm]
  self.foorth_exclude(vm)
  vm.pop
end

#puts_foorth_bullets(page_width) ⇒ Object

Print out the array as bullet points.



85
86
87
# File 'lib/fOOrth/library/formatting/bullets.rb', line 85

def puts_foorth_bullets(page_width)
  puts foorth_bulletize(page_width)
end

#puts_foorth_columnized(page_length, page_width) ⇒ Object

Print out the array with efficient columns.



117
118
119
120
121
122
# File 'lib/fOOrth/library/formatting/columns.rb', line 117

def puts_foorth_columnized(page_length, page_width)
  foorth_columnize(page_length, page_width).each do |page|
    puts page
    puts
  end
end