tty-table 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +104 -98
  5. data/lib/tty-table.rb +1 -1
  6. data/lib/tty/table.rb +70 -34
  7. data/lib/tty/table/alignment_set.rb +1 -3
  8. data/lib/tty/table/border.rb +50 -57
  9. data/lib/tty/table/border/ascii.rb +16 -16
  10. data/lib/tty/table/border/null.rb +19 -22
  11. data/lib/tty/table/border/row_line.rb +3 -2
  12. data/lib/tty/table/border/unicode.rb +16 -16
  13. data/lib/tty/table/border_dsl.rb +24 -22
  14. data/lib/tty/table/border_options.rb +32 -27
  15. data/lib/tty/table/column_constraint.rb +12 -9
  16. data/lib/tty/table/columns.rb +6 -6
  17. data/lib/tty/table/field.rb +46 -28
  18. data/lib/tty/table/header.rb +5 -5
  19. data/lib/tty/table/indentation.rb +7 -4
  20. data/lib/tty/table/operation/alignment.rb +1 -1
  21. data/lib/tty/table/operation/escape.rb +1 -2
  22. data/lib/tty/table/operation/padding.rb +1 -1
  23. data/lib/tty/table/operation/truncation.rb +1 -1
  24. data/lib/tty/table/operation/wrapped.rb +1 -1
  25. data/lib/tty/table/options.rb +1 -1
  26. data/lib/tty/table/orientation.rb +4 -4
  27. data/lib/tty/table/renderer.rb +8 -8
  28. data/lib/tty/table/renderer/ascii.rb +2 -2
  29. data/lib/tty/table/renderer/basic.rb +37 -40
  30. data/lib/tty/table/renderer/unicode.rb +1 -1
  31. data/lib/tty/table/row.rb +7 -7
  32. data/lib/tty/table/validatable.rb +23 -7
  33. data/lib/tty/table/version.rb +1 -1
  34. metadata +23 -272
  35. data/Rakefile +0 -10
  36. data/examples/alignment.rb +0 -10
  37. data/examples/basic.rb +0 -6
  38. data/examples/orientation.rb +0 -13
  39. data/examples/padding.rb +0 -15
  40. data/examples/resize.rb +0 -15
  41. data/spec/spec_helper.rb +0 -50
  42. data/spec/unit/access_spec.rb +0 -84
  43. data/spec/unit/add_row_spec.rb +0 -26
  44. data/spec/unit/alignment_set/each_spec.rb +0 -15
  45. data/spec/unit/alignment_set/new_spec.rb +0 -25
  46. data/spec/unit/alignment_set/to_ary_spec.rb +0 -12
  47. data/spec/unit/alignment_spec.rb +0 -69
  48. data/spec/unit/border/ascii/rendering_spec.rb +0 -88
  49. data/spec/unit/border/new_spec.rb +0 -25
  50. data/spec/unit/border/null/rendering_spec.rb +0 -128
  51. data/spec/unit/border/options/from_spec.rb +0 -36
  52. data/spec/unit/border/options/new_spec.rb +0 -12
  53. data/spec/unit/border/unicode/rendering_spec.rb +0 -61
  54. data/spec/unit/border_options/new_spec.rb +0 -18
  55. data/spec/unit/border_options/update_spec.rb +0 -16
  56. data/spec/unit/column_constraint/enforce_spec.rb +0 -68
  57. data/spec/unit/column_constraint/widths_spec.rb +0 -33
  58. data/spec/unit/columns/extract_widths_spec.rb +0 -41
  59. data/spec/unit/columns/total_width_spec.rb +0 -11
  60. data/spec/unit/columns/widths_from_spec.rb +0 -49
  61. data/spec/unit/data_spec.rb +0 -10
  62. data/spec/unit/each_spec.rb +0 -24
  63. data/spec/unit/each_with_index_spec.rb +0 -49
  64. data/spec/unit/empty_spec.rb +0 -21
  65. data/spec/unit/eql_spec.rb +0 -32
  66. data/spec/unit/field/equality_spec.rb +0 -49
  67. data/spec/unit/field/length_spec.rb +0 -33
  68. data/spec/unit/field/lines_spec.rb +0 -19
  69. data/spec/unit/field/new_spec.rb +0 -27
  70. data/spec/unit/field/width_spec.rb +0 -21
  71. data/spec/unit/filter_spec.rb +0 -20
  72. data/spec/unit/header/call_spec.rb +0 -28
  73. data/spec/unit/header/color_spec.rb +0 -17
  74. data/spec/unit/header/equality_spec.rb +0 -49
  75. data/spec/unit/header/height_spec.rb +0 -25
  76. data/spec/unit/header/new_spec.rb +0 -13
  77. data/spec/unit/header/set_spec.rb +0 -18
  78. data/spec/unit/header/to_ary_spec.rb +0 -12
  79. data/spec/unit/header_spec.rb +0 -11
  80. data/spec/unit/indentation/indent_spec.rb +0 -15
  81. data/spec/unit/new_spec.rb +0 -71
  82. data/spec/unit/operation/alignment/call_spec.rb +0 -37
  83. data/spec/unit/operation/escape/call_spec.rb +0 -13
  84. data/spec/unit/operation/filter/call_spec.rb +0 -14
  85. data/spec/unit/operation/truncation/call_spec.rb +0 -28
  86. data/spec/unit/operation/wrapped/call_spec.rb +0 -38
  87. data/spec/unit/operations/new_spec.rb +0 -28
  88. data/spec/unit/options/access_spec.rb +0 -12
  89. data/spec/unit/options_spec.rb +0 -23
  90. data/spec/unit/orientation_spec.rb +0 -143
  91. data/spec/unit/padding_spec.rb +0 -115
  92. data/spec/unit/properties_spec.rb +0 -23
  93. data/spec/unit/render_repeat_spec.rb +0 -39
  94. data/spec/unit/render_spec.rb +0 -61
  95. data/spec/unit/render_with_spec.rb +0 -104
  96. data/spec/unit/renderer/ascii/coloring_spec.rb +0 -83
  97. data/spec/unit/renderer/ascii/indentation_spec.rb +0 -39
  98. data/spec/unit/renderer/ascii/multiline_spec.rb +0 -99
  99. data/spec/unit/renderer/ascii/padding_spec.rb +0 -115
  100. data/spec/unit/renderer/ascii/render_spec.rb +0 -66
  101. data/spec/unit/renderer/ascii/resizing_spec.rb +0 -112
  102. data/spec/unit/renderer/ascii/separator_spec.rb +0 -38
  103. data/spec/unit/renderer/basic/alignment_spec.rb +0 -86
  104. data/spec/unit/renderer/basic/coloring_spec.rb +0 -59
  105. data/spec/unit/renderer/basic/extract_column_widths_spec.rb +0 -26
  106. data/spec/unit/renderer/basic/filter_spec.rb +0 -51
  107. data/spec/unit/renderer/basic/indentation_spec.rb +0 -46
  108. data/spec/unit/renderer/basic/multiline_spec.rb +0 -72
  109. data/spec/unit/renderer/basic/new_spec.rb +0 -24
  110. data/spec/unit/renderer/basic/options_spec.rb +0 -50
  111. data/spec/unit/renderer/basic/padding_spec.rb +0 -74
  112. data/spec/unit/renderer/basic/render_spec.rb +0 -55
  113. data/spec/unit/renderer/basic/resizing_spec.rb +0 -94
  114. data/spec/unit/renderer/basic/separator_spec.rb +0 -41
  115. data/spec/unit/renderer/basic/single_row_separator_spec.rb +0 -80
  116. data/spec/unit/renderer/basic/truncation_spec.rb +0 -33
  117. data/spec/unit/renderer/basic/wrapping_spec.rb +0 -38
  118. data/spec/unit/renderer/border_spec.rb +0 -102
  119. data/spec/unit/renderer/render_spec.rb +0 -34
  120. data/spec/unit/renderer/select_spec.rb +0 -20
  121. data/spec/unit/renderer/unicode/coloring_spec.rb +0 -68
  122. data/spec/unit/renderer/unicode/indentation_spec.rb +0 -39
  123. data/spec/unit/renderer/unicode/padding_spec.rb +0 -59
  124. data/spec/unit/renderer/unicode/render_spec.rb +0 -66
  125. data/spec/unit/renderer/unicode/separator_spec.rb +0 -36
  126. data/spec/unit/renderer_spec.rb +0 -17
  127. data/spec/unit/rotate_spec.rb +0 -84
  128. data/spec/unit/row/access_spec.rb +0 -23
  129. data/spec/unit/row/call_spec.rb +0 -43
  130. data/spec/unit/row/data_spec.rb +0 -24
  131. data/spec/unit/row/each_spec.rb +0 -29
  132. data/spec/unit/row/equality_spec.rb +0 -71
  133. data/spec/unit/row/height_spec.rb +0 -25
  134. data/spec/unit/row/new_spec.rb +0 -39
  135. data/spec/unit/row/to_ary_spec.rb +0 -12
  136. data/spec/unit/to_s_spec.rb +0 -56
  137. data/spec/unit/transformation/extract_tuples_spec.rb +0 -33
  138. data/spec/unit/utf_spec.rb +0 -31
  139. data/spec/unit/validatable/validate_options_spec.rb +0 -31
  140. data/spec/unit/validatable_spec.rb +0 -30
  141. data/tasks/console.rake +0 -11
  142. data/tasks/coverage.rake +0 -11
  143. data/tasks/spec.rake +0 -29
  144. data/tty-table.gemspec +0 -41
