Class: HasOnePropertyDefinition
- Inherits:
-
Object
- Object
- HasOnePropertyDefinition
- Defined in:
- lib/doc_wrapper/has_one_property_definition.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
Returns the value of attribute klass.
-
#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.
Instance Method Summary collapse
-
#initialize(property_name, selector, klass, options) ⇒ HasOnePropertyDefinition
constructor
A new instance of HasOnePropertyDefinition.
- #property(documents) ⇒ Object
Constructor Details
#initialize(property_name, selector, klass, options) ⇒ HasOnePropertyDefinition
Returns a new instance of HasOnePropertyDefinition.
5 6 7 8 9 10 |
# File 'lib/doc_wrapper/has_one_property_definition.rb', line 5 def initialize (property_name, selector, klass, ) @property_name = property_name @selector = selector @klass = klass @options = end |
Instance Attribute Details
#klass ⇒ Object
Returns the value of attribute klass.
3 4 5 |
# File 'lib/doc_wrapper/has_one_property_definition.rb', line 3 def klass @klass end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/doc_wrapper/has_one_property_definition.rb', line 3 def @options end |
#property_name ⇒ Object
Returns the value of attribute property_name.
3 4 5 |
# File 'lib/doc_wrapper/has_one_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/has_one_property_definition.rb', line 3 def selector @selector end |
Instance Method Details
#property(documents) ⇒ Object
12 13 14 15 |
# File 'lib/doc_wrapper/has_one_property_definition.rb', line 12 def property (documents) nodes = documents.collect { |doc| result = doc.search(selector) ; result.blank? ? nil : result }.flatten.compact klass.new(nodes) end |