lib/ids_please/grabbers/base.rb in ids_please-2.2.0 vs lib/ids_please/grabbers/base.rb in ids_please-2.2.1

- old
+ new

@@ -6,17 +6,24 @@ def self.interact(links) links.map { |l| self.new(l).grab_link } end - attr_reader :avatar, :display_name, :username, :link, :page_source, :network_id, :data, :counts + attr_reader :avatar, + :display_name, + :username, + :link, + :page_source, + :network_id, + :data, + :counts def initialize(link) @link = link end - def grab_link(link) + def grab_link(_link) throw 'Base grabber can not grab anything' end def to_s line = '' @@ -46,8 +53,21 @@ end def page_source @page_source ||= open(link).read end + + def errors + @errors ||= [] + end + + def record_error(event, message) + errors << "#{event} has #{message}" + end + + def find_by_regex(reg) + page_source.scan(reg).flatten.first + end + end end end