Class: FakeAWS::S3::S3Object

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_aws/s3/s3_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket, key) ⇒ S3Object

Returns a new instance of S3Object.



6
7
8
9
# File 'lib/fake_aws/s3/s3_object.rb', line 6

def initialize(bucket, key)
  @bucket = bucket
  @key = key
end

Instance Attribute Details

#bucketObject (readonly)

Returns the value of attribute bucket.



11
12
13
# File 'lib/fake_aws/s3/s3_object.rb', line 11

def bucket
  @bucket
end

#keyObject (readonly)

Returns the value of attribute key.



12
13
14
# File 'lib/fake_aws/s3/s3_object.rb', line 12

def key
  @key
end

Instance Method Details

#content_lengthObject



24
25
26
27
# File 'lib/fake_aws/s3/s3_object.rb', line 24

def content_length
  must_exist!
  @data.length
end

#exists?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/fake_aws/s3/s3_object.rb', line 29

def exists?
  !!@data
end

#readObject



19
20
21
22
# File 'lib/fake_aws/s3/s3_object.rb', line 19

def read
  must_exist!
  @data
end

#write(data) ⇒ Object



14
15
16
17
# File 'lib/fake_aws/s3/s3_object.rb', line 14

def write(data)
  data = data.read if data.respond_to?(:read)
  @data = data
end