Class: Rake::Funnel::Support::Timing::Report::Column
- Inherits:
-
Object
- Object
- Rake::Funnel::Support::Timing::Report::Column
- Defined in:
- lib/rake/funnel/support/timing/report.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
- #format_header ⇒ Object
- #format_value(value) ⇒ Object
-
#initialize(stats: [], header: '', accessor: -> (_) { '' }) ⇒ Column
constructor
A new instance of Column.
- #width ⇒ Object
Constructor Details
#initialize(stats: [], header: '', accessor: -> (_) { '' }) ⇒ Column
Returns a new instance of Column.
11 12 13 14 15 |
# File 'lib/rake/funnel/support/timing/report.rb', line 11 def initialize(stats: [], header: '', accessor: -> (_) { '' }) @stats = stats @header = header @accessor = accessor end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
9 10 11 |
# File 'lib/rake/funnel/support/timing/report.rb', line 9 def header @header end |
Instance Method Details
#format_header ⇒ Object
24 25 26 |
# File 'lib/rake/funnel/support/timing/report.rb', line 24 def format_header @header.ljust(width) end |
#format_value(value) ⇒ Object
28 29 30 |
# File 'lib/rake/funnel/support/timing/report.rb', line 28 def format_value(value) @accessor.call(value).ljust(width) end |
#width ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rake/funnel/support/timing/report.rb', line 17 def width longest_value = @stats.map { |s| @accessor.call(s) }.max_by { |m| m.length } || '' width = longest_value.length width = @header.length if width < @header.length width end |