Class: FileMarshal::Writer
- Inherits:
-
Object
- Object
- FileMarshal::Writer
- Defined in:
- lib/file_marshal/writer.rb,
lib/file_marshal/writer/file.rb,
lib/file_marshal/writer/temp.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(attributes) ⇒ Writer
constructor
A new instance of Writer.
- #prepare ⇒ Object
- #set_time ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Writer
Returns a new instance of Writer.
5 6 7 |
# File 'lib/file_marshal/writer.rb', line 5 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/file_marshal/writer.rb', line 3 def attributes @attributes end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/file_marshal/writer.rb', line 3 def file @file end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 |
# File 'lib/file_marshal/writer.rb', line 12 def build write set_time prepare end |
#prepare ⇒ Object
31 32 33 34 |
# File 'lib/file_marshal/writer.rb', line 31 def prepare file.rewind file end |
#set_time ⇒ Object
27 28 29 |
# File 'lib/file_marshal/writer.rb', line 27 def set_time ::File.utime(file.atime, Time.parse(updated_at), file.path) end |
#write ⇒ Object
22 23 24 25 |
# File 'lib/file_marshal/writer.rb', line 22 def write file.write(content) file end |