Class: Spidy::Binder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/spidy/binder.rb

Direct Known Subclasses

Html, Json, Xml

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(define_name, spidy, resource, url) ⇒ Base

Returns a new instance of Base.



33
34
35
36
37
38
# File 'lib/spidy/binder.rb', line 33

def initialize(define_name, spidy, resource, url)
  @define_name = define_name
  @spidy = spidy
  @resource = resource
  @url = url
end

Class Attribute Details

.attribute_namesObject (readonly)

Returns the value of attribute attribute_names.



28
29
30
# File 'lib/spidy/binder.rb', line 28

def attribute_names
  @attribute_names
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



31
32
33
# File 'lib/spidy/binder.rb', line 31

def resource
  @resource
end

#urlObject (readonly)

Returns the value of attribute url.



31
32
33
# File 'lib/spidy/binder.rb', line 31

def url
  @url
end

Instance Method Details

#to_hObject



44
45
46
# File 'lib/spidy/binder.rb', line 44

def to_h
  self.class.attribute_names.map { |name| [name, send(name)] }.to_h
end

#to_sObject



40
41
42
# File 'lib/spidy/binder.rb', line 40

def to_s
  to_h.to_json
end