Class: FileData
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_names ⇒ Object
33
|
# File 'lib/libisi/uri/file.rb', line 33
def column_names; ["size","dirname","basename"]; end
|
#file ⇒ Object
28
|
# File 'lib/libisi/uri/file.rb', line 28
def file; @file; end
|
#items ⇒ Object
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
|
#pathname ⇒ Object
29
|
# File 'lib/libisi/uri/file.rb', line 29
def pathname; @file; end
|
#primary_key ⇒ Object
31
|
# File 'lib/libisi/uri/file.rb', line 31
def primary_key; Proc.new {|pathname| pathname.basename.to_s}; end
|