Class: Swallow::Email
- Inherits:
-
Object
- Object
- Swallow::Email
- Defined in:
- lib/email.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#host ⇒ Object
Returns the value of attribute host.
-
#id ⇒ Object
Returns the value of attribute id.
-
#order ⇒ Object
Returns the value of attribute order.
-
#weird_id ⇒ Object
Returns the value of attribute weird_id.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(filename) ⇒ Email
constructor
A new instance of Email.
- #mark_read ⇒ Object
- #move_to(folder) ⇒ Object
- #newer_than?(limit) ⇒ Boolean
- #older_than?(limit) ⇒ Boolean
- #parse_filename(file) ⇒ Object
- #read? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(filename) ⇒ Email
Returns a new instance of Email.
11 12 13 14 15 |
# File 'lib/email.rb', line 11 def initialize(filename) @filename = filename path_parts = filename.split(/\//) parse_filename(path_parts[-1]) end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
9 10 11 |
# File 'lib/email.rb', line 9 def filename @filename end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/email.rb', line 8 def host @host end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/email.rb', line 8 def id @id end |
#order ⇒ Object
Returns the value of attribute order.
8 9 10 |
# File 'lib/email.rb', line 8 def order @order end |
#weird_id ⇒ Object
Returns the value of attribute weird_id.
8 9 10 |
# File 'lib/email.rb', line 8 def weird_id @weird_id end |
Instance Method Details
#delete ⇒ Object
46 47 48 |
# File 'lib/email.rb', line 46 def delete File.delete(@filename) end |
#mark_read ⇒ Object
34 35 36 |
# File 'lib/email.rb', line 34 def mark_read # modify filename to "S" on end end |
#move_to(folder) ⇒ Object
38 39 40 |
# File 'lib/email.rb', line 38 def move_to(folder) File.move(@filename, folder, true) end |
#newer_than?(limit) ⇒ Boolean
22 23 24 |
# File 'lib/email.rb', line 22 def newer_than?(limit) File.open(@filename).newer_than?(Date.today - limit) end |
#older_than?(limit) ⇒ Boolean
26 27 28 |
# File 'lib/email.rb', line 26 def older_than?(limit) File.open(@filename).older_than?(Date.today - limit) end |
#parse_filename(file) ⇒ Object
17 18 19 20 |
# File 'lib/email.rb', line 17 def parse_filename(file) uppername, @order, @read = file.split(/,/) @id, @weird_id, @host = uppername.split(/\./) end |
#read? ⇒ Boolean
30 31 32 |
# File 'lib/email.rb', line 30 def read? @read == "S" end |
#to_s ⇒ Object
42 43 44 |
# File 'lib/email.rb', line 42 def to_s File.open(@filename).read end |