Class: Lita::Handlers::WhatsBradEating

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/whats_brad_eating.rb

Instance Method Summary collapse

Instance Method Details

#brad_eats(response) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/lita/handlers/whats_brad_eating.rb', line 13

def brad_eats(response)
  blog_url = 'https://whatsbradeating.tumblr.com'

  res = http.get(blog_url)
  noked = Nokogiri.parse(res.body)

  post = noked.css("#posts .post").first

  caption = post.css(".caption").first
  img = post.css(".photo-wrapper img").first

  caption_text = caption.text.strip
  img_url = img.get_attribute('src')

  msg = "#{caption_text} >> #{img_url}"

  response.reply msg
end