Class Terminal::Table::Style
In: lib/terminal-table/style.rb
lib/terminal-table/style.rb
Parent: Object

A Style object holds all the formatting information for a Table object

To create a table with a certain style, use either the constructor option :style, the Table#style object or the Table#style= method

All these examples have the same effect:

    # by constructor
    @table = Table.new(:style => {:padding_left => 2, :width => 40})

    # by object
    @table.style.padding_left = 2
    @table.style.width = 40

    # by method
    @table.style = {:padding_left => 2, :width => 40}

To set a default style for all tables created afterwards use Style.defaults=

    Terminal::Table::Style.defaults = {:width => 80}

Methods

apply   apply   defaults   defaults   defaults=   defaults=   new   new  

Attributes

border_i  [RW] 
border_i  [RW] 
border_x  [RW] 
border_x  [RW] 
border_y  [RW] 
border_y  [RW] 
padding_left  [RW] 
padding_left  [RW] 
padding_right  [RW] 
padding_right  [RW] 
width  [RW] 
width  [RW] 

Public Class methods

[Source]

    # File lib/terminal-table/style.rb, line 51
51:         def defaults
52:           @@defaults
53:         end

[Source]

    # File lib/terminal-table/style.rb, line 51
51:         def defaults
52:           @@defaults
53:         end

[Source]

    # File lib/terminal-table/style.rb, line 55
55:         def defaults= options
56:           @@defaults = defaults.merge(options)
57:         end

[Source]

    # File lib/terminal-table/style.rb, line 55
55:         def defaults= options
56:           @@defaults = defaults.merge(options)
57:         end

[Source]

    # File lib/terminal-table/style.rb, line 42
42:       def initialize options = {}
43:         apply self.class.defaults.merge(options)
44:       end

[Source]

    # File lib/terminal-table/style.rb, line 42
42:       def initialize options = {}
43:         apply self.class.defaults.merge(options)
44:       end

Public Instance methods

[Source]

    # File lib/terminal-table/style.rb, line 46
46:       def apply options
47:         options.each { |m, v| __send__ "#{m}=", v }
48:       end

[Source]

    # File lib/terminal-table/style.rb, line 46
46:       def apply options
47:         options.each { |m, v| __send__ "#{m}=", v }
48:       end

[Validate]