Class: TablePrint::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/table_print/config.rb

Constant Summary collapse

DEFAULT_MAX_WIDTH =
30
DEFAULT_TIME_FORMAT =
"%Y-%m-%d %H:%M:%S"
DEFAULT_IO =
$stdout
DEFAULT_CAPITALIZE_HEADERS =
true
DEFAULT_SEPARATOR =
"|"
@@max_width =
DEFAULT_MAX_WIDTH
@@time_format =
DEFAULT_TIME_FORMAT
@@multibyte =
false
@@io =
DEFAULT_IO
@@capitalize_headers =
true
@@separator =
DEFAULT_SEPARATOR
@@klasses =
{}

Class Method Summary collapse

Class Method Details

.capitalize_headersObject



64
65
66
# File 'lib/table_print/config.rb', line 64

def self.capitalize_headers
  @@capitalize_headers
end

.capitalize_headers=(caps) ⇒ Object



68
69
70
# File 'lib/table_print/config.rb', line 68

def self.capitalize_headers=(caps)
  @@capitalize_headers = caps
end

.clear(klass) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/table_print/config.rb', line 31

def self.clear(klass)
  if klass.is_a? Class
    @@klasses.delete(klass)
  else
    original_value = TablePrint::Config.const_get("DEFAULT_#{klass.to_s.upcase}")
    TablePrint::Config.send("#{klass}=", original_value)
  end
end

.for(klass) ⇒ Object



27
28
29
# File 'lib/table_print/config.rb', line 27

def self.for(klass)
  @@klasses.fetch(klass) {}
end

.ioObject



80
81
82
# File 'lib/table_print/config.rb', line 80

def self.io
  @@io
end

.io=(io) ⇒ Object

Raises:

  • (StandardError)


84
85
86
87
# File 'lib/table_print/config.rb', line 84

def self.io=(io)
  raise StandardError.new("IO object must respond to :puts") unless io.respond_to? :puts
  @@io = io
end

.max_widthObject



40
41
42
# File 'lib/table_print/config.rb', line 40

def self.max_width
  @@max_width
end

.max_width=(width) ⇒ Object



44
45
46
# File 'lib/table_print/config.rb', line 44

def self.max_width=(width)
  @@max_width = width
end

.multibyteObject



48
49
50
# File 'lib/table_print/config.rb', line 48

def self.multibyte
  @@multibyte
end

.multibyte=(width) ⇒ Object



52
53
54
# File 'lib/table_print/config.rb', line 52

def self.multibyte=(width)
  @@multibyte = width
end

.separatorObject



72
73
74
# File 'lib/table_print/config.rb', line 72

def self.separator
  @@separator
end

.separator=(separator) ⇒ Object



76
77
78
# File 'lib/table_print/config.rb', line 76

def self.separator=(separator)
  @@separator = separator
end

.set(klass, val) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/table_print/config.rb', line 19

def self.set(klass, val)
  if klass.is_a? Class
    @@klasses[klass] = val  # val is a hash of column options
  else
    TablePrint::Config.send("#{klass}=", val.first)
  end
end

.time_formatObject



56
57
58
# File 'lib/table_print/config.rb', line 56

def self.time_format
  @@time_format
end

.time_format=(format) ⇒ Object



60
61
62
# File 'lib/table_print/config.rb', line 60

def self.time_format=(format)
  @@time_format = format
end