Class: S3Antivirus::S3Record

Inherits:
Object
  • Object
show all
Includes:
Conf
Defined in:
lib/s3_antivirus/s3_record.rb

Instance Method Summary collapse

Methods included from Conf

#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

#bucketObject



15
16
17
# File 'lib/s3_antivirus/s3_record.rb', line 15

def bucket
  @record['s3']['bucket']['name']
end

#human_keyObject



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

#keyObject



19
20
21
# File 'lib/s3_antivirus/s3_record.rb', line 19

def key
  URI.decode(@record['s3']['object']['key']).gsub('+', ' ')
end

#max_sizeObject



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

Returns:

  • (Boolean)


27
28
29
# File 'lib/s3_antivirus/s3_record.rb', line 27

def oversized?
  size > max_size
end

#sizeObject



31
32
33
# File 'lib/s3_antivirus/s3_record.rb', line 31

def size
  @record['s3']['object']['size']
end

#versionObject



23
24
25
# File 'lib/s3_antivirus/s3_record.rb', line 23

def version
  @record['s3']['object']['versionId']
end