Class: Mbox::Mail::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/mbox/mail/metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMetadata

Returns a new instance of Metadata



25
26
27
28
29
# File 'lib/mbox/mail/metadata.rb', line 25

def initialize
	@from = []
	@to = []
	@subject = []
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from



23
24
25
# File 'lib/mbox/mail/metadata.rb', line 23

def from
  @from
end

#subjectObject (readonly)

Returns the value of attribute subject



23
24
25
# File 'lib/mbox/mail/metadata.rb', line 23

def subject
  @subject
end

#toObject (readonly)

Returns the value of attribute to



23
24
25
# File 'lib/mbox/mail/metadata.rb', line 23

def to
  @to
end

Instance Method Details

#parse_from(line) ⇒ Object



31
32
33
34
35
# File 'lib/mbox/mail/metadata.rb', line 31

def parse_from (line)
	line.match /^>*From ([^\s]+) (.{24})/ do |m|
		@from << Struct.new(:name, :date).new(m[1], m[2])
	end
end

#parse_subject(line) ⇒ Object



41
42
43
44
45
# File 'lib/mbox/mail/metadata.rb', line 41

def parse_subject (line)
	line.match /Subject: (.*)/ do |m|
		@subject << m[1]
	end
end

#parse_to(line) ⇒ Object



36
37
38
39
40
# File 'lib/mbox/mail/metadata.rb', line 36

def parse_to (line)
	line.match /Delivered-To: (.*)/ do |m|
		@to << m[1]
	end
end