Class: Capybara::UI::TextTable

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Conversions, Enumerable
Defined in:
lib/capybara/ui/text_table.rb,
lib/capybara/ui/text_table/mapping.rb,
lib/capybara/ui/text_table/cell_text.rb,
lib/capybara/ui/text_table/void_mapping.rb,
lib/capybara/ui/text_table/transformations.rb

Defined Under Namespace

Modules: Transformations Classes: CellText, Mapping, VoidMapping

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Conversions

#Boolean, #List, #Timeish

Constructor Details

#initialize(table) ⇒ TextTable

Returns a new instance of TextTable.


75
76
77
# File 'lib/capybara/ui/text_table.rb', line 75

def initialize(table)
  self.table = table
end

Class Method Details

.Array(table) ⇒ Object


10
11
12
# File 'lib/capybara/ui/text_table.rb', line 10

def Array(table)
  new(table).to_a
end

.Hash(table) ⇒ Object


14
15
16
# File 'lib/capybara/ui/text_table.rb', line 14

def Hash(table)
  new(table).to_h
end

.map(name, options = {}, &block) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/capybara/ui/text_table.rb', line 18

def map(name, options = {}, &block)
  case name
  when :*
    set_default_mapping options, &block
  else
    set_mapping name, options, &block
  end
end

.mappingsObject


27
28
29
30
31
# File 'lib/capybara/ui/text_table.rb', line 27

def mappings
  @mappings ||= Hash.
   new { |h, k| h[k] = Mapping.new }.
   merge(with_parent_mappings)
end

.skip(name) ⇒ Object


33
34
35
36
37
38
39
40
# File 'lib/capybara/ui/text_table.rb', line 33

def skip(name)
  case name
  when :*
    set_default_mapping VoidMapping
  else
    raise ArgumentError, "can't convert #{name.inspect} to name"
  end
end

Instance Method Details

#each(&block) ⇒ Object


79
80
81
# File 'lib/capybara/ui/text_table.rb', line 79

def each(&block)
  rows.each(&block)
end

#rowsObject Also known as: to_a


83
84
85
# File 'lib/capybara/ui/text_table.rb', line 83

def rows
  @rows ||= table.hashes.map { |h| new_row(h) }
end

#single_rowObject Also known as: to_h


87
88
89
# File 'lib/capybara/ui/text_table.rb', line 87

def single_row
  @single_row ||= new_row(table.rows_hash)
end