Class: AsCSV::CSVBuilder
- Inherits:
-
Object
- Object
- AsCSV::CSVBuilder
- Defined in:
- lib/as_csv/csv_builder.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(records, options = {}) ⇒ CSVBuilder
constructor
A new instance of CSVBuilder.
- #to_csv ⇒ Object
Constructor Details
#initialize(records, options = {}) ⇒ CSVBuilder
Returns a new instance of CSVBuilder.
7 8 9 10 11 |
# File 'lib/as_csv/csv_builder.rb', line 7 def initialize(records, ={}) @records = Array(records) @options = validate end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/as_csv/csv_builder.rb', line 5 def @options end |
#records ⇒ Object (readonly)
Returns the value of attribute records.
5 6 7 |
# File 'lib/as_csv/csv_builder.rb', line 5 def records @records end |
Instance Method Details
#to_csv ⇒ Object
13 14 15 |
# File 'lib/as_csv/csv_builder.rb', line 13 def to_csv rows.collect { |row| CSV.generate_line row }.join end |