lib/Archivist.rb in p2e_builder-0.1.4 vs lib/Archivist.rb in p2e_builder-0.1.5

- old
+ new

@@ -5,11 +5,17 @@ class Archivist attr_reader :ancestries, :backgrounds, :classes @@source = "https://2e.aonprd.com/" + + @@ance_parser = /Ability Boosts(Str.+|Dex.+|Con.+|Int.+|Wis.+|Cha.+)(Str.+|Dex.+|Con.+|Int.+|Wis.+|Cha.+)FreeAbility Flaw\(s\)(Str.+|Dex.+|Con.+|Int.+|Wis.+|Cha.+)Languages/ + @@back_parser = /be to (Str.+|Dex.+|Con.+|Int.+|Wis.+|Cha.+) or (Str.+|Dex.+|Con.+|Int.+|Wis.+|Cha.+), and one/ + + @@clas_parser = /(STR\w+|DEX\w+|CON\w+|INT\w+|WIS\w+|CHA\w+)/ + def page_finder(aspect) Nokogiri::HTML(open(@@source+aspect.to_s.capitalize+'.aspx')) end def hasher(aspect, header) @@ -29,19 +35,41 @@ end def summarize(option, aspect) # => grabs flavor blurb page = "https://2e.aonprd.com/"+self.send("#{aspect}")[option] blurb = Nokogiri::HTML(open(page)) - #binding.pry if page.include?("Backgrounds") puts blurb.text.match(/pg. 6\d(.+)Choose/)[1] else puts blurb.css("i")[1].text end end + def ance_stats(option, aspect) # => grabs stats from ancestry + page = "https://2e.aonprd.com/"+self.send("#{aspect}")[option] + blurb = Nokogiri::HTML(open(page)) + blurb.text.match(@@ance_parser) + end + + def back_stats(option, aspect) # => grabs stats from background + page = "https://2e.aonprd.com/"+self.send("#{aspect}")[option] + blurb = Nokogiri::HTML(open(page)) + blurb.text.match(@@back_parser) + end + + def clas_stats(option, aspect) # => grabs stats from class + page = "https://2e.aonprd.com/"+self.send("#{aspect}")[option] + blurb = Nokogiri::HTML(open(page)) + binding.pry + blurb.css("b")[2].text.match(@@clas_parser) + end + def confirm(option, aspect) return true if self.send("#{aspect}").include?(option) puts "Choose from the list of #{aspect} above." end -end +end + +#Archivist.new.ance_stats("Dwarf", :ancestries) + +#binding.pry \ No newline at end of file