Class: FileStruct
- Inherits:
-
Object
- Object
- FileStruct
- Defined in:
- lib/file_struct.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#basename ⇒ Object
Returns the value of attribute basename.
-
#content ⇒ Object
Returns the value of attribute content.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#path ⇒ Object
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #basic_name ⇒ Object
-
#initialize(path, options = {}) ⇒ FileStruct
constructor
A new instance of FileStruct.
- #reload! ⇒ Object
- #save! ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ FileStruct
Returns a new instance of FileStruct.
5 6 7 8 9 10 11 |
# File 'lib/file_struct.rb', line 5 def initialize(path, = {}) @path = path @basename = File.basename(path) @ext = File.extname(path) @content = [:content] || File.read(@path) @version = [:version] end |
Instance Attribute Details
#basename ⇒ Object
Returns the value of attribute basename.
2 3 4 |
# File 'lib/file_struct.rb', line 2 def basename @basename end |
#content ⇒ Object
Returns the value of attribute content.
2 3 4 |
# File 'lib/file_struct.rb', line 2 def content @content end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
3 4 5 |
# File 'lib/file_struct.rb', line 3 def ext @ext end |
#path ⇒ Object
Returns the value of attribute path.
2 3 4 |
# File 'lib/file_struct.rb', line 2 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/file_struct.rb', line 3 def version @version end |
Instance Method Details
#basic_name ⇒ Object
13 14 15 |
# File 'lib/file_struct.rb', line 13 def basic_name File.basename(@path, @ext) end |
#reload! ⇒ Object
21 22 23 |
# File 'lib/file_struct.rb', line 21 def reload! @content = File.read(@path) end |
#save! ⇒ Object
25 26 |
# File 'lib/file_struct.rb', line 25 def save! end |