Class: Lita::Handlers::WhatsBradEating
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::WhatsBradEating
- Defined in:
- lib/lita/handlers/whats_brad_eating.rb
Constant Summary collapse
- BLOG_URL =
START:blog_url
'https://whatsbradeating.tumblr.com'.freeze
Instance Method Summary collapse
-
#brad_eats(response) ⇒ Object
START:brad_eats.
- #caption ⇒ Object
- #first_post ⇒ Object
- #image ⇒ Object
-
#parsed_response ⇒ Object
END:blog_url.
- #response ⇒ Object
Instance Method Details
#brad_eats(response) ⇒ Object
START:brad_eats
36 37 38 39 40 41 42 43 44 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 36 def brad_eats(response) # caption text had some stray newlines we don't need = .text.strip img_url = image.get_attribute('src') msg = "#{} >> #{img_url}" response.reply msg end |
#caption ⇒ Object
31 32 33 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 31 def image.attributes.fetch('alt') end |
#first_post ⇒ Object
23 24 25 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 23 def first_post parsed_response.css('section.post').first end |
#image ⇒ Object
27 28 29 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 27 def image first_post.css('.photo-wrapper img').first end |
#parsed_response ⇒ Object
END:blog_url
19 20 21 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 19 def parsed_response Nokogiri.parse(response.body) end |
#response ⇒ Object
14 15 16 |
# File 'lib/lita/handlers/whats_brad_eating.rb', line 14 def response @_response ||= http.get(BLOG_URL) end |