@@ -1 +1 @@
1
- require_relative 'tty/table'
1
+ require_relative "tty/table"
@@ -1,24 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'equatable'
4
- require 'forwardable'
5
- require 'necromancer'
6
-
7
- require_relative 'table/columns'
8
- require_relative 'table/header'
9
- require_relative 'table/orientation'
10
- require_relative 'table/row'
11
- require_relative 'table/renderer'
12
- require_relative 'table/transformation'
13
- require_relative 'table/validatable'
14
- require_relative 'table/version'
3
+ require "forwardable"
4
+
5
+ require_relative "table/columns"
6
+ require_relative "table/header"
7
+ require_relative "table/orientation"
8
+ require_relative "table/row"
9
+ require_relative "table/renderer"
10
+ require_relative "table/transformation"
11
+ require_relative "table/validatable"
12
+ require_relative "table/version"
15
13
 
16
14
  module TTY
17
15
  # A core class intended for storing data in a structured, tabular form.
18
16
  # Once the data is stored in a TTY::Table various operations can be performed
19
17
  # before the information is dumped into a stdout.
20
18
  class Table
21
- include Comparable, Enumerable, Validatable, Equatable
19
+ include Comparable, Enumerable, Validatable
22
20
  extend Forwardable
23
21
 
24
22
  # The table header
