Class: OKCupid::Mailbox::Message
- Inherits:
-
Object
- Object
- OKCupid::Mailbox::Message
- Defined in:
- lib/lonely_coder/mailbox.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#from_me ⇒ Object
Returns the value of attribute from_me.
-
#to_me ⇒ Object
Returns the value of attribute to_me.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(attrs) ⇒ Message
Returns a new instance of Message.
95 96 97 98 99 |
# File 'lib/lonely_coder/mailbox.rb', line 95 def initialize(attrs) attrs.each do |attr, value| self.send("#{attr}=", value) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
79 80 81 |
# File 'lib/lonely_coder/mailbox.rb', line 79 def body @body end |
#from_me ⇒ Object
Returns the value of attribute from_me.
79 80 81 |
# File 'lib/lonely_coder/mailbox.rb', line 79 def from_me @from_me end |
#to_me ⇒ Object
Returns the value of attribute to_me.
79 80 81 |
# File 'lib/lonely_coder/mailbox.rb', line 79 def to_me @to_me end |
Class Method Details
.from_html(html) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/lonely_coder/mailbox.rb', line 81 def self.from_html(html) to_me = !!html.attribute('class').text.match(/to_me/) from_me = !to_me # time = html.search('.timestamp').text body = html.search('.message_body').text.gsub('<br>', "\n") self.new({ to_me: to_me, from_me: from_me, # time: time, body: body }) end |