Class: SocialAvatarProxy::AvatarFile

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/social_avatar_proxy/avatar_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ AvatarFile

Returns a new instance of AvatarFile.



9
10
11
12
13
14
15
16
17
# File 'lib/social_avatar_proxy/avatar_file.rb', line 9

def initialize(path, options = {})
  if File.exist?(path)
    @file = File.new(path)
    mtime(file.mtime)
  else
    @file = Tempfile.new(path.gsub("/", "-"), options)
  end
  super(file)
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/social_avatar_proxy/avatar_file.rb', line 7

def file
  @file
end

Instance Method Details

#content_type(value = nil) ⇒ Object



23
24
25
# File 'lib/social_avatar_proxy/avatar_file.rb', line 23

def content_type(value = nil)
  value ? @content_type = value : @content_type
end

#mtime(value = nil) ⇒ Object



19
20
21
# File 'lib/social_avatar_proxy/avatar_file.rb', line 19

def mtime(value = nil)
  value ? @mtime = value.to_i : Time.at(@mtime)
end