class OPFile

Attributes

api_wrapper[RW]
data_id[RW]
file_hash[RW]
filepath[RW]
hash[RW]
scan_results[RW]

Public Class Methods

new(attributes) click to toggle source
# File lib/file_sentry/op_file.rb, line 5
def initialize(attributes)
  attributes.each {|attribute, value| self.send("#{attribute}=", value)}
  self.file_hash ||= FileHash.new({op_file: self})
  self.api_wrapper ||= APIWrapper.new({op_file: self})
end

Public Instance Methods

process_file(encrypt) click to toggle source
# File lib/file_sentry/op_file.rb, line 11
def process_file(encrypt)
  check_file
  file_hash.hash_file(encrypt)
  api_wrapper.scan_file
end

Private Instance Methods

check_file() click to toggle source
# File lib/file_sentry/op_file.rb, line 19
def check_file
  raise "Invalid file" if !File.file?(filepath)
  raise "File size too large" if get_file_size > 140
end
get_file_size() click to toggle source
# File lib/file_sentry/op_file.rb, line 24
def get_file_size
  ('%.2f' % (File.size(filepath).to_f / 2**20)).to_i
end