@@ -64,7 +62,7 @@ module TTY
64
62
  # Create a new Table where each argument is a row
65
63
  #
66
64
  # @example
67
- # table = TTY::Table[['a1', 'a2'], ['b1', 'b2']]
65
+ # table = TTY::Table[["a1", "a2"], ["b1", "b2"]]
68
66
  #
69
67
  # @api public
70
68
  def self.[](*rows)
@@ -74,18 +72,18 @@ module TTY
74
72
  # Instantiate a new Table
75
73
  #
76
74
  # @example of no header
77
- # table = Table.new [['a1', 'a2'], ['b1', 'b2']]
75
+ # table = Table.new [["a1", "a2"], ["b1", "b2"]]
78
76
  #
79
77
  # @example of direct parameters
80
- # rows = [['a1', 'a2'], ['b1', 'b2']]
81
- # table = Table.new ['Header 1', 'Header 2'], rows
78
+ # rows = [["a1", "a2"], ["b1", "b2"]]
79
+ # table = Table.new ["Header 1", "Header 2"], rows
82
80
  #
83
81
  # @example of parameters passed as options
84
- # rows = [['a1', 'a2'], ['b1', 'b2']]
85
- # table = Table.new header: ['Header 1', 'Header 2'], rows: rows
82
+ # rows = [["a1", "a2"], ["b1", "b2"]]
83
+ # table = Table.new header: ["Header 1", "Header 2"], rows: rows
86
84
  #
