Class: RXFRead::FileX

Inherits:
Object
  • Object
show all
Defined in:
lib/rxfreader.rb

Class Method Summary collapse

Class Method Details

.exists?(filename) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rxfreader.rb', line 18

def self.exists?(filename)

  type = FileX.filetype(filename)

  filex = case type
  when :file
    File
  when :dfs
    DfsFile
  else
    nil
  end

  return nil unless filex

  filex.exists? filename

end

.filetype(x) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/rxfreader.rb', line 38

def self.filetype(x)

  return :string if x.lines.length > 1

  case x
  when /^https?:\/\//
    :http
  when /^dfs:\/\//
    :dfs
  when /^file:\/\//
    :file
  else

    if File.exists?(x) then
      :file
    else
      :text
    end

  end
end

.read(x) ⇒ Object



60
61
62
# File 'lib/rxfreader.rb', line 60

def self.read(x)
  RXFReader.read(x).first
end