Class: Cure::Export::TerminalProcessor

Inherits:
BaseProcessor show all
Defined in:
lib/cure/export/base_processor.rb

Instance Attribute Summary collapse

Attributes inherited from BaseProcessor

#named_range

Instance Method Summary collapse

Methods inherited from BaseProcessor

#initialize, #process_row

Methods included from Log

#log_debug, #log_error, #log_info, #log_trace, #log_warn

Constructor Details

This class inherits a constructor from Cure::Export::BaseProcessor

Instance Attribute Details

#limit_rowsObject (readonly)

Returns the value of attribute limit_rows.



47
48
49
# File 'lib/cure/export/base_processor.rb', line 47

def limit_rows
  @limit_rows
end

#processedObject (readonly)

Returns the value of attribute processed.



47
48
49
# File 'lib/cure/export/base_processor.rb', line 47

def processed
  @processed
end

#tableObject (readonly)

Returns the value of attribute table.



47
48
49
# File 'lib/cure/export/base_processor.rb', line 47

def table
  @table
end

Instance Method Details

#cleanupObject



68
69
70
# File 'lib/cure/export/base_processor.rb', line 68

def cleanup
  puts @table
end

#process(row) ⇒ Object



49
50
51
52
# File 'lib/cure/export/base_processor.rb', line 49

def process(row)
  @table.headings = row.keys if @processed.zero?
  @table.add_row(row.values)
end

#setupObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cure/export/base_processor.rb', line 54

def setup
  # Markdown mode
  Terminal::Table::Style.defaults = {
    border_top: false,
    border_bottom: false,
    border_x: "-",
    border_y: "|",
    border_i: "|"
  }

  log_info "Exporting [#{@named_range}] to terminal."
  @table = Terminal::Table.new(title: @opts[:title] || "<No Title Set>")
end