87
85
  # @example of parameters passed as hash
88
- # Table.new [{'Header1' => ['a1','a2'], 'Header2' => ['b1', 'b2'] }]}
86
+ # Table.new [{"Header1" => ["a1","a2"], "Header2" => ["b1", "b2"] }]}
89
87
  #
90
88
  # @param [Array[Symbol], Hash] args
91
89
  #
@@ -115,7 +113,6 @@ module TTY
115
113
  # @api private
116
114
  def initialize(options = {}, &block)
117
115
  validate_options! options
118
- @converter = Necromancer.new
119
116
  @header = (value = options[:header]) ? Header.new(value) : nil
120
117
  @rows = coerce(options.fetch(:rows) { Row.new([]) })
121
118
  @rotated = false
@@ -204,10 +201,10 @@ module TTY
204
201
  # @param [Integer] column_index
205
202
  #
206
203
  # @example
207
- # table = TTY::Table.new [['a1','a2'], ['b1','b2']]
208
- # table[0] # => ['a1','a2']
209
- # table[0,0] # => 'a1'
210
- # table[-1] # => ['b1','b2']
204
+ # table = TTY::Table.new [["a1","a2"], ["b1","b2"]]
205
+ # table[0] # => ["a1","a2"]
206
+ # table[0,0] # => "a1"
207
+ # table[-1] # => ["b1","b2"]
211
208
  #
212
209
  # @api public
213
210
  def [](row_index, column_index = false)
@@ -215,12 +212,12 @@ module TTY
215
212
  if row_index >= 0 && column_index >= 0
216
213
  rows.fetch(row_index) { return nil }[column_index]
217
214
  else
218
- fail TTY::Table::TupleMissing.new(row_index, column_index)
215
+ raise TTY::Table::TupleMissing.new(row_index, column_index)
219
216
  end
220
217
  end
221
- alias_method :at, :[]
222
- alias_method :element, :[]
223
- alias_method :component, :[]
218
+ alias at []
219
+ alias element []
220
+ alias component []
224
221
 
225
222
  # Set table value at row(i) and column(j)
226
223
  #
@@ -234,7 +231,7 @@ module TTY
234
231
  # When a block is given, the elements of that Array are iterated over.
235
232
  #
236
233
  # @example
237
- # rows = [['a1', 'a2'], ['b1', 'b2']]
234
+ # rows = [["a1", "a2"], ["b1", "b2"]]
238
235
  # table = TTY::Table.new rows: rows
239
236
  # table.row(1) { |row| ... }
240
237
  #
@@ -261,7 +258,7 @@ module TTY
261
258
  #
262
259
  # @example
263
260
  # header = [:h1, :h2]
264
- # rows = [ ['a1', 'a2'], ['b1', 'b2'] ]
261
+ # rows = [ ["a1", "a2"], ["b1", "b2"] ]
265
262
  # table = TTY::Table.new :rows => rows, :header => header
266
263
  # table.column(1)
267
264
  # table.column(1) { |element| ... }
@@ -298,8 +295,7 @@ module TTY
298
295
  if row == Border::SEPARATOR
