Class: FileSetWorks::File

Inherits:
FilesetItem show all
Defined in:
lib/fileset.rb

Direct Known Subclasses

YAMLFile

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FilesetItem

#create_in, #default_populator, #populate

Constructor Details

#initialize(path, data, populator = default_populator()) ⇒ File

Returns a new instance of File.



105
106
107
108
# File 'lib/fileset.rb', line 105

def initialize(path, data, populator = default_populator())
  super(path, populator)
  @contents = data
end

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



111
112
113
# File 'lib/fileset.rb', line 111

def contents
  @contents
end

#pathObject (readonly)

Returns the value of attribute path.



110
111
112
# File 'lib/fileset.rb', line 110

def path
  @path
end

Instance Method Details

#init_self(path) ⇒ Object



122
123
124
125
126
# File 'lib/fileset.rb', line 122

def init_self(path)
  ::File::open(path, "w") do |file|
    store(file)
  end
end

#load(file) ⇒ Object



113
114
115
116
# File 'lib/fileset.rb', line 113

def load(file)
  @contents = file.read
  return @contents
end

#store(file) ⇒ Object



118
119
120
# File 'lib/fileset.rb', line 118

def store(file)
  file.write(@contents)
end