Class: Csvbuilder::Model::Header
- Inherits:
-
Object
- Object
- Csvbuilder::Model::Header
- Includes:
- ColumnShared
- Defined in:
- lib/csvbuilder/core/internal/model/header.rb
Instance Attribute Summary collapse
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#row_model_class ⇒ Object
readonly
Returns the value of attribute row_model_class.
Instance Method Summary collapse
- #formatted_header(header_name) ⇒ Object
-
#initialize(column_name, row_model_class, context) ⇒ Header
constructor
A new instance of Header.
- #value ⇒ Object
Methods included from ColumnShared
Constructor Details
#initialize(column_name, row_model_class, context) ⇒ Header
Returns a new instance of Header.
12 13 14 15 16 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 12 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_name ⇒ Object (readonly)
Returns the value of attribute column_name.
10 11 12 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 10 def column_name @column_name end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 10 def context @context end |
#row_model_class ⇒ Object (readonly)
Returns the value of attribute row_model_class.
10 11 12 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 10 def row_model_class @row_model_class end |
Instance Method Details
#formatted_header(header_name) ⇒ Object
29 30 31 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 29 def formatted_header(header_name) row_model_class.format_header(header_name, context) end |
#value ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/csvbuilder/core/internal/model/header.rb', line 18 def value case [:header] when Proc return [:header].call(column_name, context) when String return [:header] end formatted_header(column_name.to_s.humanize) end |