299
296
  separators << columns_size - (header ? 0 : 2)
300
297
  else
301
- rows_copy = rows.dup
302
- assert_row_sizes rows_copy << row
298
+ assert_row_size(row, rows)
303
299
  rows << to_row(row)
304
300
  end
305
301
  self
@@ -480,7 +476,7 @@ module TTY
480
476
  # @api public
481
477
  def coerce(rows)
482
478
  coerced_rows = []
483
- @converter.convert(rows).to(:array).each do |row|
479
+ Array(rows).each do |row|
484
480
  if row == Border::SEPARATOR
485
481
  separators << coerced_rows.length - (header ? 0 : 1)
486
482
  else
@@ -490,6 +486,46 @@ module TTY
490
486
  coerced_rows
491
487
  end
492
488
 
489
+ # Compare table for equality of header and rows attributes
490
+ #
491
+ # @return [Boolean]
492
+ #
493
+ # @api public
494
+ def eql?(other)
495
+ instance_of?(other.class) &&
496
+ header.eql?(other.header) && rows.eql?(other.rows)
497
+ end
498
+
499
+ # Compare table for equivalence of header and rows attributes
500
+ #
501
+ # @return [Boolean]
502
+ #
503
+ # @api public
504
+ def ==(other)
505
+ other.is_a?(self.class) &&
506
+ header == other.header && rows == other.rows
507
+ end
508
+
509
+ # Inspect this instance attributes
510
+ #
511
+ # @return [String]
512
+ #
513
+ # @api public
514
+ def inspect
515
+ "#<#{self.class.name} header=#{header.inspect} rows=#{rows.inspect} " \
516
+ "original_rows=#{original_rows.inspect} " \
517
+ "original_columns=#{original_columns.inspect}>"
518
+ end
519
+
520
+ # Hash for this instance and its attributes
521
+ #
522
+ # @return [Numeric]
523
+ #
524
+ # @api public
525
+ def hash
526
+ [self.class, header, rows].hash
527
+ end
528
+
493
529
  private
494
530
 
495
531
  # Evaluate block
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'necromancer'
4
-
5
3
  module TTY
6
4
  class Table
7
5
  # A class responsible for column alignments
@@ -19,7 +17,7 @@ module TTY
19
17
  #
20
18
  # @api private
21
19
  def initialize(alignments)
22
- @alignments = Necromancer.convert(alignments).to(:array).map(&:to_sym)
20
+ @alignments = Array(alignments).map(&:to_sym)
23
21
  end
24
22
 
25
23
  # Iterate over each element in the alignment set
@@ -1,23 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'equatable'
4
- require 'pastel'
5
- require 'strings'
3
+ require "pastel"
4
+ require "strings"
6
5
 
7
- require_relative 'border_options'
8
- require_relative 'border_dsl'
9
- require_relative 'border/row_line'
10
- require_relative 'error'
6
+ require_relative "border_dsl"
7
+ require_relative "border/row_line"
8
+ require_relative "error"
11
9
 
12
10
  module TTY
13
11
  class Table
14
12
  # Abstract base class that is responsible for building the table border.
15
13
  class Border
16
- include Equatable
14
+ EMPTY_CHAR = ""
17
15
 
18
- EMPTY_CHAR = ''.freeze
19
-
20
- SPACE_CHAR = ' '.freeze
16
+ SPACE_CHAR = " "
21
17
 
22
18
  # Represent a separtor on each row
23
19
  EACH_ROW = :each_row
@@ -32,39 +28,40 @@ module TTY
32
28
  attr_accessor :characters
33
29
  end
34
30
 
31
+ # Define border characters
32
+ #
33
+ # @param [Hash] characters
34
+ # the border characters
35
+ #
36
+ # @return [Hash]
37
+ #
38
+ # @api public
39
+ def self.def_border(characters = (not_set = true), &block)
40
+ return self.characters = characters unless not_set
41
+
42
+ dsl = BorderDSL.new(&block)
43
+ self.characters = dsl.characters
44
+ end
45
+
35
46
  # Instantiate a new object
