This repository has been archived on 2021-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
d20pfsrd/lib/pf/classes.rb

26 lines
616 B
Ruby

require_relative "../page.rb"
module PF
class Classes < Page
def initialize
super(uri: "https://www.d20pfsrd.com/classes")
end
def to_ruby
parsed = parse
klasses = parsed
.xpath("//a")
.to_a
.filter { |a| a[:href].match?(/^https:\/\/www.d20pfsrd.com\/classes\/[\w-]+\/.+/) }
klasses.map { |klass|
{
name: klass.text,
book: klass[:href].split("/")[-2].gsub("-", " ").capitalize,
link: klass[:href],
page: PF::Class.new(uri: klass[:href]),
}
}.uniq { |klass| klass[:link] }
end
end
end