Class: S3Antivirus::S3Record
- Inherits:
-
Object
- Object
- S3Antivirus::S3Record
- Includes:
- Conf
- Defined in:
- lib/s3_antivirus/s3_record.rb
Instance Method Summary collapse
- #bucket ⇒ Object
- #human_key ⇒ Object
-
#initialize(record) ⇒ S3Record
constructor
A new instance of S3Record.
- #key ⇒ Object
- #max_size ⇒ Object
- #oversized? ⇒ Boolean
- #size ⇒ Object
- #version ⇒ Object
Methods included from Conf
Constructor Details
#initialize(record) ⇒ S3Record
Returns a new instance of S3Record.
5 6 7 |
# File 'lib/s3_antivirus/s3_record.rb', line 5 def initialize(record) @record = record # record data from SQS event structure end |
Instance Method Details
#bucket ⇒ Object
15 16 17 |
# File 'lib/s3_antivirus/s3_record.rb', line 15 def bucket @record['s3']['bucket']['name'] end |
#human_key ⇒ Object
9 10 11 12 13 |
# File 'lib/s3_antivirus/s3_record.rb', line 9 def human_key text = "s3://#{bucket}/#{key}" text += " (version: #{version})" if version text end |
#key ⇒ Object
19 20 21 |
# File 'lib/s3_antivirus/s3_record.rb', line 19 def key URI.decode(@record['s3']['object']['key']).gsub('+', ' ') end |
#max_size ⇒ Object
35 36 37 |
# File 'lib/s3_antivirus/s3_record.rb', line 35 def max_size conf['volume_size'] * 1073741824 / 2 # in bytes end |
#oversized? ⇒ Boolean
27 28 29 |
# File 'lib/s3_antivirus/s3_record.rb', line 27 def oversized? size > max_size end |
#size ⇒ Object
31 32 33 |
# File 'lib/s3_antivirus/s3_record.rb', line 31 def size @record['s3']['object']['size'] end |
#version ⇒ Object
23 24 25 |
# File 'lib/s3_antivirus/s3_record.rb', line 23 def version @record['s3']['object']['versionId'] end |