36
47
  #
37
48
  # @param [Array] column_widths
38
49
  # the table column widths
39
50
  #
40
- # @param [BorderOptions] options
51
+ # @param [BorderOptions] border_opts
41
52
  #
42
53
  # @return [Object]
43
54
  #
44
55
  # @api private
45
- def initialize(column_widths, options = nil)
56
+ def initialize(column_widths, border_opts = nil)
46
57
  if self.class == Border
47
- fail NotImplementedError, "#{self} is an abstract class"
48
- else
49
- @widths = column_widths
50
- @border_options = TTY::Table::BorderOptions.from options
51
- @color = Pastel.new
58
+ raise NotImplementedError, "#{self} is an abstract class"
52
59
  end
53
- end
54
-
55
- # Define border characters
56
- #
57
- # @param [Hash] characters
58
- # the border characters
59
- #
60
- # @return [Hash]
61
- #
62
- # @api public
63
- def self.def_border(characters=(not_set=true), &block)
64
- return self.characters = characters unless not_set
65
60
 
66
- dsl = TTY::Table::BorderDSL.new(&block)
67
- self.characters = dsl.characters
61
+ @widths = column_widths
62
+ @dsl = BorderDSL.new(border_opts)
63
+ @characters = self.class.characters.merge(@dsl.characters)
64
+ @color = Pastel.new
68
65
  end
69
66
 
70
67
  # Retrive individual character by type
@@ -76,13 +73,7 @@ module TTY
76
73
  #
77
74
  # @api private
78
75
  def [](type)
79
- characters = self.class.characters
80
- chars = if border_options.nil?
81
- characters
82
- else
83
- characters.merge(border_options.characters)
84
- end
85
- chars[type] || EMPTY_CHAR
76
+ @characters[type] || EMPTY_CHAR
86
77
  end
87
78
 
88
79
  # Check if border color is set
@@ -91,7 +82,7 @@ module TTY
91
82
  #
92
83
  # @api public
93
84
  def color?
94
- border_options && border_options.style
85
+ !!@dsl.style
95
86
  end
96
87
 
97
88
  # A line spanning all columns marking top of a table.
@@ -117,7 +108,7 @@ module TTY
117
108
  # @return [String]
118
109
  #
119
110
  # @api private
120
- def separator
111
+ def middle_line
121
112
  (result = render(:mid)).empty? ? nil : result
122
113
  end
123
114
 
@@ -130,30 +121,27 @@ module TTY
130
121
  #
131
122
  # @api public
132
123
  def row_line(row)
133
- line = RowLine.new(self['left'], self['center'], self['right'])
134
- line.colorize(self, border_options.style) if color?
124
+ line = RowLine.new(self["left"], self["center"], self["right"])
125
+ line.colorize(self, @dsl.style) if color?
135
126
 
136
127
  result = row_heights(row, line)
137
128
  result.empty? ? EMPTY_CHAR : result
138
129
  end
139
130
 
140
- # Set color on characters
131
+ # Set color for a string
141
132
  #
142
133
  # @param [Symbol] color
143
134
  #
144
- # @param [Array[String]] strings array of strings
135
+ # @param [String] string
136
+ # the string to color
145
137
  #
146
- # @return [Array[String]]
138
+ # @return [String]
147
139
  #
148
140
  # @api public
149
- def set_color(color, *strings)
150
- strings.map do |string|
151
- if string.gsub(/\s+/, '').empty?
152
- string
153
- else
154
- @color.decorate(string, color)
155
- end
156
- end
141
+ def set_color(color, string)
142
+ return string if string.gsub(/\s+/, EMPTY_CHAR).empty?
143
+
144
+ @color.decorate(string, color)
157
145
  end
