Class: EveGate::Mail

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mail, agent) ⇒ Mail

attr_writer :body, :sender, :to



9
10
11
12
13
14
15
16
# File 'lib/eve_gate.rb', line 9

def initialize(mail, agent)
  @read =     mail.children[2].children[1].attributes['alt'].text == 'Read'
  @sender =   mail.children[4].children[1].text.strip
  @subject =  mail.children[6].children[1].children[1].text
  @url =      mail.children[6].children[1].children[1].attributes['href'].value
  @date = DateTime.parse(mail.children[8].text).to_time
  @agent = agent
end

Instance Attribute Details

#readObject

Returns the value of attribute read.



7
8
9
# File 'lib/eve_gate.rb', line 7

def read
  @read
end

#receipientObject

Returns the value of attribute receipient.



7
8
9
# File 'lib/eve_gate.rb', line 7

def receipient
  @receipient
end

#subjectObject

Returns the value of attribute subject.



7
8
9
# File 'lib/eve_gate.rb', line 7

def subject
  @subject
end

Instance Method Details

#bodyObject



18
19
20
21
# File 'lib/eve_gate.rb', line 18

def body
  update_details unless @body
  @body
end

#senderObject



23
24
25
26
# File 'lib/eve_gate.rb', line 23

def sender
  update_details unless @sender
  @sender
end

#toObject



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

def to
  update_details unless @to
  @to
end

#update_detailsObject



33
34
35
36
37
38
# File 'lib/eve_gate.rb', line 33

def update_details
  @agent.get(@url)
  @body   = @agent.page.search(".//div[@id='hideBottomButtons']/p")[1].inner_html
  @to     = @agent.page.search(".//div[@id='hideBottomButtons']/p[1]/a")[1].text
  @sender = @agent.page.search(".//div[@id='hideBottomButtons']/p[1]/a")[0].text
end