Class: AsciiParadise::AsciiTable::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/ascii_paradise/asciitable/style.rb

Constant Summary collapse

DEFAULTS =
#

DEFAULTS

Three different tokens are possible as border style, which are ‘-’,‘|’ and ‘+’.

#
{
  border_x:      '-',
  border_y:      '|',
  border_i:      '+', # 3 borders.
  padding_left:  1,
  padding_right: 1,
  width:         nil
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(i = {}) ⇒ Style

#

initialize

#


60
61
62
63
64
# File 'lib/ascii_paradise/asciitable/style.rb', line 60

def initialize(i = {})
  apply(
    self.class.defaults.merge(i)
  )
end

Instance Attribute Details

#border_iObject

Returns the value of attribute border_i.



38
39
40
# File 'lib/ascii_paradise/asciitable/style.rb', line 38

def border_i
  @border_i
end

#border_xObject

Returns the value of attribute border_x.



36
37
38
# File 'lib/ascii_paradise/asciitable/style.rb', line 36

def border_x
  @border_x
end

#border_yObject

Returns the value of attribute border_y.



37
38
39
# File 'lib/ascii_paradise/asciitable/style.rb', line 37

def border_y
  @border_y
end

#padding_leftObject

Returns the value of attribute padding_left.



39
40
41
# File 'lib/ascii_paradise/asciitable/style.rb', line 39

def padding_left
  @padding_left
end

#padding_rightObject

Returns the value of attribute padding_right.



40
41
42
# File 'lib/ascii_paradise/asciitable/style.rb', line 40

def padding_right
  @padding_right
end

Class Method Details

.defaultsObject

#

Style.defaults

#


78
79
80
# File 'lib/ascii_paradise/asciitable/style.rb', line 78

def self.defaults # Can be called like so: Style.defaults
  DEFAULTS
end

.defaults=(i) ⇒ Object

#

Style.defaults=

#


85
86
87
# File 'lib/ascii_paradise/asciitable/style.rb', line 85

def self.defaults=(i)
  defaults.merge(i) # Call the above method here.
end

Instance Method Details

#apply(i) ⇒ Object

#

apply

The input to this method should be an Array.

#


71
72
73
# File 'lib/ascii_paradise/asciitable/style.rb', line 71

def apply(i)
  i.each { |m, v| __send__ "#{m}=", v }
end

#width=(i) ⇒ Object

#

width=

#


99
100
101
# File 'lib/ascii_paradise/asciitable/style.rb', line 99

def width=(i)
  @width = i
end

#width?Boolean Also known as: width

#

width?

#

Returns:

  • (Boolean)


92
93
94
# File 'lib/ascii_paradise/asciitable/style.rb', line 92

def width?
  @width
end