wbailey / command_line_reporter

A gem for making it easy to produce a report while a ruby script is executing
Apache License 2.0
432 stars 23 forks source link

undefined method `align' for nil:NilClass (NoMethodError) #33

Closed Youngv closed 4 years ago

Youngv commented 6 years ago

I want to have a header with full width, but have the error below:

code:

require 'command_line_reporter'
class AccountInfo
  include CommandLineReporter

  def initialize
    table(border: true, width: 80) do
      row header: true do
        column('Account Info', width: 80)
      end
      row do
        column('balance', width: 40)
        column('9999', width: 40)
      end
    end
  end
end
AccountInfo.new

error:

~/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:111:in `block in use_positional_attrs': undefined method `align' for nil:NilClass (NoMethodError)
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:110:in `each'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:110:in `use_positional_attrs'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:99:in `block in inherit_column_attrs'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `each'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `each_with_index'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:98:in `inherit_column_attrs'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter/table.rb:25:in `add'
    from /Users/victor/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter.rb:123:in `row'
    from account_info.rb:10:in `block in initialize'
    from ~/.rvm/gems/ruby-2.3.1/gems/command_line_reporter-4.0.0/lib/command_line_reporter.rb:115:in `table'
    from account_info.rb:6:in `initialize'
    from account_info.rb:17:in `new'
    from account_info.rb:17:in `<main>'