Sha256: 248d7f0e61a309aa864cf24b0bb996859fb9270067b7713defb6c866b10d793c

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 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 += ", #{iv}=#{val}"
        end
        "#{self.class}##{self.object_id} #{line[1..-1]}"
      end

      def inspect
        to_s
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ids_please-2.0.0.beta1 lib/ids_please/grabbers/base.rb