Class: Helium::Console::KeyValue::TableFormatter

Inherits:
Object
  • Object
show all
Includes:
ColorizedString::Helpers
Defined in:
lib/helium/console/key_value.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ColorizedString::Helpers

#length_of

Constructor Details

#initialize(key_value, console:, level:, left:, between:, right:, max_width:, key_options: {}, value_options: {}) ⇒ TableFormatter

Returns a new instance of TableFormatter.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/helium/console/key_value.rb', line 35

def initialize(
  key_value,
  console:,
  level:,
  left:,
  between:,
  right:,
  max_width:,
  key_options: {},
  value_options: {}
)
  @key_value = key_value
  @console = console
  @left = left
  @between = between
  @right = right
  @max_width = max_width
  @key_options = key_options
  @level = level
  @value_options = value_options

  set_width_limits
end

Class Method Details

.call(*args, **options) ⇒ Object



31
32
33
# File 'lib/helium/console/key_value.rb', line 31

def self.call(*args, **options)
  new(*args, **options).()
end

Instance Method Details

#callObject



59
60
61
62
63
64
65
# File 'lib/helium/console/key_value.rb', line 59

def call
  Formatter::LazyStringEvaluator.new do |y|
    key_value.rows.each do |key, value, options|
      format_entry(y, key, value, **options)
    end
  end
end