Class: XfOOrth::BulletPoints
- Defined in:
- lib/fOOrth/library/formatting/bullets.rb
Overview
A class to display data in bullet points.
Instance Method Summary collapse
-
#add(raw_bullet = "*", *raw_item) ⇒ Object
Add an item to this page.
-
#initialize(page_width) ⇒ BulletPoints
constructor
Prepare a blank slate.
-
#render ⇒ Object
Render the page as an array of strings.
Constructor Details
#initialize(page_width) ⇒ BulletPoints
Prepare a blank slate.
9 10 11 |
# File 'lib/fOOrth/library/formatting/bullets.rb', line 9 def initialize(page_width) @page_width, @bullet_data = page_width, [] end |
Instance Method Details
#add(raw_bullet = "*", *raw_item) ⇒ Object
Add an item to this page.
Returns
-
The number if items that did not fit in the page.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fOOrth/library/formatting/bullets.rb', line 16 def add(raw_bullet = "*", *raw_item) if raw_item.empty? bullet = ["*"] items = raw_bullet.in_array else bullet = raw_bullet.in_array items = raw_item.in_array end items.each_index do |index| @bullet_data << [(bullet[index] || "").to_s, items[index].to_s] end end |
#render ⇒ Object
Render the page as an array of strings.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fOOrth/library/formatting/bullets.rb', line 32 def render @key_length, results = get_key_length, [] @bullet_data.each do |key, item| results.concat(render_bullet(key, item)) end @bullet_data = [] results end |