tty 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -3
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +42 -306
  5. data/lib/tty/{text → shell}/distance.rb +5 -27
  6. data/lib/tty/shell/suggestion.rb +42 -22
  7. data/lib/tty/version.rb +1 -1
  8. data/lib/tty.rb +2 -42
  9. data/spec/tty/{text → shell}/distance/distance_spec.rb +4 -4
  10. data/spec/tty/shell/distance/initialize_spec.rb +14 -0
  11. data/tty.gemspec +4 -3
  12. metadata +37 -269
  13. data/benchmarks/table.rb +0 -40
  14. data/lib/tty/table/border/ascii.rb +0 -32
  15. data/lib/tty/table/border/null.rb +0 -37
  16. data/lib/tty/table/border/row_line.rb +0 -18
  17. data/lib/tty/table/border/unicode.rb +0 -32
  18. data/lib/tty/table/border.rb +0 -222
  19. data/lib/tty/table/border_dsl.rb +0 -251
  20. data/lib/tty/table/border_options.rb +0 -53
  21. data/lib/tty/table/column_set.rb +0 -121
  22. data/lib/tty/table/columns.rb +0 -170
  23. data/lib/tty/table/error.rb +0 -18
  24. data/lib/tty/table/field.rb +0 -139
  25. data/lib/tty/table/header.rb +0 -133
  26. data/lib/tty/table/indentation.rb +0 -52
  27. data/lib/tty/table/operation/alignment.rb +0 -107
  28. data/lib/tty/table/operation/alignment_set.rb +0 -77
  29. data/lib/tty/table/operation/escape.rb +0 -30
  30. data/lib/tty/table/operation/filter.rb +0 -34
  31. data/lib/tty/table/operation/padding.rb +0 -95
  32. data/lib/tty/table/operation/truncation.rb +0 -55
  33. data/lib/tty/table/operation/wrapped.rb +0 -58
  34. data/lib/tty/table/operations.rb +0 -69
  35. data/lib/tty/table/orientation/horizontal.rb +0 -48
  36. data/lib/tty/table/orientation/vertical.rb +0 -38
  37. data/lib/tty/table/orientation.rb +0 -57
  38. data/lib/tty/table/padder.rb +0 -180
  39. data/lib/tty/table/renderer/ascii.rb +0 -16
  40. data/lib/tty/table/renderer/basic.rb +0 -294
  41. data/lib/tty/table/renderer/color.rb +0 -12
  42. data/lib/tty/table/renderer/unicode.rb +0 -21
  43. data/lib/tty/table/renderer.rb +0 -101
  44. data/lib/tty/table/row.rb +0 -217
  45. data/lib/tty/table/transformation.rb +0 -39
  46. data/lib/tty/table/validatable.rb +0 -64
  47. data/lib/tty/table.rb +0 -476
  48. data/lib/tty/text/truncation.rb +0 -99
  49. data/lib/tty/text/wrapping.rb +0 -118
  50. data/lib/tty/text.rb +0 -98
  51. data/spec/tty/table/access_spec.rb +0 -86
  52. data/spec/tty/table/add_row_spec.rb +0 -28
  53. data/spec/tty/table/border/ascii/rendering_spec.rb +0 -90
  54. data/spec/tty/table/border/new_spec.rb +0 -27
  55. data/spec/tty/table/border/null/rendering_spec.rb +0 -130
  56. data/spec/tty/table/border/options/from_spec.rb +0 -38
  57. data/spec/tty/table/border/options/new_spec.rb +0 -14
  58. data/spec/tty/table/border/unicode/rendering_spec.rb +0 -63
  59. data/spec/tty/table/border_options/new_spec.rb +0 -20
  60. data/spec/tty/table/border_options/update_spec.rb +0 -18
  61. data/spec/tty/table/column_set/extract_widths_spec.rb +0 -15
  62. data/spec/tty/table/column_set/total_width_spec.rb +0 -15
  63. data/spec/tty/table/column_set/widths_from_spec.rb +0 -51
  64. data/spec/tty/table/columns/enforce_spec.rb +0 -68
  65. data/spec/tty/table/columns/widths_spec.rb +0 -35
  66. data/spec/tty/table/data_spec.rb +0 -14
  67. data/spec/tty/table/each_spec.rb +0 -41
  68. data/spec/tty/table/each_with_index_spec.rb +0 -57
  69. data/spec/tty/table/empty_spec.rb +0 -23
  70. data/spec/tty/table/eql_spec.rb +0 -34
  71. data/spec/tty/table/field/equality_spec.rb +0 -51
  72. data/spec/tty/table/field/length_spec.rb +0 -21
  73. data/spec/tty/table/field/lines_spec.rb +0 -21
  74. data/spec/tty/table/field/new_spec.rb +0 -29
  75. data/spec/tty/table/field/width_spec.rb +0 -23
  76. data/spec/tty/table/filter_spec.rb +0 -23
  77. data/spec/tty/table/header/call_spec.rb +0 -30
  78. data/spec/tty/table/header/height_spec.rb +0 -27
  79. data/spec/tty/table/header/new_spec.rb +0 -25
  80. data/spec/tty/table/header/set_spec.rb +0 -20
  81. data/spec/tty/table/header/to_ary_spec.rb +0 -14
  82. data/spec/tty/table/header_spec.rb +0 -13
  83. data/spec/tty/table/indentation/insert_indent_spec.rb +0 -27
  84. data/spec/tty/table/initialize_spec.rb +0 -88
  85. data/spec/tty/table/operation/alignment/format_spec.rb +0 -47
  86. data/spec/tty/table/operation/alignment/new_spec.rb +0 -31
  87. data/spec/tty/table/operation/alignment_set/call_spec.rb +0 -39
  88. data/spec/tty/table/operation/alignment_set/each_spec.rb +0 -17
  89. data/spec/tty/table/operation/alignment_set/new_spec.rb +0 -27
  90. data/spec/tty/table/operation/alignment_set/to_ary_spec.rb +0 -14
  91. data/spec/tty/table/operation/escape/call_spec.rb +0 -16
  92. data/spec/tty/table/operation/filter/call_spec.rb +0 -17
  93. data/spec/tty/table/operation/truncation/call_spec.rb +0 -32
  94. data/spec/tty/table/operation/truncation/truncate_spec.rb +0 -22
  95. data/spec/tty/table/operation/wrapped/call_spec.rb +0 -33
  96. data/spec/tty/table/operation/wrapped/wrap_spec.rb +0 -23
  97. data/spec/tty/table/operations/new_spec.rb +0 -30
  98. data/spec/tty/table/options_spec.rb +0 -25
  99. data/spec/tty/table/orientation_spec.rb +0 -145
  100. data/spec/tty/table/padder/parse_spec.rb +0 -45
  101. data/spec/tty/table/padder/to_s_spec.rb +0 -14
  102. data/spec/tty/table/padding_spec.rb +0 -120
  103. data/spec/tty/table/properties_spec.rb +0 -25
  104. data/spec/tty/table/render_spec.rb +0 -63
  105. data/spec/tty/table/render_with_spec.rb +0 -106
  106. data/spec/tty/table/renderer/ascii/indentation_spec.rb +0 -41
  107. data/spec/tty/table/renderer/ascii/padding_spec.rb +0 -61
  108. data/spec/tty/table/renderer/ascii/render_spec.rb +0 -68
  109. data/spec/tty/table/renderer/ascii/resizing_spec.rb +0 -114
  110. data/spec/tty/table/renderer/ascii/separator_spec.rb +0 -28
  111. data/spec/tty/table/renderer/basic/alignment_spec.rb +0 -88
  112. data/spec/tty/table/renderer/basic/coloring_spec.rb +0 -46
  113. data/spec/tty/table/renderer/basic/extract_column_widths_spec.rb +0 -28
  114. data/spec/tty/table/renderer/basic/filter_spec.rb +0 -53
  115. data/spec/tty/table/renderer/basic/indentation_spec.rb +0 -48
  116. data/spec/tty/table/renderer/basic/multiline_content_spec.rb +0 -135
  117. data/spec/tty/table/renderer/basic/new_spec.rb +0 -22
  118. data/spec/tty/table/renderer/basic/options_spec.rb +0 -48
  119. data/spec/tty/table/renderer/basic/padding_spec.rb +0 -52
  120. data/spec/tty/table/renderer/basic/render_spec.rb +0 -57
  121. data/spec/tty/table/renderer/basic/resizing_spec.rb +0 -96
  122. data/spec/tty/table/renderer/basic/separator_spec.rb +0 -43
  123. data/spec/tty/table/renderer/basic/truncation_spec.rb +0 -35
  124. data/spec/tty/table/renderer/basic/wrapping_spec.rb +0 -40
  125. data/spec/tty/table/renderer/basic_spec.rb +0 -0
  126. data/spec/tty/table/renderer/border_spec.rb +0 -104
  127. data/spec/tty/table/renderer/render_spec.rb +0 -36
  128. data/spec/tty/table/renderer/select_spec.rb +0 -22
  129. data/spec/tty/table/renderer/style_spec.rb +0 -72
  130. data/spec/tty/table/renderer/unicode/indentation_spec.rb +0 -41
  131. data/spec/tty/table/renderer/unicode/padding_spec.rb +0 -61
  132. data/spec/tty/table/renderer/unicode/render_spec.rb +0 -68
  133. data/spec/tty/table/renderer/unicode/separator_spec.rb +0 -26
  134. data/spec/tty/table/renderer_spec.rb +0 -19
  135. data/spec/tty/table/rotate_spec.rb +0 -86
  136. data/spec/tty/table/row/access_spec.rb +0 -25
  137. data/spec/tty/table/row/call_spec.rb +0 -41
  138. data/spec/tty/table/row/data_spec.rb +0 -26
  139. data/spec/tty/table/row/each_spec.rb +0 -31
  140. data/spec/tty/table/row/equality_spec.rb +0 -73
  141. data/spec/tty/table/row/height_spec.rb +0 -27
  142. data/spec/tty/table/row/new_spec.rb +0 -41
  143. data/spec/tty/table/row/to_ary_spec.rb +0 -14
  144. data/spec/tty/table/to_s_spec.rb +0 -63
  145. data/spec/tty/table/transformation/extract_tuples_spec.rb +0 -35
  146. data/spec/tty/table/validatable/validate_options_spec.rb +0 -33
  147. data/spec/tty/table/validatable_spec.rb +0 -32
  148. data/spec/tty/text/distance/initialize_spec.rb +0 -14
  149. data/spec/tty/text/distance_spec.rb +0 -11
  150. data/spec/tty/text/truncate_spec.rb +0 -12
  151. data/spec/tty/text/truncation/initialize_spec.rb +0 -29
  152. data/spec/tty/text/truncation/truncate_spec.rb +0 -94
  153. data/spec/tty/text/wrap_spec.rb +0 -13
  154. data/spec/tty/text/wrapping/initialize_spec.rb +0 -25
  155. data/spec/tty/text/wrapping/wrap_spec.rb +0 -97
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- module Operation
6
- # A class responsible for escaping special chars in a table field
7
- #
8
- # @api private
9
- class Escape
10
-
11
- # Escape special characters in a table field
12
- #
13
- # @param [TTY::Table::Field] field
14
- #
15
- # @param [Integer] row
16
- # the field row index
17
- #
18
- # @param [Integer] col
19
- # the field column index
20
- #
21
- # @api public
22
- def call(field, row, col)
23
- field.value = field.value.to_s.gsub(/(\t|\r|\n)/) do |val|
24
- val.dump.gsub('"', '')
25
- end
26
- end
27
- end # Escape
28
- end # Operation
29
- end # Table
30
- end # TTY
@@ -1,34 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- module Operation
6
- # A class responsible for transforming table field
7
- #
8
- # @api private
9
- class Filter
10
- # Initialize a Filter
11
- #
12
- # @api public
13
- def initialize(filter)
14
- @filter = filter
15
- end
16
-
17
- # Apply filer to the provided table field
18
- #
19
- # @param [TTY::Table::Field] field
20
- #
21
- # @param [Integer] row
22
- # the field row index
23
- #
24
- # @param [Integer] col
25
- # the field column index
26
- #
27
- # @api public
28
- def call(field, row, col)
29
- field.value = @filter.call(field.value, row, col)
30
- end
31
- end # Filter
32
- end # Operation
33
- end # Table
34
- end # TTY
@@ -1,95 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- module TTY
4
- class Table
5
- module Operation
6
-
7
- # A class responsible for padding field with whitespace
8
- class Padding
9
-
10
- attr_reader :padding_top
11
-
12
- attr_reader :padding_right
13
-
14
- attr_reader :padding_bottom
15
-
16
- attr_reader :padding_left
17
-
18
- attr_reader :padding_width
19
-
20
- attr_reader :multiline
21
-
22
- # Initialize a Padding operation
23
- #
24
- # @param [TTY::Table::Padder]
25
- #
26
- # @api public
27
- def initialize(padding, multiline)
28
- @padding_top = "\n" * padding.top
29
- @padding_right = ' ' * padding.right
30
- @padding_bottom = "\n" * padding.bottom
31
- @padding_left = ' ' * padding.left
32
- @padding_width = padding.left + padding.right
33
- @multiline = multiline
34
- end
35
-
36
- # Apply padding to a field
37
- #
38
- # @param [TTY::Table::Field] field
39
- # the table field
40
- #
41
- # @param [Integer] row
42
- # the field row index
43
- #
44
- # @param [Integer] col
45
- # the field column index
46
- #
47
- # @return [TTY::Table::Field]
48
- #
49
- # @api public
50
- def call(field, row, col)
51
- text = field.value.to_s
52
-
53
- text = multiline ? pad_multi_line(text) : pad_single_line(text)
54
- text.insert(0, padding_top).insert(-1, padding_bottom)
55
-
56
- field.value = text
57
- end
58
-
59
- # Apply padding to multi line text
60
- #
61
- # @param [String] text
62
- #
63
- # @return [String]
64
- #
65
- # @api private
66
- def pad_multi_line(text)
67
- text.split("\n", -1).map { |part| pad_around(part) }.join("\n")
68
- end
69
-
70
- # Apply padding to single line text
71
- #
72
- # @param [String] text
73
- #
74
- # @return [String]
75
- #
76
- # @api private
77
- def pad_single_line(text)
78
- pad_around(text.strip)
79
- end
80
-
81
- # Apply padding to left and right side of string
82
- #
83
- # @param [String] text
84
- #
85
- # @return [String]
86
- #
87
- # @api private
88
- def pad_around(text)
89
- text.insert(0, padding_left).insert(-1, padding_right)
90
- end
91
-
92
- end # Padding
93
- end # Operation
94
- end # Table
95
- end # TTY
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- module Operation
6
- # A class responsible for shortening text.
7
- #
8
- # @api private
9
- class Truncation
10
-
11
- attr_reader :widths
12
-
13
- # Initialize a Truncation
14
- #
15
- # @api public
16
- def initialize(widths)
17
- @widths = widths
18
- end
19
-
20
- # Apply truncation to a field
21
- #
22
- # @param [TTY::Table::Field] field
23
- # the table field
24
- #
25
- # @param [Integer] row
26
- # the field row index
27
- #
28
- # @param [Integer] col
29
- # the field column index
30
- #
31
- # @return [TTY::Table::Field]
32
- #
33
- # @api public
34
- def call(field, row, col)
35
- width = widths[col] || field.width
36
- field.value = truncate(field.value, width)
37
- end
38
-
39
- # Shorten given string with traling character.
40
- #
41
- # @param [String] string
42
- # the string to truncate
43
- # @param [Integer] width
44
- # the maximum width
45
- #
46
- # @return [String]
47
- #
48
- # @api public
49
- def truncate(string, width)
50
- TTY::Text.truncate(string, width)
51
- end
52
- end # Truncation
53
- end # Operation
54
- end # Table
55
- end # TTY
@@ -1,58 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- module Operation
6
- # A class responsible for wrapping text.
7
- #
8
- # @api private
9
- class Wrapped
10
-
11
- attr_reader :widths
12
-
13
- attr_reader :padding
14
-
15
- # Initialize a Wrapped
16
- #
17
- # @api public
18
- def initialize(widths, padding)
19
- @widths = widths
20
- @padding = padding.padding
21
- end
22
-
23
- # Apply wrapping to a field
24
- #
25
- # @param [TTY::Table::Field] field
26
- # the table field
27
- #
28
- # @param [Integer] row
29
- # the field row index
30
- #
31
- # @param [Integer] col
32
- # the field column index
33
- #
34
- # @return [Array[String]]
35
- #
36
- # @api public
37
- def call(field, row, col)
38
- width = widths[col] || field.width
39
- field.value = wrap(field.value, width)
40
- end
41
-
42
- # Wrap a long string according to the width.
43
- #
44
- # @param [String] string
45
- # the string to wrap
46
- # @param [Integer] width
47
- # the maximum width
48
- #
49
- # @return [String]
50
- #
51
- # @api public
52
- def wrap(string, width)
53
- TTY::Text.wrap(string, width, padding: padding)
54
- end
55
- end # Wrapped
56
- end # Operation
57
- end # Table
58
- end # TTY
@@ -1,69 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- # A class holding table field operations.
6
- #
7
- # @api private
8
- class Operations
9
- # The table
10
- #
11
- # @api private
12
- attr_reader :table
13
- private :table
14
-
15
- # Available operations
16
- #
17
- # @return [Hash]
18
- #
19
- # @api public
20
- attr_reader :operations
21
-
22
- # Initialize Operations
23
- #
24
- # @param [TTY::Table] table
25
- # the table to perform operations on
26
- #
27
- # @return [Object]
28
- #
29
- # @api public
30
- def initialize(table)
31
- @table = table
32
- @operations = Hash.new { |hash, key| hash[key] = [] }
33
- end
34
-
35
- # Add operation
36
- #
37
- # @param [Symbol] operation_type
38
- # the operation type
39
- # @param [Object] object
40
- # the callable object
41
- #
42
- # @return [Hash]
43
- #
44
- # @api public
45
- def add(operation_type, object)
46
- operations[operation_type] << object
47
- end
48
-
49
- # Apply operations to a table row
50
- #
51
- # @param [Array[Symbol]] types
52
- # the operation types
53
- # @param [Hash] options
54
- # the options for the row
55
- #
56
- # @return [TTY::Table]
57
- #
58
- # @api public
59
- def run_operations(*args)
60
- operation_types = args
61
- table.each_with_index do |val, row, col|
62
- operation_types.each do |type|
63
- operations[type].each { |op| op.call(val, row, col) }
64
- end
65
- end
66
- end
67
- end # Operations
68
- end # Table
69
- end # TTY
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- # A class representing table orientation
6
- class Orientation
7
- # A class responsible for horizontal table transformation
8
- class Horizontal < Orientation
9
- # Rotate table horizontally
10
- #
11
- # @param [Table] table
12
- #
13
- # @return [nil]
14
- #
15
- # @api public
16
- def transform(table)
17
- table.rotate_horizontal
18
- end
19
-
20
- # Slice vertical table data into horizontal
21
- #
22
- # @param [Table] table
23
- #
24
- # @api public
25
- def slice(table)
26
- head, body, array_h, array_b = 4.times.map { [] }
27
- index = 0
28
- first_column = 0
29
- second_column = 1
30
-
31
- (0...table.original_columns * table.original_rows).each do |col_index|
32
- row = table.rows[index]
33
- array_h += [row[first_column]]
34
- array_b += [row[second_column]]
35
-
36
- if col_index % table.original_columns == 2
37
- head << array_h
38
- body << array_b
39
- array_h, array_b = [], []
40
- end
41
- index += 1
42
- end
43
- [head, body]
44
- end
45
- end # Horizontal
46
- end # Orientation
47
- end # Table
48
- end # TTY
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- # A class representing table orientation
6
- class Orientation
7
- # A class responsible for vertical table transformation
8
- class Vertical < Orientation
9
- # Rotate table vertically
10
- #
11
- # @param [Table] table
12
- #
13
- # @return [nil]
14
- #
15
- # @api public
16
- def transform(table)
17
- table.rotate_vertical
18
- end
19
-
20
- # Slice horizontal table data into vertical
21
- #
22
- # @param [Table] table
23
- #
24
- # @api public
25
- def slice(table)
26
- header = table.header
27
- row_size = table.row_size
28
-
29
- head = header ? header : (0..row_size).map { |n| (n + 1).to_s }
30
-
31
- (0...row_size).reduce([]) do |array, index|
32
- array + head.zip(table.rows[index]).map { |row| table.to_row(row) }
33
- end
34
- end
35
- end # Vertical
36
- end # Orientation
37
- end # Table
38
- end # TTY
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- # A class representing table orientation
6
- #
7
- # @api private
8
- class Orientation
9
- # The name for the orientation
10
- #
11
- # @api public
12
- attr_reader :name
13
-
14
- # Initialize an Orientation
15
- #
16
- # @api public
17
- def initialize(name)
18
- @name = name
19
- end
20
-
21
- # Coerce the name argument into an orientation
22
- #
23
- # @param [Symbol] name
24
- #
25
- # @api public
26
- def self.coerce(name)
27
- case name.to_s
28
- when /h|horiz(ontal)?/i
29
- Horizontal.new :horizontal
30
- when /v|ert(ical)?/i
31
- Vertical.new :vertical
32
- else
33
- fail InvalidOrientationError,
34
- 'orientation must be one of :horizontal, :vertical'
35
- end
36
- end
37
-
38
- # Check if orientation is vertical
39
- #
40
- # @return [Boolean]
41
- #
42
- # @api public
43
- def vertical?
44
- name == :vertical
45
- end
46
-
47
- # Check if orientation is horizontal
48
- #
49
- # @return [Boolean]
50
- #
51
- # @api public
52
- def horizontal?
53
- name == :horizontal
54
- end
55
- end # Orientation
56
- end # Table
57
- end # TTY
@@ -1,180 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- # A class responsible for processing table field padding
6
- #
7
- # Used internally by {Table::Renderer}
8
- #
9
- # @api private
10
- class Padder
11
- include Equatable
12
-
13
- # Padding for the table cells
14
- #
15
- # @return [Array[Integer]]
16
- attr_reader :padding
17
-
18
- # Initialize a Padder
19
- #
20
- # @api public
21
- def initialize(padding)
22
- @padding = padding
23
- end
24
-
25
- # Parse padding options
26
- #
27
- # Turn possible values into 4 element array
28
- #
29
- # @example
30
- # padder = TTY::Table::Padder.parse(5)
31
- # padder.padding # => [5, 5, 5, 5]
32
- #
33
- # @param [Object] value
34
- #
35
- # @return [TTY::Padder]
36
- # the new padder with padding values
37
- #
38
- # @api public
39
- def self.parse(value = nil)
40
- return value if value.is_a?(self)
41
-
42
- new(convert_to_ary(value))
43
- end
44
-
45
- # Convert value to 4 element array
46
- #
47
- # @return [Array[Integer]]
48
- # the 4 element padding array
49
- #
50
- # @api private
51
- def self.convert_to_ary(value)
52
- if value.class <= Numeric
53
- [value, value, value, value]
54
- elsif value.nil?
55
- []
56
- elsif value.size == 2
57
- [value[0], value[1], value[0], value[1]]
58
- elsif value.size == 4
59
- value
60
- else
61
- fail ArgumentError, 'Wrong :padding parameter, must be an array'
62
- end
63
- end
64
-
65
- # Top padding
66
- #
67
- # @return [Integer]
68
- #
69
- # @api public
70
- def top
71
- @padding[0].to_i
72
- end
73
-
74
- # Set top padding
75
- #
76
- # @param [Integer] val
77
- #
78
- # @return [nil]
79
- #
80
- # @api public
81
- def top=(value)
82
- @padding[0] = value
83
- end
84
-
85
- # Right padding
86
- #
87
- # @return [Integer]
88
- #
89
- # @api public
90
- def right
91
- @padding[1].to_i
92
- end
93
-
94
- # Set right padding
95
- #
96
- # @param [Integer] val
97
- #
98
- # @api public
99
- def right=(value)
100
- @padding[1] = value
101
- end
102
-
103
- # Bottom padding
104
- #
105
- # @return [Integer]
106
- #
107
- # @api public
108
- def bottom
109
- @padding[2].to_i
110
- end
111
-
112
- # Set bottom padding
113
- #
114
- # @param [Integer] value
115
- #
116
- # @return [nil]
117
- #
118
- # @api public
119
- def bottom=(value)
120
- @padding[2] = value
121
- end
122
-
123
- # Left padding
124
- #
125
- # @return [Integer]
126
- #
127
- # @api public
128
- def left
129
- @padding[3].to_i
130
- end
131
-
132
- # Set left padding
133
- #
134
- # @param [Integer] value
135
- #
136
- # @return [nil]
137
- #
138
- # @api public
139
- def left=(value)
140
- @padding[3] = value
141
- end
142
-
143
- # Check if padding is set
144
- #
145
- # @return [Boolean]
146
- #
147
- # @api public
148
- def empty?
149
- padding.empty?
150
- end
151
-
152
- # Check if vertical padding is applied
153
- #
154
- # @return [Boolean]
155
- #
156
- # @api public
157
- def vertical?
158
- top.nonzero? || bottom.nonzero?
159
- end
160
-
161
- # Check if horizontal padding is applied
162
- #
163
- # @return [Boolean]
164
- #
165
- # @api public
166
- def horizontal?
167
- left.nonzero? || right.nonzero?
168
- end
169
-
170
- # String represenation of this padder with padding values
171
- #
172
- # @return [String]
173
- #
174
- # @api public
175
- def to_s
176
- inspect
177
- end
178
- end # Padder
179
- end # Table
180
- end # TTY
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module TTY
4
- class Table
5
- class Renderer
6
- class ASCII < Basic
7
- # Create ASCII renderer
8
- #
9
- # @api private
10
- def initialize(table, options = {})
11
- super(table, options.merge(border_class: TTY::Table::Border::ASCII))
12
- end
13
- end # ASCII
14
- end # Renderer
15
- end # Table
16
- end # TTY