Class: RXFHelperModule::FileX

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

Class Method Summary collapse

Class Method Details

.exists?(filename) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rxfhelper.rb', line 14

def self.exists?(filename)
  
  type = self.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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rxfhelper.rb', line 33

def self.filetype(x)
  
  return :string if x.lines.length > 1
  
  case x
  when /^rse:\/\//
    :rse
  when /^https?:\/\//
    :http
  when /^dfs:\/\//
    :dfs        
  when /^file:\/\//
    :file
  else
    
    if File.exists?(x) then
      :file
    else
      :text
    end
    
  end
end

.read(x) ⇒ Object



57
# File 'lib/rxfhelper.rb', line 57

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

.write(x, s) ⇒ Object



58
# File 'lib/rxfhelper.rb', line 58

def self.write(x, s)  RXFHelper.write(x, s)    end