Class: FileData

Inherits:
BaseUri show all
Defined in:
lib/libisi/uri/file.rb

Instance Attribute Summary

Attributes inherited from BaseUri

#options, #uri

Instance Method Summary collapse

Methods inherited from BaseUri

#base_uri, #credential_hash, #execute_command, #find, #password, #user

Constructor Details

#initialize(uri, options = {}) ⇒ FileData

Returns a new instance of FileData.



21
22
23
24
25
26
# File 'lib/libisi/uri/file.rb', line 21

def initialize(uri, options = {})
  super
  raise "Only local files allowed. Host is #{uri.host}" unless
    ["127.0.0.1","localhost"].include?(uri.host)
  @file = Pathname.new(uri.path[1..-1])
end

Instance Method Details

#column_namesObject



33
# File 'lib/libisi/uri/file.rb', line 33

def column_names; ["size","dirname","basename"]; end

#fileObject



28
# File 'lib/libisi/uri/file.rb', line 28

def file; @file; end

#itemsObject



35
36
37
38
39
40
41
# File 'lib/libisi/uri/file.rb', line 35

def items
  if @file.directory?
    @file.entries
  else
    @file.readlines
  end
end

#pathnameObject



29
# File 'lib/libisi/uri/file.rb', line 29

def pathname; @file; end

#primary_keyObject



31
# File 'lib/libisi/uri/file.rb', line 31

def primary_key; Proc.new {|pathname| pathname.basename.to_s}; end