Module: DaruLite::IOHelpers

Defined in:
lib/daru_lite/io/io.rb

Constant Summary collapse

INT_PATTERN =
/^[-+]?\d+$/
FLOAT_PATTERN =
/^[-+]?\d+[,.]?\d*(e-?\d+)?$/

Class Method Summary collapse

Class Method Details

.open_local_or_remote_file(path) ⇒ Object



23
24
25
26
# File 'lib/daru_lite/io/io.rb', line 23

def open_local_or_remote_file(path)
  uri = URI.parse(path)
  uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS) ? uri.open : File.open(uri.path)
end

.process_row(row, empty) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/daru_lite/io/io.rb', line 9

def process_row(row, empty)
  row.to_a.map do |c|
    if empty.include?(c)
      # FIXME: As far as I can guess, it will never work.
      # It is called only inside `from_plaintext`, and there
      # data is splitted by `\s+` -- there is no chance that
      # "empty" (currently just '') will be between data?..
      nil
    else
      try_string_to_number(c)
    end
  end
end