lib/itch/bundles.rb in itch_client-0.3.0 vs lib/itch/bundles.rb in itch_client-0.4.0
- old
+ new
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'bigdecimal'
+require "bigdecimal"
+
require_relative "simple_inspect"
require_relative "bundle"
require_relative "request"
require_relative "require_auth"
-
module Itch
# Fetch bundles
class Bundles
include RequireAuth
include SimpleInspect
@@ -21,19 +21,19 @@
def list
page = with_login do
@agent.get(bundles_url)
end
- page.css('.bundle_list table > tr').map do |row|
+ page.css(".bundle_list table > tr").map do |row|
parse_row(row)
end
end
def parse_row(row)
- id = row.at_xpath('td[2]/a/@href').value.match(%r[^/b/(\d+)/])[1]
- vals = row.css('td').map(&:text)
- price = BigDecimal(vals[5].gsub(/[^\d.-]/, ''))
- earnings = BigDecimal(vals[6].gsub(/[\D-]/, ''))
+ id = row.at_xpath("td[2]/a/@href").value.match(%r{^/b/(\d+)/})[1]
+ vals = row.css("td").map(&:text)
+ price = BigDecimal(vals[5].gsub(/[^\d.-]/, ""))
+ earnings = BigDecimal(vals[6].gsub(/[\D-]/, ""))
Bundle.new(id, vals[1], vals[4].to_i, price, earnings)
end
def bundles_url