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
@@max_width =
DEFAULT_MAX_WIDTH
@@time_format =
DEFAULT_TIME_FORMAT
@@multibyte =
false
@@io =
DEFAULT_IO
@@capitalize_headers =
true
@@klasses =
{}

Class Method Summary collapse

Class Method Details

.capitalize_headersObject



62
63
64
# File 'lib/table_print/config.rb', line 62

def self.capitalize_headers
  @@capitalize_headers
end

.capitalize_headers=(caps) ⇒ Object



66
67
68
# File 'lib/table_print/config.rb', line 66

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

.clear(klass) ⇒ Object



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

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



25
26
27
# File 'lib/table_print/config.rb', line 25

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

.ioObject



70
71
72
# File 'lib/table_print/config.rb', line 70

def self.io
  @@io
end

.io=(io) ⇒ Object

Raises:

  • (StandardError)


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

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

.max_widthObject



38
39
40
# File 'lib/table_print/config.rb', line 38

def self.max_width
  @@max_width
end

.max_width=(width) ⇒ Object



42
43
44
# File 'lib/table_print/config.rb', line 42

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

.multibyteObject



46
47
48
# File 'lib/table_print/config.rb', line 46

def self.multibyte
  @@multibyte
end

.multibyte=(width) ⇒ Object



50
51
52
# File 'lib/table_print/config.rb', line 50

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

.set(klass, val) ⇒ Object



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

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



54
55
56
# File 'lib/table_print/config.rb', line 54

def self.time_format
  @@time_format
end

.time_format=(format) ⇒ Object



58
59
60
# File 'lib/table_print/config.rb', line 58

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