Module: PtabManager
Overview
Example Trial
"trialNumber": "IPR2016-00831",
"applicationNumber": "09026118",
"patentNumber": "6162705",
"petitionerPartyName": "Commissariat a l’Energie Atomique et aux Energies Alternatives",
"patentOwnerName": "Silicon Genesis Corporation",
"inventorName": "FRANCOIS HENLEY",
"prosecutionStatus": "Terminated-Settled",
"filingDate": "2016-04-01",
"accordedFilingDate": "2016-04-01",
"institutionDecisionDate": "2016-09-28",
"lastModifiedDatetime": "2017-07-06T16:06:59",
Instance Method Summary collapse
- #each ⇒ Object
- #filter(*args, **kwargs) ⇒ Object
- #get(*args, **kwargs) ⇒ Object
- #get_page(page_no = 0) ⇒ Object
- #initialize(params = Hash.new) ⇒ Object
- #length ⇒ Object
Instance Method Details
#each ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/ptab.rb', line 76 def each puts "Record Class #{self.record_class_name}" (0..(length-1)).each do |index| position = index % 25 page_no = (index / 25).floor yield get_page(page_no)["results"][position] end end |
#filter(*args, **kwargs) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/ptab.rb', line 46 def filter(*args, **kwargs) if args kwargs["trialNumber"] = args[0] end new_params = @params.merge(kwargs) self.class.new(new_params) end |
#get(*args, **kwargs) ⇒ Object
41 42 43 44 |
# File 'lib/ptab.rb', line 41 def get(*args, **kwargs) new_manager = filter(*args, **kwargs) new_manager.first() end |
#get_page(page_no = 0) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ptab.rb', line 55 def get_page(page_no=0) if not @pages.key? page_no params = @params.merge({"page_no" => page_no+1}) url_params = Hash.new inflector = Dry::Inflector.new params.each_pair do |key, value| new_key = inflector.camelize(key) new_key = new_key[0].downcase + new_key[1..] url_params[new_key] = value end response = @conn.get "ptab-api/trials", url_params @pages[page_no] = JSON.parse(response.body) end @pages[page_no] end |
#initialize(params = Hash.new) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ptab.rb', line 33 def initialize(params=Hash.new) @params = params @conn = Faraday.new( :url => "https://ptabdata.uspto.gov" ) @pages = {} end |
#length ⇒ Object
71 72 73 74 |
# File 'lib/ptab.rb', line 71 def length page_one = get_page() page_one["metadata"]["count"] end |