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.
10 11 12 13 |
# File 'lib/spidy/definition_object.rb', line 10 def initialize(resource, url) @resource = resource @url = url end |
Class Attribute Details
.attribute_names ⇒ Object (readonly)
Returns the value of attribute attribute_names.
6 7 8 |
# File 'lib/spidy/definition_object.rb', line 6 def attribute_names @attribute_names end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'lib/spidy/definition_object.rb', line 8 def resource @resource end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/spidy/definition_object.rb', line 8 def url @url end |
Instance Method Details
#to_h ⇒ Object
19 20 21 |
# File 'lib/spidy/definition_object.rb', line 19 def to_h self.class.attribute_names.to_h { |name| [name, send(name)] } end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/spidy/definition_object.rb', line 15 def to_s to_h.to_json end |