Class: CollinsShell::LogPrinter
- Inherits:
-
Object
- Object
- CollinsShell::LogPrinter
- Includes:
- PrinterUtil
- Defined in:
- lib/collins_shell/util/log_printer.rb
Instance Attribute Summary collapse
-
#asset_tag ⇒ Object
readonly
Returns the value of attribute asset_tag.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#table_width ⇒ Object
readonly
Returns the value of attribute table_width.
Instance Method Summary collapse
-
#initialize(asset_or_tag, logs) ⇒ LogPrinter
constructor
A new instance of LogPrinter.
- #render(_logs = []) ⇒ Object (also: #to_s)
Methods included from PrinterUtil
#dynamic_terminal_width, #format_datetime, #wrap_text
Constructor Details
#initialize(asset_or_tag, logs) ⇒ LogPrinter
Returns a new instance of LogPrinter.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/collins_shell/util/log_printer.rb', line 12 def initialize asset_or_tag, logs @asset_tag = Collins::Util.get_asset_or_tag(asset_or_tag).tag if logs.is_a?(Hash) then @logs = logs.delete(:logs) || [] @options = logs else @logs = logs @options = {} end @table_width = 0 @table = Terminal::Table.new(:title => "Logs for #{asset_tag}") end |
Instance Attribute Details
#asset_tag ⇒ Object (readonly)
Returns the value of attribute asset_tag.
10 11 12 |
# File 'lib/collins_shell/util/log_printer.rb', line 10 def asset_tag @asset_tag end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
10 11 12 |
# File 'lib/collins_shell/util/log_printer.rb', line 10 def logs @logs end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/collins_shell/util/log_printer.rb', line 10 def @options end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
10 11 12 |
# File 'lib/collins_shell/util/log_printer.rb', line 10 def table @table end |
#table_width ⇒ Object (readonly)
Returns the value of attribute table_width.
10 11 12 |
# File 'lib/collins_shell/util/log_printer.rb', line 10 def table_width @table_width end |
Instance Method Details
#render(_logs = []) ⇒ Object Also known as: to_s
25 26 27 28 29 30 31 |
# File 'lib/collins_shell/util/log_printer.rb', line 25 def render _logs = [] setup_table setup_header need_separator, formatted_logs = format_logs _logs add_logs_to_table need_separator, formatted_logs render! end |