Class: PopThis::POP3Server::Email

Inherits:
Object
  • Object
show all
Defined in:
lib/pop_this.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Email

Returns a new instance of Email.



24
25
26
27
# File 'lib/pop_this.rb', line 24

def initialize(filename)
  @filename = filename
  @deleted = false
end

Instance Attribute Details

#deletedObject

Returns the value of attribute deleted.



14
15
16
# File 'lib/pop_this.rb', line 14

def deleted
  @deleted
end

#filenameObject (readonly)

Returns the value of attribute filename.



13
14
15
# File 'lib/pop_this.rb', line 13

def filename
  @filename
end

Class Method Details

.all(dir) ⇒ Object



16
17
18
# File 'lib/pop_this.rb', line 16

def self.all(dir)
  Dir.glob("#{ dir }/*").reject{|fn| fn =~ /^\./ || File.directory?(fn) }.map{|fn| Email.new(fn) }
end

.delete(email) ⇒ Object



20
21
22
# File 'lib/pop_this.rb', line 20

def self.delete(email)
  File.delete(email.filename)
end

Instance Method Details

#deleted?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/pop_this.rb', line 33

def deleted?
  deleted
end

#emailObject



29
30
31
# File 'lib/pop_this.rb', line 29

def email
  @email ||= File.read(@filename)
end