Class: OKCupid::Mailbox::MessageSnippet
- Inherits:
-
Object
- Object
- OKCupid::Mailbox::MessageSnippet
- Defined in:
- lib/lonely_coder/mailbox.rb
Instance Attribute Summary collapse
-
#conversation_url ⇒ Object
Returns the value of attribute conversation_url.
-
#last_date ⇒ Object
Returns the value of attribute last_date.
-
#preview ⇒ Object
Returns the value of attribute preview.
-
#profile_small_avatar_url ⇒ Object
Returns the value of attribute profile_small_avatar_url.
-
#profile_username ⇒ Object
Returns the value of attribute profile_username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs) ⇒ MessageSnippet
constructor
A new instance of MessageSnippet.
Constructor Details
#initialize(attrs) ⇒ MessageSnippet
Returns a new instance of MessageSnippet.
33 34 35 36 37 |
# File 'lib/lonely_coder/mailbox.rb', line 33 def initialize(attrs) attrs.each do |attr, value| self.send("#{attr}=", value) end end |
Instance Attribute Details
#conversation_url ⇒ Object
Returns the value of attribute conversation_url.
15 16 17 |
# File 'lib/lonely_coder/mailbox.rb', line 15 def conversation_url @conversation_url end |
#last_date ⇒ Object
Returns the value of attribute last_date.
15 16 17 |
# File 'lib/lonely_coder/mailbox.rb', line 15 def last_date @last_date end |
#preview ⇒ Object
Returns the value of attribute preview.
15 16 17 |
# File 'lib/lonely_coder/mailbox.rb', line 15 def preview @preview end |
#profile_small_avatar_url ⇒ Object
Returns the value of attribute profile_small_avatar_url.
15 16 17 |
# File 'lib/lonely_coder/mailbox.rb', line 15 def profile_small_avatar_url @profile_small_avatar_url end |
#profile_username ⇒ Object
Returns the value of attribute profile_username.
15 16 17 |
# File 'lib/lonely_coder/mailbox.rb', line 15 def profile_username @profile_username end |
Class Method Details
.from_html(html) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/lonely_coder/mailbox.rb', line 17 def self.from_html(html) profile_username = html.search('a.subject').text preview = html.search('.previewline').text last_date = html.search('.timestamp').text conversation_url = html.search('p:first').attribute('onclick').text.gsub('window.location=\'', '').gsub('\';','') profile_small_avatar_url = html.search('a.photo img').attribute('src').text self.new({ profile_username: profile_username, preview: preview, last_date: Date.parse(last_date), conversation_url: conversation_url, profile_small_avatar_url: profile_small_avatar_url }) end |