Class: Xxx::Youporn

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

Constant Summary collapse

HOST =
"youporn.com"
URI =
"http://#{HOST}"
BROWSE_TIME_PATH =
"/browse/time"
ENTER_WEBSITE =
lambda { |page| page.forms.first.click_button }

Instance Method Summary collapse

Instance Method Details

#agentObject



8
9
10
# File 'lib/xxx/youporn.rb', line 8

def agent
  @agent ||= Mechanize.new
end

#latestObject



12
13
14
15
16
# File 'lib/xxx/youporn.rb', line 12

def latest
  agent.get(uri(BROWSE_TIME_PATH), &ENTER_WEBSITE)
  path = agent.page.links_with(:href => /watch/).first.href
  uri(path)
end

#uri(path) ⇒ Object



18
19
20
# File 'lib/xxx/youporn.rb', line 18

def uri(path)
  "#{URI}#{path}"
end