Sha256: d1fc345c4eb9462243d086bd344f62774bc22675e67ab48e39e1ba300e4905a2
Contents?: true
Size: 536 Bytes
Versions: 1
Compression:
Stored size: 536 Bytes
Contents
require 'sway/base' require 'active_support' require 'csv' module Sway class CSV < Sway::Base def initialize(csv, *options) extracted_options = options.extract_options! without_header = !(extracted_options[:header] == :first_line) raise "CSV can't be moshed without a header." if without_header lines = ::CSV.new(csv) key = lines.first values = lines.map {|line| line} array = values.inject([]) {|key_value, value| key_value << Hash[key.zip(value)]} super(array) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sway-0.0.1 | lib/sway/csv.rb |