class Array
-
Runtime clone library support in
Array
.
-
library/formatting/array.rb -
Array
support for displaying data formatted neatly.
Public Instance Methods
foorth_column_width()
click to toggle source
Get the widest element of an array.
Returns
-
The width of the widest string in the array.
# File lib/fOOrth/library/formatting/array.rb, line 29 def foorth_column_width (self.max_by {|item| item.length}).length end
foorth_format_bullets(page_width)
click to toggle source
Convert the array to strings with bullet points.
Returns
-
A string
# File lib/fOOrth/library/formatting/array.rb, line 62 def foorth_format_bullets(page_width) return "" if empty? builder = XfOOrth::BulletPoints.new(page_width) self.each do |pair| builder.add(*pair.prepare_bullet_data) end builder.render.join("\n").freeze end
format_description(page_width)
click to toggle source
Convert the array to a bullet point description.
Returns
-
An array of strings.
# File lib/fOOrth/library/formatting/array.rb, line 77 def format_description(page_width) format_foorth_pages(false, page_width)[0] || [] end
format_foorth_columns(page_length, page_width)
click to toggle source
Convert the array to strings with efficient columns.
Returns
-
A string.
# File lib/fOOrth/library/formatting/array.rb, line 18 def format_foorth_columns(page_length, page_width) format_foorth_pages(page_length, page_width) .map {|page| page << ""} .flatten[0...-1] .join("\n") .freeze end
full_clone_exclude()
click to toggle source
The full clone data member clone exclusion control
# File lib/fOOrth/library/clone_library.rb, line 54 def full_clone_exclude vm = Thread.current[:vm] self.foorth_exclude(vm) vm.pop end
prepare_bullet_data()
click to toggle source
Get data ready for being in a bullet point.
# File lib/fOOrth/library/formatting/array.rb, line 82 def prepare_bullet_data if length < 2 ["*", self[0]] else self end end
puts_foorth_bullets(page_width)
click to toggle source
Print out the array as bullet points.
# File lib/fOOrth/library/formatting/array.rb, line 55 def puts_foorth_bullets(page_width) puts foorth_format_bullets(page_width) end
puts_foorth_columns(page_length, page_width)
click to toggle source
Print out the array with efficient columns.
# File lib/fOOrth/library/formatting/array.rb, line 9 def puts_foorth_columns(page_length, page_width) format_foorth_pages(page_length, page_width).each do |page| puts page, "" end end
Private Instance Methods
format_foorth_pages(page_length, page_width)
click to toggle source
Convert the array to strings with efficient columns.
Returns
-
An array of pages (arrays of strings)
# File lib/fOOrth/library/formatting/array.rb, line 38 def format_foorth_pages(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