Class: AsciiTable

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii_table.rb,
lib/ascii_table/version.rb

Defined Under Namespace

Classes: AbortError

Constant Summary collapse

DELIMITER_MAP =
{
  "t" => "\t",
  "0" => "\0",
  "v" => "\v",
  "r" => "\r"
}
VERSION =
"0.9.0"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, reader) ⇒ AsciiTable

Returns a new instance of AsciiTable.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ascii_table.rb', line 18

def initialize(args, reader)
  @table  = nil
  @parser = nil
  @input  = []
  # defaults
  @options = OpenStruct.new(
    :delimiter    => ";",
    :headings     => false,
    :table_align  => :left,
    :cell_align   => {},
    :separator    => ""
  )

  parse_options!(args)
  read_input!(reader)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/ascii_table.rb', line 9

def options
  @options
end

#parserObject (readonly)

Returns the value of attribute parser.



9
10
11
# File 'lib/ascii_table.rb', line 9

def parser
  @parser
end

#tableObject (readonly)

Returns the value of attribute table.



9
10
11
# File 'lib/ascii_table.rb', line 9

def table
  @table
end

Instance Method Details

#to_sObject



35
36
37
38
# File 'lib/ascii_table.rb', line 35

def to_s
  generate_table! unless @table
  @table.to_s
end