Class: SocialAvatarProxy::AvatarFile
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SocialAvatarProxy::AvatarFile
- Defined in:
- lib/social_avatar_proxy/avatar_file.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #content_type(value = nil) ⇒ Object
-
#initialize(path, options = {}) ⇒ AvatarFile
constructor
A new instance of AvatarFile.
- #mtime(value = nil) ⇒ Object
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, = {}) if File.exist?(path) @file = File.new(path) mtime(file.mtime) else @file = Tempfile.new(path.gsub("/", "-"), ) end super(file) end |
Instance Attribute Details
#file ⇒ Object (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 |