Class: Julia::Builder
- Inherits:
-
Object
- Object
- Julia::Builder
- Defined in:
- lib/julia/builder.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(collection) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(collection) ⇒ Builder
Returns a new instance of Builder.
7 8 9 |
# File 'lib/julia/builder.rb', line 7 def initialize(collection) @collection = collection end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
5 6 7 |
# File 'lib/julia/builder.rb', line 5 def collection @collection end |
Class Method Details
.column(keyname, action = nil) ⇒ Object
15 16 17 |
# File 'lib/julia/builder.rb', line 15 def self.column(keyname, action = nil) self.columns[keyname] = action end |
.columns ⇒ Object
11 12 13 |
# File 'lib/julia/builder.rb', line 11 def self.columns @columns ||= {} end |
Instance Method Details
#build ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/julia/builder.rb', line 19 def build CSV.generate do |csv| csv << columns.keys collection.each do |record| csv << columns.map do |key, action| get_value(record, key, action) end end end end |