Class: Mysh::BulletPoints

Inherits:
Object show all
Defined in:
lib/mysh/internal/format/bullets.rb

Overview

  • mysh/internal/format/bullets.rb - A class to display data in bullet points.

Instance Method Summary collapse

Constructor Details

#initialize(page_width) ⇒ BulletPoints

Prepare a blank slate.



10
11
12
13
14
# File 'lib/mysh/internal/format/bullets.rb', line 10

def initialize(page_width)
  @page_width  = page_width
  @bullet_data = []
  @key_length  = nil
end

Instance Method Details

#add(bullet, *items) ⇒ Object

Add items to these bullet points.



17
18
19
20
21
22
# File 'lib/mysh/internal/format/bullets.rb', line 17

def add(bullet, *items)
  items.each do |item|
    @bullet_data << [bullet.to_s, item]
    bullet = ""
  end
end

#renderObject

Render the bullet points as an array of strings.



25
26
27
28
29
30
31
32
33
34
# File 'lib/mysh/internal/format/bullets.rb', line 25

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