Class: Gyazo::Image
- Inherits:
-
Object
- Object
- Gyazo::Image
- Defined in:
- lib/gyazo/image.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(upload_data) ⇒ Image
constructor
A new instance of Image.
- #name ⇒ Object
- #upload ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(upload_data) ⇒ Image
Returns a new instance of Image.
4 5 6 |
# File 'lib/gyazo/image.rb', line 4 def initialize(upload_data) @file = upload_data[:tempfile] end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
3 4 5 |
# File 'lib/gyazo/image.rb', line 3 def file @file end |
Class Method Details
.adapter=(sym_or_klass) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/gyazo/image.rb', line 34 def adapter=(sym_or_klass) if sym_or_klass.kind_of?(Symbol) @adapter = adapter_map[sym_or_klass] else @adapter = sym_or_klass end end |
.adapter_class ⇒ Object
30 31 32 |
# File 'lib/gyazo/image.rb', line 30 def adapter_class @adapter || ::Gyazo::UploadAdapters::Fog end |
Instance Method Details
#data ⇒ Object
16 17 18 |
# File 'lib/gyazo/image.rb', line 16 def data @data ||= @file.read end |
#name ⇒ Object
20 21 22 |
# File 'lib/gyazo/image.rb', line 20 def name @name ||= Digest::MD5.hexdigest(data).to_s + ".jpg" end |
#upload ⇒ Object
8 9 10 |
# File 'lib/gyazo/image.rb', line 8 def upload @url = self.adapter.upload end |
#url ⇒ Object
12 13 14 |
# File 'lib/gyazo/image.rb', line 12 def url @url end |