class Array
Support for displaying an array formatted neatly. Output as bullet points starts with an array as input.
Support for displaying an array formatted neatly. Output as columns starts with an array as input.
Support for displaying an array of strings formatted with word wrap.
Public Instance Methods
This method is a duplicate of a column method with a new name.
Convert the array to a string with bullet points. Returns: A string.
# File lib/format_output/bullets.rb, line 14 def format_output_bullets(options = {}) format_output_raw_bullets(options).join("\n") end
Convert the array to a string with efficient columns. Returns: A string. Endemic Code Smells reek:FeatureEnvy – false positive.
# File lib/format_output/columns.rb, line 15 def format_output_columns(options = {}) format_output_raw_columns(options).join("\n") end
Get the widest element of an array. Returns: The width of the widest string in the array.
# File lib/format_output/columns.rb, line 33 def format_output_greatest_width max_by {|item| item.length}.length end
Get data ready for being in a bullet point.
# File lib/format_output/bullets.rb, line 36 def format_output_prepare_bullet_detail if length < 2 ["*", self[0]] else self end end
Convert the array to strings with bullet points. Returns: An array of strings.
# File lib/format_output/bullets.rb, line 20 def format_output_raw_bullets(options = {}) return [""] if empty? builder = FormatOutput::BulletPointBuilder.new(options) each {|pair| builder.add(*pair.format_output_prepare_bullet_detail)} builder.render end
Convert the array to strings with efficient columns. Returns: An array of strings.
# File lib/format_output/columns.rb, line 21 def format_output_raw_columns(options = {}) builder = FormatOutput::ColumnBuilder.new(options) each {|item| builder.add(item)} builder.render end
Convert the array to strings with word wrap. Returns: An array of strings.
# File lib/format_output/word_wrap.rb, line 19 def format_output_raw_word_wrap(options = {}) result = [] each do |item| result.concat(item.to_s.format_output_raw_word_wrap(options)) result << "" end result end
Convert the array to a string with word wrap. Returns: A string.
# File lib/format_output/word_wrap.rb, line 13 def format_output_word_wrap(options = {}) format_output_raw_word_wrap(options).join("\n") end
Print out the array as bullet points.
# File lib/format_output/bullets.rb, line 8 def puts_format_output_bullets(options = {}) puts format_output_bullets(options) end
Print out the array with efficient columns.
# File lib/format_output/columns.rb, line 8 def puts_format_output_columns(options = {}) puts format_output_columns(options) end
Print out the array with word wrap.
# File lib/format_output/word_wrap.rb, line 7 def puts_format_output_word_wrap(options = {}) puts format_output_word_wrap(options).join("\n") end