Class: FileSetWorks::File
- Inherits:
-
FilesetItem
- Object
- FilesetItem
- FileSetWorks::File
- Defined in:
- lib/fileset.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #init_self(path) ⇒ Object
-
#initialize(path, data, populator = default_populator()) ⇒ File
constructor
A new instance of File.
- #load(file) ⇒ Object
- #store(file) ⇒ Object
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
#contents ⇒ Object
Returns the value of attribute contents.
111 112 113 |
# File 'lib/fileset.rb', line 111 def contents @contents end |
#path ⇒ Object (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 |