Class: FFFS::File

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/fffs/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#path

Constructor Details

#initialize(name, content = '', parent = nil, filesystem = nil) ⇒ File



32
33
34
35
36
37
38
39
40
# File 'lib/fffs/file.rb', line 32

def initialize (name, content='', parent=nil, filesystem=nil)
  @filesystem = filesystem
  @parent     = parent

  @name = name

  @content = content.clone
  @content.force_encoding 'ASCII-8BIT'
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



29
30
31
# File 'lib/fffs/file.rb', line 29

def content
  @content
end

#filesystemObject

Returns the value of attribute filesystem.



27
28
29
# File 'lib/fffs/file.rb', line 27

def filesystem
  @filesystem
end

#nameObject

Returns the value of attribute name.



30
31
32
# File 'lib/fffs/file.rb', line 30

def name
  @name
end

#parentObject

Returns the value of attribute parent.



27
28
29
# File 'lib/fffs/file.rb', line 27

def parent
  @parent
end

Instance Method Details

#inspectObject



58
59
60
# File 'lib/fffs/file.rb', line 58

def inspect
  self.path
end

#save(path) ⇒ Object



48
49
50
51
52
# File 'lib/fffs/file.rb', line 48

def save (path)
  ::File.open(path, 'wb') {|f|
    f.write content
  }
end

#to_sObject



54
55
56
# File 'lib/fffs/file.rb', line 54

def to_s
  @content
end