Class: OKCupid
- Inherits:
-
Object
show all
- Defined in:
- lib/lonely_coder.rb,
lib/lonely_coder/search.rb,
lib/lonely_coder/mailbox.rb,
lib/lonely_coder/profile.rb,
lib/lonely_coder/authentication.rb,
lib/lonely_coder/search/options/age.rb,
lib/lonely_coder/search/options/filter.rb,
lib/lonely_coder/search/options/radius.rb,
lib/lonely_coder/search/magic_constants.rb,
lib/lonely_coder/search/options/location.rb,
lib/lonely_coder/search/options/order_by.rb,
lib/lonely_coder/search/options/ethnicity.rb,
lib/lonely_coder/search/options/paginator.rb,
lib/lonely_coder/search/options/require_photo.rb,
lib/lonely_coder/search/search_pagination_parser.rb
Defined Under Namespace
Modules: MagicNumbers
Classes: AgeFilter, Authentication, AuthenticationParser, EthnicityFilter, Filter, LocationParameter, Mailbox, OrderByParameter, Paginator, Profile, RadiusFilter, RequirePhotoFilter, Search, SearchPaginationParser
Constant Summary
collapse
- BaseUrl =
'http://www.okcupid.com'
- VERSION =
'0.1.5'
- WhiteSpace =
"\302\240"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(username = nil, password = nil) ⇒ OKCupid
Returns a new instance of OKCupid.
16
17
18
19
20
|
# File 'lib/lonely_coder.rb', line 16
def initialize(username=nil, password=nil)
@browser = Mechanize.new
@browser.user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
authenticate(username, password)
end
|
Class Method Details
.strip(str) ⇒ Object
23
24
25
|
# File 'lib/lonely_coder.rb', line 23
def self.strip(str)
str.gsub(WhiteSpace, ' ').strip
end
|
Instance Method Details
#authenticate(username, password) ⇒ Object
5
6
7
|
# File 'lib/lonely_coder/authentication.rb', line 5
def authenticate(username, password)
@authentication = Authentication.new(username, password, @browser)
end
|
#conversation_for(id) ⇒ Object
8
9
10
|
# File 'lib/lonely_coder/mailbox.rb', line 8
def conversation_for(id)
Mailbox::Conversation.by_id(id, @browser)
end
|
#love(n = 20) ⇒ Object
27
28
29
|
# File 'lib/lonely_coder.rb', line 27
def love(n=20)
' ♥ ' * n
end
|
#mailbox ⇒ Object
4
5
6
|
# File 'lib/lonely_coder/mailbox.rb', line 4
def mailbox
@mailbox ||= Mailbox.new(@browser)
end
|
#profile_for(username) ⇒ Object
4
5
6
|
# File 'lib/lonely_coder/profile.rb', line 4
def profile_for(username)
Profile.by_username(username, @browser)
end
|
#search(options = {}) ⇒ Search
Creates a new Search with the passed options to act as query parameters. A search will not trigger a query to OKCupid until ‘results` is called.
49
50
51
|
# File 'lib/lonely_coder/search.rb', line 49
def search(options={})
Search.new(options, @browser)
end
|