Class: OKCupid::Mailbox
- Inherits:
-
Object
- Object
- OKCupid::Mailbox
- Defined in:
- lib/lonely_coder/mailbox.rb
Defined Under Namespace
Classes: Conversation, Message, MessageSnippet
Instance Method Summary collapse
-
#initialize(browser) ⇒ Mailbox
constructor
A new instance of Mailbox.
- #messages ⇒ Object
- #useage ⇒ Object
Constructor Details
#initialize(browser) ⇒ Mailbox
Returns a new instance of Mailbox.
102 103 104 |
# File 'lib/lonely_coder/mailbox.rb', line 102 def initialize(browser) @browser = browser end |
Instance Method Details
#messages ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/lonely_coder/mailbox.rb', line 113 def @messages = [] html = @browser.get('/messages') = html.search('#messages li') @messages += .collect do || MessageSnippet.from_html() end @messages end |
#useage ⇒ Object
106 107 108 109 110 111 |
# File 'lib/lonely_coder/mailbox.rb', line 106 def useage html = @browser.get('/messages') current, max = html.search('p.fullness').text.match(/([\d]+) of ([\d]+)/).captures return { current: current.to_i, max: max.to_i } end |