Sha256: 89ade8d5165818fdc39545427cdb4cd1de8efd592ac424c7bdcba61fb1c0532b
Contents?: true
Size: 639 Bytes
Versions: 4
Compression:
Stored size: 639 Bytes
Contents
# frozen_string_literal: true require "http" require "json" module Osakana class Ayashige BASE_URL = "https://ayashige.herokuapp.com/feed" def lookup(keyword) res = HTTP.get(BASE_URL) return [] unless res.code == 200 websites = [] json = JSON.parse(res.body.to_s) json.each do |item| domain = item.dig("domain") || "" updated_on = item.dig("updated_on") || "" next unless domain.include?(keyword) websites << Website.new(domain: domain, date: updated_on) end websites end def self.lookup(keyword) new.lookup(keyword) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
osakana-0.4.0 | lib/osakana/ayashige.rb |
osakana-0.3.0 | lib/osakana/ayashige.rb |
osakana-0.2.1 | lib/osakana/ayashige.rb |
osakana-0.2.0 | lib/osakana/ayashige.rb |