Class: String

Inherits:
Object show all
Defined in:
lib/arql/ext/string.rb

Instance Method Summary collapse

Instance Method Details

#expaObject



6
7
8
# File 'lib/arql/ext/string.rb', line 6

def expa
  File.expand_path(self)
end

#fObject



10
11
12
# File 'lib/arql/ext/string.rb', line 10

def f
  expa
end

#pObject



2
3
4
# File 'lib/arql/ext/string.rb', line 2

def p
  puts self
end

#parseObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/arql/ext/string.rb', line 38

def parse
  if File.file?(File.expand_path(self))
    if self =~ /\.xlsx?$/i
      parse_excel
    elsif self =~ /\.csv$/i
      parse_csv
    elsif self =~ /\.json$/i
      parse_json
    else
      raise "File type not supported: #{self}"
    end
  else
    raise "File not found: #{self}"
  end
end

#parse_csvObject



22
23
24
25
26
27
28
# File 'lib/arql/ext/string.rb', line 22

def parse_csv
  if File.file?(File.expand_path(self))
    Kernel.parse_csv(File.expand_path(self))
  else
    raise "File not found: #{self}"
  end
end

#parse_excelObject



14
15
16
17
18
19
20
# File 'lib/arql/ext/string.rb', line 14

def parse_excel
  if File.file?(File.expand_path(self))
    Kernel.parse_excel(File.expand_path(self))
  else
    raise "File not found: #{self}"
  end
end

#parse_jsonObject



30
31
32
33
34
35
36
# File 'lib/arql/ext/string.rb', line 30

def parse_json
  if File.file?(File.expand_path(self))
    Kernel.parse_json(File.expand_path(self))
  else
    raise "File not found: #{self}"
  end
end