Class: CommandLineReporter::Column
- Inherits:
-
Object
- Object
- CommandLineReporter::Column
- Includes:
- OptionsValidator
- Defined in:
- lib/command_line_reporter/column.rb
Constant Summary collapse
- VALID_OPTIONS =
i[width padding align color bold underline reversed span].freeze
Instance Method Summary collapse
-
#initialize(text = nil, options = {}) ⇒ Column
constructor
A new instance of Column.
- #required_width ⇒ Object
- #screen_rows ⇒ Object
- #size ⇒ Object
Methods included from OptionsValidator
Constructor Details
#initialize(text = nil, options = {}) ⇒ Column
10 11 12 13 14 15 16 |
# File 'lib/command_line_reporter/column.rb', line 10 def initialize(text = nil, = {}) (, *VALID_OPTIONS) assign_alignment_defaults() assign_color_defaults() self.text = text.to_s end |
Instance Method Details
#required_width ⇒ Object
22 23 24 |
# File 'lib/command_line_reporter/column.rb', line 22 def required_width text.to_s.size + 2 * padding end |
#screen_rows ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/command_line_reporter/column.rb', line 26 def screen_rows if text.nil? || text.empty? [' ' * width] else text.scan(/.{1,#{size}}/m).map { |s| to_cell(s) } end end |
#size ⇒ Object
18 19 20 |
# File 'lib/command_line_reporter/column.rb', line 18 def size width - (2 * padding) + (3 * (span - 1)) end |