class Lita::Handlers::Wotd

Constants

WOTD_URL

Public Instance Methods

wotd(response) click to toggle source
# File lib/lita/handlers/wotd.rb, line 14
def wotd(response)
  response.reply(the_word)
end

Private Instance Methods

api_call() click to toggle source
# File lib/lita/handlers/wotd.rb, line 38
def api_call
  Net::HTTP.get_response(uri)
end
doc() click to toggle source
# File lib/lita/handlers/wotd.rb, line 30
def doc
  @doc ||= REXML::Document.new(api_call.body)
end
extract_the_word() click to toggle source
# File lib/lita/handlers/wotd.rb, line 24
def extract_the_word
  title = doc.get_elements('//title').last.get_text
  description = doc.get_elements('//description').last.get_text
  "#{title} => #{description}"
end
the_word() click to toggle source
# File lib/lita/handlers/wotd.rb, line 20
def the_word
  "#{extract_the_word} - wordsmith.org"
end
uri() click to toggle source
# File lib/lita/handlers/wotd.rb, line 34
def uri
  URI.parse WOTD_URL
end