Sha256: 10fd502d276f09acc21e3fb4f06897d2fe873cc6765faaac18e62e073f5e2e85

Contents?: true

Size: 547 Bytes

Versions: 1

Compression:

Stored size: 547 Bytes

Contents

# frozen_string_literal: true

module WordOfTheDay
  class Adapter
    class MerriamWebster < Base
      private

      def word
        html.match(/<h2 class="word-header-txt">(.+?)</)&.captures&.first
      end

      def url
        "https://www.merriam-webster.com/word-of-the-day/#{today}"
      end

      private

      def today
        Time.now.strftime('%F')
      end

      def html
        case (response = HTTPX.get(url))
          in { status: 200 } then response.body.to_s
          else ''
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rodbot-0.4.4 lib/rodbot/plugins/word_of_the_day/lib/adapters/merriam_webster.rb