Sha256: b39c94b15de4ceedf16c944a89af799dd49f30fc12ad4c625db05770f4626202
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
# encoding: utf-8 module Terminal class Table # 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 <tt>:style</tt>, 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} # class Style @@defaults = { :border_x => "-", :border_y => "|", :border_i => "+", :padding_left => 1, :padding_right => 1, :width => nil, :alignment => nil, :wrap => true, :wrap_minimum_width => 4 } attr_accessor :border_x attr_accessor :border_y attr_accessor :border_i attr_accessor :padding_left attr_accessor :padding_right attr_accessor :width attr_accessor :alignment attr_accessor :wrap attr_accessor :wrap_minimum_width def initialize options = {} apply self.class.defaults.merge(options) end def apply options options.each { |m, v| __send__ "#{m}=", v } end class << self def defaults @@defaults end def defaults= options @@defaults = defaults.merge(options) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
galileo-0.2.1 | lib/terminal-table/lib/terminal-table/style.rb |