Class: TTY::Table::BorderDSL Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tty/table/border_dsl.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A class responsible for bulding and modifying border

Used internally by Border to allow for building custom border through DSL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(border_opts = nil, &block) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize a BorderDSL

Parameters:

  • characters (Hash)

    the border characters



32
33
34
35
# File 'lib/tty/table/border_dsl.rb', line 32

def initialize(border_opts = nil, &block)
  @options = TTY::Table::BorderOptions.from(border_opts)
  yield_or_eval(&block) if block_given?
end

Instance Attribute Details

#optionsTable::BorderOptions (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Border options



20
21
22
# File 'lib/tty/table/border_dsl.rb', line 20

def options
  @options
end

Instance Method Details

#bottom(value) ⇒ undefined

Set bottom border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


121
122
123
# File 'lib/tty/table/border_dsl.rb', line 121

def bottom(value)
  characters["bottom"] = value
end

#bottom_left(value) ⇒ undefined

Set bottom left corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


145
146
147
# File 'lib/tty/table/border_dsl.rb', line 145

def bottom_left(value)
  characters["bottom_left"] = value
end

#bottom_mid(value) ⇒ undefined

Set bottom middle border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


133
134
135
# File 'lib/tty/table/border_dsl.rb', line 133

def bottom_mid(value)
  characters["bottom_mid"] = value
end

#bottom_right(value) ⇒ undefined

Set bottom right corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


157
158
159
# File 'lib/tty/table/border_dsl.rb', line 157

def bottom_right(value)
  characters["bottom_right"] = value
end

#center(value) ⇒ undefined

Set center border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


229
230
231
# File 'lib/tty/table/border_dsl.rb', line 229

def center(value)
  characters["center"] = value
end

#left(value) ⇒ undefined

Set left border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


217
218
219
# File 'lib/tty/table/border_dsl.rb', line 217

def left(value)
  characters["left"] = value
end

#mid(value) ⇒ undefined

Set middle border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


169
170
171
# File 'lib/tty/table/border_dsl.rb', line 169

def mid(value)
  characters["mid"] = value
end

#mid_left(value) ⇒ undefined

Set middle left corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


193
194
195
# File 'lib/tty/table/border_dsl.rb', line 193

def mid_left(value)
  characters["mid_left"] = value
end

#mid_mid(value) ⇒ undefined

Set middle border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


181
182
183
# File 'lib/tty/table/border_dsl.rb', line 181

def mid_mid(value)
  characters["mid_mid"] = value
end

#mid_right(value) ⇒ undefined

Set middle right corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


205
206
207
# File 'lib/tty/table/border_dsl.rb', line 205

def mid_right(value)
  characters["mid_right"] = value
end

#right(value) ⇒ undefined

Set right border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


241
242
243
# File 'lib/tty/table/border_dsl.rb', line 241

def right(value)
  characters["right"] = value
end

#separator(value = (not_set = true)) ⇒ undefined

Apply table tuple separator

Parameters:

  • value (Symbol) (defaults to: (not_set = true))

    the table tuple separator

Returns:

  • (undefined)


59
60
61
62
63
# File 'lib/tty/table/border_dsl.rb', line 59

def separator(value = (not_set = true))
  return options.separator if not_set

  options.separator = value
end

#style(value = (not_set = true)) ⇒ undefined

Apply style color to the border

Parameters:

  • value (Symbol) (defaults to: (not_set = true))

    the style color for the border

Returns:

  • (undefined)


45
46
47
48
49
# File 'lib/tty/table/border_dsl.rb', line 45

def style(value = (not_set = true))
  return options.style if not_set

  options.style = value
end

#top(value) ⇒ undefined

Set top border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


73
74
75
# File 'lib/tty/table/border_dsl.rb', line 73

def top(value)
  characters["top"] = value
end

#top_left(value) ⇒ undefined

Set top left corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


97
98
99
# File 'lib/tty/table/border_dsl.rb', line 97

def top_left(value)
  characters["top_left"] = value
end

#top_mid(value) ⇒ undefined

Set top middle border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


85
86
87
# File 'lib/tty/table/border_dsl.rb', line 85

def top_mid(value)
  characters["top_mid"] = value
end

#top_right(value) ⇒ undefined

Set top right corner border character

Parameters:

  • value (String)

    the character value

Returns:

  • (undefined)


109
110
111
# File 'lib/tty/table/border_dsl.rb', line 109

def top_right(value)
  characters["top_right"] = value
end