Class: EventDb::EventReader
- Inherits:
-
Object
- Object
- EventDb::EventReader
- Defined in:
- lib/eventdb/reader.rb
Defined Under Namespace
Classes: CsvParser, DatafileParser, Event, MarkdownParser, YamlParser
Class Method Summary collapse
Class Method Details
.read(path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/eventdb/reader.rb', line 13 def self.read( path ) txt = if path.start_with?( 'http://' ) || path.start_with?( 'https://' ) worker = Fetcher::Worker.new worker.read_utf8!( path ) else File.open( path, 'r:utf-8' ).read end parser = if path.end_with?( '.yml') || path.end_with?( '.yaml') YamlParser.new( txt ) elsif path.end_with?( '.csv') CsvParser.new( txt ) elsif path.end_with?( '.txt') DatafileParser.new( txt ) else MarkdownParser.new( txt ) end parser.parse end |