Class: Mortadella::Horizontal

Inherits:
Object
  • Object
show all
Defined in:
lib/mortadella/horizontal.rb

Overview

Makes it easy to build DRY horizontal Cucumber-compatible tables

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers:, dry: []) ⇒ Horizontal

Returns a new instance of Horizontal.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/mortadella/horizontal.rb', line 9

def initialize headers:, dry: []
  @headers = headers

  @dry = dry

  # The resulting Cucumber-compatible table structure
  @table = [headers]

  # The previously added row
  @previous_row = nil
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



6
7
8
# File 'lib/mortadella/horizontal.rb', line 6

def table
  @table
end

Instance Method Details

#<<(row) ⇒ Object

Adds the given row to the table



23
24
25
26
# File 'lib/mortadella/horizontal.rb', line 23

def << row
  @table << dry_up(row)
  @previous_row = row
end

#empty?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/mortadella/horizontal.rb', line 29

def empty?
  @table.size == 1
end