Class: SipoMailer::Models::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/sipo_mailer/models/attachment.rb

Constant Summary collapse

FILENAME_REGEX =
/^[0-9]+_?([0-9]{4}-[0-9]{2}-[0-9]{2})?\.[a-zA-Z0-9]+$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Attachment

Returns a new instance of Attachment.



8
9
10
11
12
# File 'lib/sipo_mailer/models/attachment.rb', line 8

def initialize(filename)
  @path = filename
  @file = open(filename)
  parse_meta
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



6
7
8
# File 'lib/sipo_mailer/models/attachment.rb', line 6

def file
  @file
end

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/sipo_mailer/models/attachment.rb', line 6

def filename
  @filename
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/sipo_mailer/models/attachment.rb', line 6

def id
  @id
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/sipo_mailer/models/attachment.rb', line 6

def path
  @path
end

#processed_onObject (readonly)

Returns the value of attribute processed_on.



6
7
8
# File 'lib/sipo_mailer/models/attachment.rb', line 6

def processed_on
  @processed_on
end

Instance Method Details

#processObject



22
# File 'lib/sipo_mailer/models/attachment.rb', line 22

def process; end

#processed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sipo_mailer/models/attachment.rb', line 18

def processed?
  !@processed_on.nil?
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/sipo_mailer/models/attachment.rb', line 14

def valid?
  !(@filename =~ FILENAME_REGEX).nil?
end