Class: AskAwesomely::S3
- Inherits:
-
Object
- Object
- AskAwesomely::S3
- Extended by:
- Forwardable
- Defined in:
- lib/ask_awesomely/s3.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#s3_object ⇒ Object
readonly
Returns the value of attribute s3_object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ S3
constructor
A new instance of S3.
- #upload_file ⇒ Object
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
#file ⇒ Object (readonly)
Returns the value of attribute file.
16 17 18 |
# File 'lib/ask_awesomely/s3.rb', line 16 def file @file end |
#s3_object ⇒ Object (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_file ⇒ Object
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 |