Class: FileSystem::LocalFileSystem::LocalFile

Inherits:
Object
  • Object
show all
Defined in:
lib/swineherd/filesystem/filesystems.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#modeObject

Returns the value of attribute mode.



69
70
71
# File 'lib/swineherd/filesystem/filesystems.rb', line 69

def mode
  @mode
end

#pathObject

Returns the value of attribute path.



69
70
71
# File 'lib/swineherd/filesystem/filesystems.rb', line 69

def path
  @path
end

#schemeObject

Returns the value of attribute scheme.



69
70
71
# File 'lib/swineherd/filesystem/filesystems.rb', line 69

def scheme
  @scheme
end

Instance Method Details

#closeObject

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

#readObject

Return whole file and as a string



83
84
85
# File 'lib/swineherd/filesystem/filesystems.rb', line 83

def read
  @handle.read
end

#readlineObject

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