Class: Csvbuilder::AttributeBase

Inherits:
Object
  • Object
show all
Includes:
ColumnShared
Defined in:
lib/csvbuilder/core/internal/attribute_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ColumnShared

#context, #options

Constructor Details

#initialize(column_name, row_model) ⇒ AttributeBase

Returns a new instance of AttributeBase.



11
12
13
14
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 11

def initialize(column_name, row_model)
  @column_name = column_name
  @row_model   = row_model
end

Instance Attribute Details

#column_nameObject (readonly)

Returns the value of attribute column_name.



9
10
11
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 9

def column_name
  @column_name
end

#row_modelObject (readonly)

Returns the value of attribute row_model.



9
10
11
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 9

def row_model
  @row_model
end

Instance Method Details

#formatted_valueObject

Returns the value with formatting applied.

Returns:

  • (Object)

    the value with formatting applied



17
18
19
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 17

def formatted_value
  @formatted_value ||= row_model_class.format_cell(source_value, column_name, row_model.context)
end

#source_valueObject

Returns the unchanged value from the source.

Returns:

  • (Object)

    the unchanged value from the source

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 27

def source_value
  raise NotImplementedError
end

#valueObject

Returns the value.

Returns:

  • (Object)

    the value

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/csvbuilder/core/internal/attribute_base.rb', line 22

def value
  raise NotImplementedError
end