class NistBib::HitCollection
Page of hit collection.
Constants
- DOMAIN
Attributes
fetched[R]
@return [TrueClass, FalseClass]
text[R]
@return [String]
year[R]
@return [String]
Public Class Methods
new(ref_nbr, year = nil, opts)
click to toggle source
@param ref_nbr [String] @param year [String] @param opts [Hash] @option opts [String] :stage
# File lib/nistbib/hit_collection.rb, line 26 def initialize(ref_nbr, year = nil, opts) @text = ref_nbr @year = year from, to = nil if year d = Date.strptime year, "%Y" from = d.strftime "%m/%d/%Y" to = d.next_year.prev_day.strftime "%m/%d/%Y" end url = "#{DOMAIN}/publications/search?keywords-lg=#{ref_nbr}" url += "&dateFrom-lg=#{from}" if from url += "&dateTo-lg=#{to}" if to url += "&status-lg=Draft,Withdrawn" if /PD/ =~ opts[:stage] doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize) hits = doc.css("table.publications-table > tbody > tr").map do |h| link = h.at("td/div/strong/a") serie = h.at("td[1]").text.strip code = h.at("td[2]").text.strip title = link.text url = DOMAIN + link[:href] status = h.at("td[4]").text.strip.downcase release_date = Date.strptime h.at("td[5]").text.strip, "%m/%d/%Y" Hit.new( { code: code, serie: serie, title: title, url: url, status: status, release_date: release_date }, self ) end concat hits # concat(hits.map { |h| Hit.new(h, self) }) @fetched = false # @hit_pages = hit_pages end
Public Instance Methods
fetch()
click to toggle source
@return [Iecbib::HitCollection]
# File lib/nistbib/hit_collection.rb, line 62 def fetch workers = RelatonBib::WorkersPool.new 4 workers.worker(&:fetch) each do |hit| workers << hit end workers.end workers.result @fetched = true self end
inspect()
click to toggle source
# File lib/nistbib/hit_collection.rb, line 78 def inspect "<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>" end
to_s()
click to toggle source
# File lib/nistbib/hit_collection.rb, line 74 def to_s inspect end