Class: DocWrapper::BasePropertyDefinition
- Inherits:
-
Object
- Object
- DocWrapper::BasePropertyDefinition
- Defined in:
- lib/doc_wrapper/base_property_definition.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#options ⇒ Object
Returns the value of attribute options.
-
#property_name ⇒ Object
Returns the value of attribute property_name.
-
#selector ⇒ Object
Returns the value of attribute selector.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(property_name, type, selector, options, block) ⇒ BasePropertyDefinition
constructor
A new instance of BasePropertyDefinition.
- #property(documents) ⇒ Object
- #transform(result) ⇒ Object
Constructor Details
#initialize(property_name, type, selector, options, block) ⇒ BasePropertyDefinition
Returns a new instance of BasePropertyDefinition.
5 6 7 8 9 10 11 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 5 def initialize (property_name, type, selector, , block) @property_name = property_name @type = type @selector = selector = @block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 3 def block @block end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 3 def end |
#property_name ⇒ Object
Returns the value of attribute property_name.
3 4 5 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 3 def property_name @property_name end |
#selector ⇒ Object
Returns the value of attribute selector.
3 4 5 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 3 def selector @selector end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 3 def type @type end |
Instance Method Details
#property(documents) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 13 def property (documents) if [:namespaces] transform(documents[[:document] - 1].xpath(@selector, [:namespaces] )) else begin transform(documents[[:document] - 1].search(@selector)) rescue Nokogiri::CSS::SyntaxError transform(documents[[:document] - 1].xpath(@selector)) end end end |
#transform(result) ⇒ Object
25 26 27 |
# File 'lib/doc_wrapper/base_property_definition.rb', line 25 def transform (result) result end |