Class: FileMarshal::Dumper

Inherits:
Object
  • Object
show all
Defined in:
lib/file_marshal/dumper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Dumper

Returns a new instance of Dumper.



5
6
7
# File 'lib/file_marshal/dumper.rb', line 5

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/file_marshal/dumper.rb', line 3

def file
  @file
end

Instance Method Details

#contentObject



17
18
19
20
# File 'lib/file_marshal/dumper.rb', line 17

def content
  file.rewind
  file.read
end

#to_hashObject



9
10
11
12
13
14
15
# File 'lib/file_marshal/dumper.rb', line 9

def to_hash
  { 
    updated_at: file.mtime,
    name: File.basename(file.path),
    content: content
  }
end