Class: CsvRowModel::Model::Header

Inherits:
Object
  • Object
show all
Includes:
ColumnShared
Defined in:
lib/csv_row_model/internal/model/header.rb

Direct Known Subclasses

DynamicColumnHeader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ColumnShared

#options

Constructor Details

#initialize(column_name, row_model_class, context) ⇒ Header

Returns a new instance of Header


10
11
12
13
14
# File 'lib/csv_row_model/internal/model/header.rb', line 10

def initialize(column_name, row_model_class, context)
  @column_name = column_name
  @row_model_class = row_model_class
  @context = OpenStruct.new(context)
end

Instance Attribute Details

#column_nameObject (readonly)

Returns the value of attribute column_name


8
9
10
# File 'lib/csv_row_model/internal/model/header.rb', line 8

def column_name
  @column_name
end

#contextObject (readonly)

Returns the value of attribute context


8
9
10
# File 'lib/csv_row_model/internal/model/header.rb', line 8

def context
  @context
end

#row_model_classObject (readonly)

Returns the value of attribute row_model_class


8
9
10
# File 'lib/csv_row_model/internal/model/header.rb', line 8

def row_model_class
  @row_model_class
end

Class Method Details

.valid_optionsObject


25
26
27
# File 'lib/csv_row_model/internal/model/header.rb', line 25

def valid_options
  %i[header]
end

Instance Method Details

#formatted_headerObject


20
21
22
# File 'lib/csv_row_model/internal/model/header.rb', line 20

def formatted_header
  row_model_class.format_header(column_name, context)
end

#valueObject


16
17
18
# File 'lib/csv_row_model/internal/model/header.rb', line 16

def value
  options[:header] || formatted_header
end