Skip to content

Commit

Permalink
Require keyword params when initializing CellData and Position structs
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-harvey committed Mar 28, 2020
1 parent efecccc commit a6a28d7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/tabulo/cell_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module Tabulo
# @attr source [Object] The member of this {Cell}'s {Table}'s underlying enumerable from which
# this {Cell}'s {Row} was derived.
# @attr position [Position] The position of the {Cell} within the {Table}.
CellData = Struct.new(:source, :position)
CellData = Struct.new(:source, :position, keyword_init: true)

end
4 changes: 2 additions & 2 deletions lib/tabulo/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def header_cell

def body_cell(source, row_index:)
if body_cell_data_required?
position = Position.new(row_index, @index)
cell_data = CellData.new(source, position)
position = Position.new(row: row_index, column: @index)
cell_data = CellData.new(source: source, position: position)
end
Cell.new(
alignment: @align_body,
Expand Down
2 changes: 1 addition & 1 deletion lib/tabulo/position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module Tabulo
# {Table} has index 0, the next has index 1, etc..
# @attr column [Integer] The positional index of the {Cell}'s {Column}. The leftmost {Column}
# of the {Table} has index 0, the next has index 1, etc..
Position = Struct.new(:row, :column)
Position = Struct.new(:row, :column, keyword_init: true)

end
4 changes: 2 additions & 2 deletions spec/cell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
end

let(:formatter) { -> (source) { source.to_s } }
let(:position) { Tabulo::Position.new(5, 3) }
let(:position) { Tabulo::Position.new(row: 5, column: 3) }
let(:source) { "hi" }
let(:styler) { -> (source, str) { str } }
let(:value) { 30 }
let(:width) { 6 }
let(:cell_data) { Tabulo::CellData.new(source, position) }
let(:cell_data) { Tabulo::CellData.new(source: source, position: position) }

describe "#height" do
subject { cell.height }
Expand Down

0 comments on commit a6a28d7

Please sign in to comment.