Class: AskAwesomely::S3

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/ask_awesomely/s3.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ S3

Returns a new instance of S3.



18
19
20
# File 'lib/ask_awesomely/s3.rb', line 18

def initialize(file)
  @file = file
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



16
17
18
# File 'lib/ask_awesomely/s3.rb', line 16

def file
  @file
end

#s3_objectObject (readonly)

Returns the value of attribute s3_object.



16
17
18
# File 'lib/ask_awesomely/s3.rb', line 16

def s3_object
  @s3_object
end

Class Method Details

.upload(file) ⇒ Object



22
23
24
# File 'lib/ask_awesomely/s3.rb', line 22

def self.upload(file)
  new(file).tap(&:upload_file)
end

Instance Method Details

#upload_fileObject



26
27
28
29
30
31
# File 'lib/ask_awesomely/s3.rb', line 26

def upload_file
  ensure_credentials_set!
  @s3_object = bucket.object(file.basename.to_s).tap do |obj|
    obj.upload_file(file.to_s)
  end
end