Class: FileSystem::LocalFileSystem::LocalFile
- Inherits:
-
Object
- Object
- FileSystem::LocalFileSystem::LocalFile
- Defined in:
- lib/swineherd/filesystem/filesystems.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
-
#close ⇒ Object
Close file.
-
#initialize(path, mode = "r", &blk) ⇒ LocalFile
constructor
A new instance of LocalFile.
- #open(path, mode = "r") ⇒ Object
-
#read ⇒ Object
Return whole file and as a string.
-
#readline ⇒ Object
Return a line from stream.
-
#write(string) ⇒ Object
Writes to the file.
Constructor Details
#initialize(path, mode = "r", &blk) ⇒ LocalFile
Returns a new instance of LocalFile.
71 72 73 74 75 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 71 def initialize(path,mode="r",&blk) @path=path @mode=mode @handle=File.open(path,mode,&blk) end |
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
69 70 71 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 69 def mode @mode end |
#path ⇒ Object
Returns the value of attribute path.
69 70 71 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 69 def path @path end |
#scheme ⇒ Object
Returns the value of attribute scheme.
69 70 71 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 69 def scheme @scheme end |
Instance Method Details
#close ⇒ Object
Close file
98 99 100 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 98 def close @handle.close end |
#open(path, mode = "r") ⇒ Object
77 78 79 80 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 77 def open(path,mode="r") # Only "r" and "w" modes are supported. initialize(path,mode) end |
#read ⇒ Object
Return whole file and as a string
83 84 85 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 83 def read @handle.read end |
#readline ⇒ Object
Return a line from stream
88 89 90 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 88 def readline @handle.gets end |
#write(string) ⇒ Object
Writes to the file
93 94 95 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 93 def write(string) @handle.write(string) end |