Sha256: f720430bf030f3f4bc426bed8b7c5ecfc659768646bd53d2429bdc314ebb8ad6
Contents?: true
Size: 974 Bytes
Versions: 1
Compression:
Stored size: 974 Bytes
Contents
# frozen_string_literal: true require "oga" module Miteru class Website attr_reader :url def initialize(url) @url = url build end def title doc.at_css("title")&.text end def zip_files @zip_files ||= doc.css("a").map do |a| href = a.get("href") href&.end_with?(".zip") ? href : nil end.compact.map do |href| href.start_with?("/") ? href[1..-1] : href end end def ok? response.code == 200 end def index? title == "Index of /" end def zip_files? !zip_files.empty? end def has_kit? ok? && index? && zip_files? end def build doc end def unbuild @doc = nil @response = nil @zip_files = nil end private def response @response ||= get end def get HTTPClient.get url end def doc @doc ||= Oga.parse_html(response.body.to_s) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.6.1 | lib/miteru/website.rb |