Class: SportDb::GroundReader
- Inherits:
-
Object
- Object
- SportDb::GroundReader
show all
- Includes:
- LogUtils::Logging, Model
- Defined in:
- lib/sportdb/readers/ground.rb
Constant Summary
Constants included
from Model
Model::City, Model::Continent, Model::Country, Model::Person, Model::Prop, Model::State
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(text, more_attribs = {}) ⇒ GroundReader
Returns a new instance of GroundReader.
36
37
38
39
40
|
# File 'lib/sportdb/readers/ground.rb', line 36
def initialize( text, more_attribs={} )
@text = text
@more_attribs = more_attribs
end
|
Class Method Details
.from_file(path, more_attribs = {}) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/sportdb/readers/ground.rb', line 24
def self.from_file( path, more_attribs={} )
text = File.read_utf8( path )
self.from_string( text, more_attribs )
end
|
.from_string(text, more_attribs = {}) ⇒ Object
31
32
33
|
# File 'lib/sportdb/readers/ground.rb', line 31
def self.from_string( text, more_attribs={} )
GroundReader.new( text, more_attribs )
end
|
.from_zip(zip_file, entry_path, more_attribs = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/sportdb/readers/ground.rb', line 14
def self.from_zip( zip_file, entry_path, more_attribs={} )
entry = zip_file.find_entry( entry_path )
text = entry.get_input_stream().read()
text = text.force_encoding( Encoding::UTF_8 )
self.from_string( text, more_attribs )
end
|
Instance Method Details
#read ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/sportdb/readers/ground.rb', line 43
def read
reader = ValuesReader.from_string( @text, @more_attribs )
reader.each_line do |new_attributes, values|
Ground.create_or_update_from_values( new_attributes, values )
end end
|