Class: TTY::Box::Border Private

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/box/border.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 reponsible for retrieving border options

Constant Summary collapse

BORDER_VALUES =

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

%i[
  corner_bottom_right
  corner_top_right
  corner_top_left
  corner_bottom_left
  divider_left
  divider_up
  divider_down
  divider_right
  line
  pipe
  cross
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: :light, top: :line, top_left: :corner_top_left, top_right: :corner_top_right, left: :pipe, right: :pipe, bottom: :line, bottom_left: :corner_bottom_left, bottom_right: :corner_bottom_right) ⇒ Border

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.

Returns a new instance of Border.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/tty/box/border.rb', line 47

def initialize(type: :light,
               top: :line,
               top_left: :corner_top_left,
               top_right: :corner_top_right,
               left: :pipe,
               right: :pipe,
               bottom: :line,
               bottom_left: :corner_bottom_left,
               bottom_right: :corner_bottom_right)

  @type         = type
  @top          = check_name(:top, top)
  @top_left     = check_name(:top_left, top_left)
  @top_right    = check_name(:top_right, top_right)
  @left         = check_name(:left, left)
  @right        = check_name(:right, right)
  @bottom       = check_name(:bottom, bottom)
  @bottom_left  = check_name(:bottom_left, bottom_left)
  @bottom_right = check_name(:bottom_right, bottom_right)
end

Instance Attribute Details

#bottomObject (readonly) Also known as: bottom?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def bottom
  @bottom
end

#bottom_leftObject (readonly) Also known as: bottom_left?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def bottom_left
  @bottom_left
end

#bottom_rightObject (readonly) Also known as: bottom_right?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def bottom_right
  @bottom_right
end

#leftObject (readonly) Also known as: left?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def left
  @left
end

#rightObject (readonly) Also known as: right?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def right
  @right
end

#topObject (readonly) Also known as: top?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def top
  @top
end

#top_leftObject (readonly) Also known as: top_left?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def top_left
  @top_left
end

#top_rightObject (readonly) Also known as: top_right?

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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def top_right
  @top_right
end

#typeObject (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.



35
36
37
# File 'lib/tty/box/border.rb', line 35

def type
  @type
end

Class Method Details

.parse(border) ⇒ Object

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.



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tty/box/border.rb', line 23

def self.parse(border)
  case border
  when Hash
    new(**border)
  when *TTY::Box::BOX_CHARS.keys
    new(type: border)
  else
    raise ArgumentError,
          "Wrong value `#{border}` for :border configuration option"
  end
end