Sha256: 33a72792a4fcd45d43a922eb4163c6cb20078efc3980ba67e7443c88a76c92ce

Contents?: true

Size: 730 Bytes

Versions: 7

Compression:

Stored size: 730 Bytes

Contents

module TimelineSetter
  class Parser
    attr_reader :events

    # Initialize a new timeline from a CSV file via TableFu,
    # add a hash for each row (event) in the sheet to an events array.
    # Sheet should contain columns for
    #  * date
    #  * display_date
    #  * description
    #  * link
    #  * thumbnail
    #  * series
    #  * html
    #
    def initialize(sheet)
      @events = []
      spreadsheet = TableFu.new(sheet) do |s|
        s.columns = %w[date display_date description link series html]
      end

      spreadsheet.rows.each do |row|
        hash = spreadsheet.columns.inject({}) {|memo, column| memo[column.to_sym] = row[column].to_s ; memo}
        @events << hash
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
timeline_setter-0.3.2 lib/timeline_setter/parser.rb
timeline_setter-0.3.1 lib/timeline_setter/parser.rb
timeline_setter-0.3.0 lib/timeline_setter/parser.rb
timeline_setter-0.2.0 lib/timeline_setter/parser.rb
timeline_setter-0.1.2 lib/timeline_setter/parser.rb
timeline_setter-0.1.1 lib/timeline_setter/parser.rb
timeline_setter-0.1.0 lib/timeline_setter/parser.rb