Class: IdsPlease::Grabbers::Base
- Inherits:
-
Object
- Object
- IdsPlease::Grabbers::Base
- Defined in:
- lib/ids_please/grabbers/base.rb
Instance Attribute Summary collapse
-
#avatar ⇒ Object
readonly
Returns the value of attribute avatar.
-
#counts ⇒ Object
readonly
Returns the value of attribute counts.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#network_id ⇒ Object
readonly
Returns the value of attribute network_id.
-
#page_source ⇒ Object
readonly
Returns the value of attribute page_source.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #errors ⇒ Object
- #find_by_regex(reg) ⇒ Object
- #grab_link(_link) ⇒ Object
-
#initialize(link) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #record_error(event, message) ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(link) ⇒ Base
Returns a new instance of Base.
20 21 22 |
# File 'lib/ids_please/grabbers/base.rb', line 20 def initialize(link) @link = link end |
Instance Attribute Details
#avatar ⇒ Object (readonly)
Returns the value of attribute avatar.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def avatar @avatar end |
#counts ⇒ Object (readonly)
Returns the value of attribute counts.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def counts @counts end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def data @data end |
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def display_name @display_name end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def link @link end |
#network_id ⇒ Object (readonly)
Returns the value of attribute network_id.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def network_id @network_id end |
#page_source ⇒ Object (readonly)
Returns the value of attribute page_source.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def page_source @page_source end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
11 12 13 |
# File 'lib/ids_please/grabbers/base.rb', line 11 def username @username end |
Class Method Details
.interact(links) ⇒ Object
7 8 9 |
# File 'lib/ids_please/grabbers/base.rb', line 7 def self.interact(links) links.map { |l| self.new(l).grab_link } end |
Instance Method Details
#errors ⇒ Object
59 60 61 |
# File 'lib/ids_please/grabbers/base.rb', line 59 def errors @errors ||= [] end |
#find_by_regex(reg) ⇒ Object
67 68 69 |
# File 'lib/ids_please/grabbers/base.rb', line 67 def find_by_regex(reg) page_source.scan(reg).flatten.first end |
#grab_link(_link) ⇒ Object
24 25 26 |
# File 'lib/ids_please/grabbers/base.rb', line 24 def grab_link(_link) throw 'Base grabber can not grab anything' end |
#inspect ⇒ Object
51 52 53 |
# File 'lib/ids_please/grabbers/base.rb', line 51 def inspect to_s end |
#record_error(event, message) ⇒ Object
63 64 65 |
# File 'lib/ids_please/grabbers/base.rb', line 63 def record_error(event, ) errors << "#{event} has #{}" end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ids_please/grabbers/base.rb', line 39 def to_h { avatar: avatar, display_name: display_name, username: username, link: link, page_source: page_source, network_id: network_id, data: data } end |
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ids_please/grabbers/base.rb', line 28 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 |