Class: CSVPlusPlus::Cell

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/csv_plus_plus/cell.rb

Overview

A cell of a template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index:, modifier:, row_index:, value:) ⇒ Cell

Returns a new instance of Cell.

Parameters:

  • index (Integer)

    The cell’s index (starts at 0)

  • modifier (Modifier)

    A modifier to apply to this cell

  • row_index (Integer)

    The cell’s row index (starts at 0)

  • value (String)

    A string value which should already have been processed through a CSV parser



38
39
40
41
42
43
# File 'lib/csv_plus_plus/cell.rb', line 38

def initialize(index:, modifier:, row_index:, value:)
  @value = value
  @modifier = modifier
  @index = index
  @row_index = row_index
end

Instance Attribute Details

#astEntity?

The AST of the formula in the cell (if there is one)

Returns:

  • (Entity, nil)

    the current value of ast



11
12
13
# File 'lib/csv_plus_plus/cell.rb', line 11

def ast
  @ast
end

#indexInteger (readonly)

The cell’s index (starts at 0)

Returns:

  • (Integer)

    the current value of index



11
12
13
# File 'lib/csv_plus_plus/cell.rb', line 11

def index
  @index
end

#modifierModifier (readonly)

The modifier for this cell

Returns:

  • (Modifier)

    the current value of modifier



11
12
13
# File 'lib/csv_plus_plus/cell.rb', line 11

def modifier
  @modifier
end

#row_indexInteger

The cell’s row index (starts at 0)

Returns:

  • (Integer)

    the current value of row_index



11
12
13
# File 'lib/csv_plus_plus/cell.rb', line 11

def row_index
  @row_index
end

Instance Method Details

#value::String

The @value (cleaned up some)

Returns:

  • (::String)


49
50
51
52
53
# File 'lib/csv_plus_plus/cell.rb', line 49

def value
  stripped = @value&.strip

  stripped&.empty? ? nil : stripped
end