Class: RelatonCen::HitCollection
- Inherits:
-
RelatonBib::HitCollection
- Object
- RelatonBib::HitCollection
- RelatonCen::HitCollection
- Defined in:
- lib/relaton_cen/hit_collection.rb
Overview
Page of hit collection.
Constant Summary collapse
- DOMAIN =
"https://standards.cencenelec.eu/dyn/www/"
Instance Attribute Summary collapse
- #agent ⇒ Mechanize readonly
Instance Method Summary collapse
-
#initialize(ref, year = nil) ⇒ HitCollection
constructor
A new instance of HitCollection.
Constructor Details
#initialize(ref, 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/relaton_cen/hit_collection.rb', line 13 def initialize(ref, year = nil) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity super ref, year @agent = Mechanize.new agent.user_agent_alias = "Mac Safari" if !ref || ref.empty? @array = [] return end search_page = agent.get "#{DOMAIN}f?p=205:105:0:::::" form = search_page.at "//form[@id='wwvFlowForm']" skip_inputs = %w[f11 essentialCookies] req_body = form.xpath(".//input").filter_map do |f| next if f[:name].empty? || skip_inputs.include?(f[:name]) val = case f[:value] when "LANGUAGE_LIST" then 0 when "STAND_REF" then CGI.escape(ref) else case f[:name] when "p_request" then "S1-S2-S3-S4-S5-S6-S7-CEN-CLC-" when "f10" then "" else f[:value] end end if f[:name] == "f10" then "f10=#{f[:value]}&f11=#{val}" else "#{f[:name]}=#{val}" end end.join("&") resp = agent.post form[:action], req_body @array = hits resp sort end |
Instance Attribute Details
#agent ⇒ Mechanize (readonly)
9 10 11 |
# File 'lib/relaton_cen/hit_collection.rb', line 9 def agent @agent end |