Sha256: 9115f8d2202a7e9a05b8472c06790709b031bf4cff16a0739864c2f0419d813e

Contents?: true

Size: 954 Bytes

Versions: 1

Compression:

Stored size: 954 Bytes

Contents

class String
  def p
    puts self
  end

  def expa
    File.expand_path(self)
  end

  def f
    expa
  end

  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

  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

  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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arql-0.3.23 lib/arql/ext/string.rb