Class: CVEasy::Query
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Query
constructor
A new instance of Query.
- #version ⇒ Object
Methods inherited from Keyword
#description, #more, #name, #url
Constructor Details
#initialize(options = {}, &block) ⇒ Query
Returns a new instance of Query.
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 |
# File 'lib/CVEasy/query.rb', line 15 def initialize(={}, &block) @year = [:year] @cve = [:cve] @keyword = [:keyword] if [:keyword] @url = "#{KEYWORD_URL}#{URI.escape(@keyword)}" @html ||= Nokogiri::HTML(open(@url)) @html.css('#TableWithRules tr').each do |td| # Skip The First TD - Used as TH. next if td.at('a').nil? block.call(Keyword.new(td, @html)) if block end else @url = "#{CVE_URL}#{@year}-#{URI.escape(@cve)}" @html = Nokogiri::HTML(open(@url)) block.call(Cve.new(@html.at_css('#GeneratedTable'))) if block end end |
Instance Method Details
#version ⇒ Object
42 43 44 |
# File 'lib/CVEasy/query.rb', line 42 def version @version ||= @html.at('.smaller , b:nth-child(2)').inner_text end |