Class: GyomuRuby::AmazonWebService::FileBucket

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/gyomu_ruby/amazon_web_service/file_bucket.rb

Defined Under Namespace

Classes: PoorMan, RichMan

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket = 'bucket') ⇒ FileBucket

Returns a new instance of FileBucket.



12
13
14
# File 'lib/gyomu_ruby/amazon_web_service/file_bucket.rb', line 12

def initialize(bucket = 'bucket')
  @backend = Rails.env.production? || Rails.env.staging? ?  RichMan.new(bucket) : PoorMan.new(bucket)
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



7
8
9
# File 'lib/gyomu_ruby/amazon_web_service/file_bucket.rb', line 7

def backend
  @backend
end

Instance Method Details

#put(io) ⇒ Object



16
17
18
19
20
# File 'lib/gyomu_ruby/amazon_web_service/file_bucket.rb', line 16

def put(io)
  "#{Time.now.strftime('%Y%m%d%H%M')}_#{SecureRandom.hex(5)}".tap do |key|
    @backend.put(key, io)
  end
end