Class: RelatonIec::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonIec::HitCollection
- Defined in:
- lib/relaton_iec/hit_collection.rb
Overview
Page of hit collection.
Constant Summary collapse
- DOMAIN =
"https://webstore.iec.ch"
Instance Method Summary collapse
-
#initialize(ref_nbr, year = nil) ⇒ HitCollection
constructor
A new instance of HitCollection.
Constructor Details
#initialize(ref_nbr, year = nil) ⇒ HitCollection
Returns a new instance of HitCollection.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/relaton_iec/hit_collection.rb', line 13 def initialize(ref_nbr, year = nil) #(text, hit_pages = nil) super from, to = nil if year from = Date.strptime year, "%Y" to = from.next_year.prev_day end url = "#{DOMAIN}/searchkey&RefNbr=#{ref_nbr}&From=#{from}&To=#{to}&start=1" doc = Nokogiri::HTML OpenURI.open_uri(::Addressable::URI.parse(url).normalize) @array = doc.css("ul.search-results > li").map do |h| link = h.at('a[@href!="#"]') code = link.text.tr [194, 160].pack("c*").force_encoding("UTF-8"), "" title = h.xpath("text()").text.gsub(/[\r\n]/, "") url = DOMAIN + link[:href] Hit.new({ code: code, title: title, url: url }, self) end end |