Class: RSpec::Variants::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/variants/table.rb

Defined Under Namespace

Classes: Row

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTable

Returns a new instance of Table.



6
7
8
9
# File 'lib/rspec/variants/table.rb', line 6

def initialize
  @rows = []
  @last_row = nil
end

Instance Attribute Details

#last_rowObject (readonly)

Returns the value of attribute last_row.



4
5
6
# File 'lib/rspec/variants/table.rb', line 4

def last_row
  @last_row
end

Instance Method Details

#add_condition_to_last_row(condition) ⇒ Object Also known as: |



19
20
21
22
# File 'lib/rspec/variants/table.rb', line 19

def add_condition_to_last_row(condition)
  last_row.add_condition(condition)
  self
end

#add_row(row) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/rspec/variants/table.rb', line 11

def add_row(row)
  unless @rows.find { |r| r.object_id == row.object_id }
    @rows << row
    @last_row = row
  end
  self
end

#to_aObject Also known as: to_conditions



26
27
28
# File 'lib/rspec/variants/table.rb', line 26

def to_a
  @rows.map(&:to_a)
end