Class: WorldDb::ReaderBaseWithOpts
- Inherits:
-
Object
- Object
- WorldDb::ReaderBaseWithOpts
show all
- Includes:
- LogUtils::Logging, Models, TextUtils::ValueHelper
- Defined in:
- lib/worlddb/readers/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#is_state?, #match_city, #match_country, #match_metro, #match_metro_flag, #match_metro_pop, #match_state_for_country, #match_supra, #match_supra_flag
Constructor Details
Returns a new instance of ReaderBaseWithOpts.
137
138
139
140
141
142
143
144
|
# File 'lib/worlddb/readers/base.rb', line 137
def initialize( text, opts={} )
@text = text
@skip_tags = opts[:skip_tags].present? ? true : false
@strict = opts[:strict].present? ? true : false
end
|
Class Method Details
.from_file(path, opts = {}) ⇒ Object
121
122
123
124
125
126
|
# File 'lib/worlddb/readers/base.rb', line 121
def self.from_file( path, opts={} )
text = File.read_utf8( path )
self.from_string( text, opts )
end
|
.from_string(text, opts = {}) ⇒ Object
128
129
130
131
|
# File 'lib/worlddb/readers/base.rb', line 128
def self.from_string( text, opts={} )
puts "[debug] ReaderBase.from_string calling #{self.name}.new" self.new( text, opts )
end
|
.from_zip(zip_file, entry_path) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/worlddb/readers/base.rb', line 92
def self.from_zip( zip_file, entry_path )
entry = zip_file.find_entry( entry_path )
text = entry.get_input_stream().read()
logger = LogUtils::Logger.root
logger.debug "text.encoding.name (before): #{text.encoding.name}"
text = text.force_encoding( Encoding::UTF_8 )
logger.debug "text.encoding.name (after): #{text.encoding.name}"
self.from_string( text )
end
|
Instance Method Details
134
|
# File 'lib/worlddb/readers/base.rb', line 134
def skip_tags?() @skip_tags == true; end
|
#strict? ⇒ Boolean
135
|
# File 'lib/worlddb/readers/base.rb', line 135
def strict?() @strict == true; end
|