Class: FileMarshal::Loader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Loader

Returns a new instance of Loader.



5
6
7
8
9
10
# File 'lib/file_marshal/loader.rb', line 5

def initialize(opts)
  opts.symbolize_keys!
  @attributes = FileAttributes.new(
    opts[:name], opts[:content], opts[:updated_at]
  )
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

Instance Method Details

#tempfileObject



15
16
17
# File 'lib/file_marshal/loader.rb', line 15

def tempfile
  Writer::Temp.new(attributes).build
end

#to_file(path) ⇒ Object



19
20
21
# File 'lib/file_marshal/loader.rb', line 19

def to_file(path)
  Writer::File.new(attributes, path).build
end