Class: Spidy::DefinitionObject
- Inherits:
-
Object
- Object
- Spidy::DefinitionObject
- Defined in:
- lib/spidy/definition_object.rb
Overview
An object that represents the scraper defined by define block.
Class Attribute Summary collapse
-
.attribute_names ⇒ Object
readonly
Returns the value of attribute attribute_names.
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(resource, url) ⇒ DefinitionObject
constructor
A new instance of DefinitionObject.
- #to_h ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(resource, url) ⇒ DefinitionObject
Returns a new instance of DefinitionObject.
12 13 14 15 |
# File 'lib/spidy/definition_object.rb', line 12 def initialize(resource, url) @resource = resource @url = url end |
Class Attribute Details
.attribute_names ⇒ Object (readonly)
Returns the value of attribute attribute_names.
8 9 10 |
# File 'lib/spidy/definition_object.rb', line 8 def attribute_names @attribute_names end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
10 11 12 |
# File 'lib/spidy/definition_object.rb', line 10 def resource @resource end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/spidy/definition_object.rb', line 10 def url @url end |
Instance Method Details
#to_h ⇒ Object
21 22 23 |
# File 'lib/spidy/definition_object.rb', line 21 def to_h self.class.attribute_names.to_h { |name| [name, send(name)] } end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/spidy/definition_object.rb', line 17 def to_s to_h.to_json end |