Class: Array
- Defined in:
- lib/format_output/bullets.rb,
lib/format_output/columns.rb,
lib/format_output/word_wrap.rb
Overview
Support for displaying an array of strings formatted with word wrap.
Instance Method Summary collapse
-
#format_output_bullet_detail ⇒ Object
This method is a duplicate of a column method with a new name.
-
#format_output_bullets(options = {}) ⇒ Object
Convert the array to a string with bullet points.
-
#format_output_columns(options = {}) ⇒ Object
Convert the array to a string with efficient columns.
-
#format_output_greatest_width ⇒ Object
Get the widest element of an array.
-
#format_output_prepare_bullet_detail ⇒ Object
Get data ready for being in a bullet point.
-
#format_output_raw_bullets(options = {}) ⇒ Object
Convert the array to strings with bullet points.
-
#format_output_raw_columns(options = {}) ⇒ Object
Convert the array to strings with efficient columns.
-
#format_output_raw_word_wrap(options = {}) ⇒ Object
Convert the array to strings with word wrap.
-
#format_output_word_wrap(options = {}) ⇒ Object
Convert the array to a string with word wrap.
-
#puts_format_output_bullets(options = {}) ⇒ Object
Print out the array as bullet points.
-
#puts_format_output_columns(options = {}) ⇒ Object
Print out the array with efficient columns.
-
#puts_format_output_word_wrap(options = {}) ⇒ Object
Print out the array with word wrap.
Instance Method Details
#format_output_bullet_detail ⇒ Object
This method is a duplicate of a column method with a new name.
33 |
# File 'lib/format_output/bullets.rb', line 33 alias :format_output_bullet_detail :format_output_raw_columns |
#format_output_bullets(options = {}) ⇒ Object
Convert the array to a string with bullet points. Returns: A string.
14 15 16 |
# File 'lib/format_output/bullets.rb', line 14 def format_output_bullets( = {}) format_output_raw_bullets().join("\n") end |
#format_output_columns(options = {}) ⇒ Object
Convert the array to a string with efficient columns. Returns: A string. Endemic Code Smells reek:FeatureEnvy – false positive.
15 16 17 |
# File 'lib/format_output/columns.rb', line 15 def format_output_columns( = {}) format_output_raw_columns().join("\n") end |
#format_output_greatest_width ⇒ Object
Get the widest element of an array. Returns: The width of the widest string in the array.
33 34 35 |
# File 'lib/format_output/columns.rb', line 33 def format_output_greatest_width max_by {|item| item.length}.length end |
#format_output_prepare_bullet_detail ⇒ Object
Get data ready for being in a bullet point.
36 37 38 39 40 41 42 |
# File 'lib/format_output/bullets.rb', line 36 def format_output_prepare_bullet_detail if length < 2 ["*", self[0]] else self end end |
#format_output_raw_bullets(options = {}) ⇒ Object
Convert the array to strings with bullet points. Returns: An array of strings.
20 21 22 23 24 25 26 27 28 |
# File 'lib/format_output/bullets.rb', line 20 def format_output_raw_bullets( = {}) return [""] if empty? builder = FormatOutput::BulletPointBuilder.new() each {|pair| builder.add(*pair.format_output_prepare_bullet_detail)} builder.render end |
#format_output_raw_columns(options = {}) ⇒ Object
Convert the array to strings with efficient columns. Returns: An array of strings.
21 22 23 24 25 26 27 |
# File 'lib/format_output/columns.rb', line 21 def format_output_raw_columns( = {}) builder = FormatOutput::ColumnBuilder.new() each {|item| builder.add(item)} builder.render end |
#format_output_raw_word_wrap(options = {}) ⇒ Object
Convert the array to strings with word wrap. Returns: An array of strings.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/format_output/word_wrap.rb', line 19 def format_output_raw_word_wrap( = {}) result = [] each do |item| result.concat(item.to_s.format_output_raw_word_wrap()) result << "" end result end |
#format_output_word_wrap(options = {}) ⇒ Object
Convert the array to a string with word wrap. Returns: A string.
13 14 15 |
# File 'lib/format_output/word_wrap.rb', line 13 def format_output_word_wrap( = {}) format_output_raw_word_wrap().join("\n") end |
#puts_format_output_bullets(options = {}) ⇒ Object
Print out the array as bullet points.
8 9 10 |
# File 'lib/format_output/bullets.rb', line 8 def puts_format_output_bullets( = {}) puts format_output_bullets() end |
#puts_format_output_columns(options = {}) ⇒ Object
Print out the array with efficient columns.
8 9 10 |
# File 'lib/format_output/columns.rb', line 8 def puts_format_output_columns( = {}) puts format_output_columns() end |
#puts_format_output_word_wrap(options = {}) ⇒ Object
Print out the array with word wrap.
7 8 9 |
# File 'lib/format_output/word_wrap.rb', line 7 def puts_format_output_word_wrap( = {}) puts format_output_word_wrap().join("\n") end |