Sha256: 954719440897b5581bb49ff2fbe1234103e11e12a54abe731a43ce50f82c6fa8
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module WordOfTheDay class Adapter class Transparent < Base LANGUAGE_CODES = { 'arabic' => 'ar', 'chinese' => 'zh', 'dutch' => 'nl', 'esperanto' => 'esp', 'french' => 'fr', 'german' => 'de', 'irish' => 'ga', 'italian' => 'it', 'japanese' => 'ja', 'latin' => 'la', 'polish' => 'pl', 'portuguese' => 'pt', 'russian' => 'ru', 'spanish' => 'es' }.freeze def word xml.match(/<word>(.+?)</)&.captures&.first end def url "https://wotd.transparent.com/widget/?lang=#{language}&date=#{today}" end private def today Time.now.strftime('%m-%d-%Y') end def language_code LANGUAGE_CODES.fetch(language, language) end def xml xml_url = "https://wotd.transparent.com/rss/#{today}-#{language_code}-widget.xml" case (response = HTTPX.get(xml_url)) in { status: 200 } then response.body.to_s else '' end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rodbot-0.4.5 | lib/rodbot/plugins/word_of_the_day/lib/adapters/transparent.rb |
rodbot-0.4.4 | lib/rodbot/plugins/word_of_the_day/lib/adapters/transparent.rb |