158
146
 
159
147
  protected
@@ -166,7 +154,9 @@ module TTY
166
154
  # The table custom border options including styling
167
155
  #
168
156
  # @api private
169
- attr_reader :border_options
157
+ def border_options
158
+ @dsl.options
159
+ end
170
160
 
171
161
  # Separate multiline string into individual rows with border.
172
162
  #
@@ -210,7 +200,9 @@ module TTY
210
200
  # Generate particular border type
211
201
  #
212
202
  # @param [String] type
213
- # border type one of [:top, :bottom, :mid]
203
+ # border type one of :top, :bottom and :mid
204
+ #
205
+ # @return [String]
214
206
  #
215
207
  # @api private
216
208
  def render(type)
@@ -222,7 +214,8 @@ module TTY
222
214
  self["#{type}_mid"])
223
215
 
224
216
  return line unless color?
225
- set_color(border_options.style, line).join
217
+
218
+ set_color(@dsl.style, line)
226
219
  end
227
220
 
228
221
  # Generate a border string
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../border'
3
+ require_relative "../border"
4
4
 
5
5
  module TTY
6
6
  class Table
@@ -11,21 +11,21 @@ module TTY
11
11
  class ASCII < Border
12
12
 
13
13
  def_border do
14
- top '-'
15
- top_mid '+'
16
- top_left '+'
17
- top_right '+'
18
- bottom '-'
19
- bottom_mid '+'
20
- bottom_left '+'
21
- bottom_right '+'
22
- mid '-'
23
- mid_mid '+'
24
- mid_left '+'
25
- mid_right '+'
26
- left '|'
27
- center '|'
28
- right '|'
14
+ top "-"
15
+ top_mid "+"
16
+ top_left "+"
17
+ top_right "+"
18
+ bottom "-"
19
+ bottom_mid "+"
20
+ bottom_left "+"
21
+ bottom_right "+"
22
+ mid "-"
23
+ mid_mid "+"
24
+ mid_left "+"
25
+ mid_right "+"
26
+ left "|"
27
+ center "|"
28
+ right "|"
29
29
  end
30
30
 
31
31
  end # ASCII
@@ -1,38 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../border'
3
+ require_relative "../border"
4
4
 
5
5
  module TTY
6
6
  class Table
7
7
  class Border
8
8
  # A class that represents no border.
9
9
  class Null < Border
10
-
11
10
  def_border do
12
- center SPACE_CHAR
13
- end
14
-
15
- # A stub top line
16
- #
17
- # @api private
18
- def top_line
19
- border_options ? super : nil
20
- end
21
-
22
- # A stub separator line
23
- #
24
- # @api private
25
- def separator
26
- return [] if border_options.separator # == EACH_ROW #TODO ask about this looks broken.
27
- # how could border_options ever be nil, if we just did border_options.separator
28
- border_options ? super : nil
11
+ top EMPTY_CHAR
12
+ top_mid EMPTY_CHAR
13
+ top_left EMPTY_CHAR
14
+ top_right EMPTY_CHAR
15
+ bottom EMPTY_CHAR
16
+ bottom_mid EMPTY_CHAR
17
+ bottom_left EMPTY_CHAR
18
+ bottom_right EMPTY_CHAR
19
+ mid EMPTY_CHAR
20
+ mid_mid EMPTY_CHAR
21
+ mid_left EMPTY_CHAR
22
+ mid_right EMPTY_CHAR
23
+ left EMPTY_CHAR
24
+ center SPACE_CHAR
25
+ right EMPTY_CHAR
29
26
  end
30
27
 
31
- # A stub bottom line
28
+ # A stub middle line
32
29
  #
33
30
  # @api private
34
- def bottom_line
35
- border_options ? super : nil
31
+ def middle_line
32
+ border_options.separator ? "" : super
36
33
  end
37
34
  end # Null
38
35
  end # Border