Sha256: 7e1b39a8e4a81721226311371348ee97186734327ed7559293f905a636d29d2b

Contents?: true

Size: 781 Bytes

Versions: 3

Compression:

Stored size: 781 Bytes

Contents

require 'open-uri'

class IdsPlease
  module Grabbers
    class Base

      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

      def initialize(link)
        @link = link
      end

      def grab_link(link)
        throw 'Base grabber can not grab anything'
      end

      def to_s
        line = ''
        self.instance_variables.each do |iv|
          next if iv == :@page_source
          val = self.instance_variable_get(iv)
          next if val.nil? || val == ''
          line += ", \n#{iv}=#{val}"
        end
        "#{self.class}##{self.object_id} #{line[1..-1]}"
      end

      def inspect
        to_s
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ids_please-2.1.1 lib/ids_please/grabbers/base.rb
ids_please-2.1.0 lib/ids_please/grabbers/base.rb
ids_please-2.0.0.beta2 lib/ids_please/grabbers/base.rb