Class: IcoBench
- Inherits:
-
Object
- Object
- IcoBench
- Defined in:
- lib/ico_bench.rb,
lib/ico_bench/version.rb
Constant Summary collapse
- BASE_URL =
'https://icobench.com'.freeze
- VERSION =
'0.1.0'
Class Method Summary collapse
Class Method Details
.icos(**params) ⇒ Hash
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/ico_bench.rb', line 16 def icos(**params) url = "#{BASE_URL}/icos" query = filters(params) url << query if query.present? request_time = Time.now.to_f response = HTTP.get(url) html = Nokogiri::HTML(response.body.to_s) rows = html.css('div.ico_list table tr') return {} if rows.blank? icos = [] rows.each_with_index do |row, index| next if index.zero? # table header row icos << parse_ico_row(row) end { current_page: params[:page] || 1, total_pages: html.css('div.pages a.num').last&.text&.to_i, response_time: (Time.now.to_f - request_time.to_d), icos: icos } end |
.people(type: nil, page: nil, search: nil) ⇒ Hash
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ico_bench.rb', line 46 def people(type: nil, page: nil, search: nil) url = "#{BASE_URL}/people" params = { page: page, type: type, s: search.presence }.compact.to_param url << "?#{params}" if params.present? request_time = Time.now.to_f response = HTTP.get(url) html = Nokogiri::HTML(response.body.to_s) rows = html.css('div.ico_list table tr') return {} if rows.blank? people = [] rows.each_with_index do |row, index| next if index.zero? # table header row people << parse_people_row(row) end { current_page: page.presence || 1, total_pages: html.css('div.pages a.num').last&.text&.to_i, response_time: (Time.now.to_f - request_time.to_d), people: people } end |