Class: Contexto::Display
- Inherits:
-
Object
- Object
- Contexto::Display
- Includes:
- CommandLineReporter
- Defined in:
- lib/contexto/display.rb
Overview
Display class
Instance Method Summary collapse
- #col_width ⇒ Object
- #create_display(title, headings, rows) ⇒ Object
- #create_new_table ⇒ Object
- #headings_options ⇒ Object
-
#initialize ⇒ Display
constructor
A new instance of Display.
- #row_options ⇒ Object
Constructor Details
#initialize ⇒ Display
Returns a new instance of Display.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/contexto/display.rb', line 9 def initialize @header = '** Contexto Contextualizes **' puts "\n" header title: @header, width: 80, align: 'center', rule: true, color: 'green', bold: true end |
Instance Method Details
#col_width ⇒ Object
66 67 68 |
# File 'lib/contexto/display.rb', line 66 def col_width @col_width ||= @rows.map(&:size).max + 10 end |
#create_display(title, headings, rows) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/contexto/display.rb', line 20 def create_display(title, headings, rows) @title = title @headings = headings @rows = rows create_new_table end |
#create_new_table ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/contexto/display.rb', line 27 def create_new_table if @title header title: @title, width: 50, align: 'left', color: 'red', bold: true end table(border: true) do row header: true do @headings.each do |h| column(h, ) end end @rows.each do |r| row do r.each do |rr| column(rr, ) end end end end end |
#headings_options ⇒ Object
51 52 53 54 55 56 |
# File 'lib/contexto/display.rb', line 51 def { align: 'center', width: col_width } end |
#row_options ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/contexto/display.rb', line 58 def { align: 'center', width: col_width, color: 'green' } end |