Class: TextDataTools::TextDataFile
- Inherits:
-
Object
- Object
- TextDataTools::TextDataFile
- Defined in:
- lib/text-data-tools.rb
Overview
This is a simple class which can interface with the methods of TextDataTools to prevent the user having to specify the file name and other properties of the data file for every call. In a nutshell, create a new instance of this class giving it the filename, and any appropriate options, then call methods from TextDataTools omitting the appropriate arguments.
Instance Method Summary collapse
- #exists? ⇒ Boolean
- #get_1d_array(column_header) ⇒ Object
- #get_1d_array_float(column_header) ⇒ Object
- #get_1d_array_integer(column_header) ⇒ Object
- #get_2d_array(column_header, index_header) ⇒ Object
- #get_2d_array_float(column_header, index_header) ⇒ Object
- #get_2d_array_integer(column_header, index_header) ⇒ Object
- #get_variable_value(name, sep) ⇒ Object
-
#initialize(filename, has_header_line = false, match = /\S+/, header_match = /\S+/) ⇒ TextDataFile
constructor
A new instance of TextDataFile.
Constructor Details
#initialize(filename, has_header_line = false, match = /\S+/, header_match = /\S+/) ⇒ TextDataFile
Returns a new instance of TextDataFile.
164 165 166 167 168 169 170 |
# File 'lib/text-data-tools.rb', line 164 def initialize(filename, has_header_line = false, match = /\S+/, header_match = /\S+/) @filename = filename @match = match @header_match = header_match @has_header_line = has_header_line self end |
Instance Method Details
#exists? ⇒ Boolean
192 193 194 |
# File 'lib/text-data-tools.rb', line 192 def exists? FileTest.exists?(@filename) end |
#get_1d_array(column_header) ⇒ Object
171 172 173 |
# File 'lib/text-data-tools.rb', line 171 def get_1d_array(column_header) TextDataTools.get_1d_array(@filename, @has_header_line, column_header, @match, @header_match) end |
#get_1d_array_float(column_header) ⇒ Object
174 175 176 |
# File 'lib/text-data-tools.rb', line 174 def get_1d_array_float(column_header) TextDataTools.get_1d_array_float(@filename, @has_header_line, column_header, @match, @header_match) end |
#get_1d_array_integer(column_header) ⇒ Object
177 178 179 |
# File 'lib/text-data-tools.rb', line 177 def get_1d_array_integer(column_header) TextDataTools.get_1d_array_integer(@filename, @has_header_line, column_header, @match, @header_match) end |
#get_2d_array(column_header, index_header) ⇒ Object
180 181 182 |
# File 'lib/text-data-tools.rb', line 180 def get_2d_array(column_header, index_header) TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match) end |
#get_2d_array_float(column_header, index_header) ⇒ Object
183 184 185 |
# File 'lib/text-data-tools.rb', line 183 def get_2d_array_float(column_header, index_header) TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match) end |
#get_2d_array_integer(column_header, index_header) ⇒ Object
186 187 188 |
# File 'lib/text-data-tools.rb', line 186 def get_2d_array_integer(column_header, index_header) TextDataTools.get_2d_array(@filename, @has_header_line, column_header, index_header, @match, @header_match) end |
#get_variable_value(name, sep) ⇒ Object
189 190 191 |
# File 'lib/text-data-tools.rb', line 189 def get_variable_value(name, sep) TextDataTools.get_variable_value(@filename, name, sep) end |