Class: CSVPlusPlus::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_plus_plus/row.rb

Overview

A row of a template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, cells, modifier) ⇒ Row

Returns a new instance of Row.

Parameters:

  • index (Integer)

    The index of this row (starts at 0)

  • cells (Array<Cell>)

    The cells belonging to this row

  • modifier (Modifier)

    The modifier to apply to all cells in this row



15
16
17
18
19
# File 'lib/csv_plus_plus/row.rb', line 15

def initialize(index, cells, modifier)
  @cells = cells
  @modifier = modifier
  @index = index
end

Instance Attribute Details

#cellsArray<Cell> (readonly)

Returns the current value of cells.

Returns:

  • (Array<Cell>)

    the current value of cells



9
10
11
# File 'lib/csv_plus_plus/row.rb', line 9

def cells
  @cells
end

#indexInteger

The index of this row

Returns:

  • (Integer)

    the current value of index



9
10
11
# File 'lib/csv_plus_plus/row.rb', line 9

def index
  @index
end

#modifierModifier (readonly)

The modifier to apply to all cells in this row

Returns:

  • (Modifier)

    the current value of modifier



9
10
11
# File 'lib/csv_plus_plus/row.rb', line 9

def modifier
  @modifier
end

Instance Method Details

#deep_cloneRow

Return a deep copy of this row

Returns:



46
47
48
# File 'lib/csv_plus_plus/row.rb', line 46

def deep_clone
  ::Marshal.load(::Marshal.dump(self))
end

#expand_amountInteger

How much this row will expand itself, if at all (0)

Returns:

  • (Integer)


32
33
34
35
36
# File 'lib/csv_plus_plus/row.rb', line 32

def expand_amount
  return 0 unless @modifier.expand

  @modifier.expand.repetitions || (1000 - @index)
end

#to_sString

Returns:

  • (String)


39
40
41
# File 'lib/csv_plus_plus/row.rb', line 39

def to_s
  "Row(index: #{index}, modifier: #{modifier}, cells: #{cells})"
end