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

initialize



13
14
15
16
17
# File 'lib/csv_plus_plus/row.rb', line 13

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

Instance Attribute Details

#cellsObject (readonly)

Returns the value of attribute cells.



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

def cells
  @cells
end

#indexObject

Returns the value of attribute index.



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

def index
  @index
end

#modifierObject (readonly)

Returns the value of attribute modifier.



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

def modifier
  @modifier
end

Instance Method Details

#deep_cloneObject

Return a deep copy of this row



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

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

#expand_amountObject

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



26
27
28
29
30
# File 'lib/csv_plus_plus/row.rb', line 26

def expand_amount
  return 0 unless @modifier.expand

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

#to_sObject

to_s



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

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