Class: Tran
Constant Summary
collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#all_rows, #calculated_rows
Constructor Details
#initialize(xml, options) ⇒ Tran
Returns a new instance of Tran.
15
16
17
18
|
# File 'lib/tran.rb', line 15
def initialize(xml, options)
@headers = options.fetch(:headers)
@xml = xml
end
|
Instance Attribute Details
Returns the value of attribute headers.
9
10
11
|
# File 'lib/tran.rb', line 9
def
@headers
end
|
Class Method Details
11
12
13
|
# File 'lib/tran.rb', line 11
def self.transform(xml, options)
new(xml, options).transform
end
|
Instance Method Details
#document ⇒ Object
29
30
31
|
# File 'lib/tran.rb', line 29
def document
@document ||= Ox.parse(@xml)
end
|
20
21
22
23
24
25
26
27
|
# File 'lib/tran.rb', line 20
def transform
CSV.generate(headers: true) do |csv|
csv << .values
calculated_rows.each do |row|
csv << row
end
end
end
|