Class: LpCSVExportable::CSVColumn
- Inherits:
-
Object
- Object
- LpCSVExportable::CSVColumn
- Defined in:
- lib/lp_csv_exportable/csv_column.rb
Instance Attribute Summary collapse
-
#default_value ⇒ Object
readonly
Returns the value of attribute default_value.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#model_method ⇒ Object
readonly
Returns the value of attribute model_method.
-
#model_methods ⇒ Object
readonly
Returns the value of attribute model_methods.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #format(result) ⇒ Object
-
#initialize(args = {}) ⇒ CSVColumn
constructor
A new instance of CSVColumn.
Constructor Details
#initialize(args = {}) ⇒ CSVColumn
Returns a new instance of CSVColumn.
5 6 7 8 9 10 11 12 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 5 def initialize(args = {}) @header = args[:header] @model_method = args[:model_method] @model_methods = args[:model_methods] @type = args.fetch(:type, :string) @default_value = args.fetch(:default_value, '') after_init(args) end |
Instance Attribute Details
#default_value ⇒ Object (readonly)
Returns the value of attribute default_value.
3 4 5 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 3 def default_value @default_value end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
3 4 5 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 3 def header @header end |
#model_method ⇒ Object (readonly)
Returns the value of attribute model_method.
3 4 5 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 3 def model_method @model_method end |
#model_methods ⇒ Object (readonly)
Returns the value of attribute model_methods.
3 4 5 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 3 def model_methods @model_methods end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 3 def type @type end |
Instance Method Details
#format(result) ⇒ Object
14 15 16 17 18 |
# File 'lib/lp_csv_exportable/csv_column.rb', line 14 def format(result) return formatted_result(result) if respond_to?(type) return default_value if use_default?(result) result end |