Class: DocWrapper::BasePropertyDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/doc_wrapper/base_property_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options, block)
  @property_name = property_name
  @type = type
  @selector = selector
  @options = options
  @block = block
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



3
4
5
# File 'lib/doc_wrapper/base_property_definition.rb', line 3

def block
  @block
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/doc_wrapper/base_property_definition.rb', line 3

def options
  @options
end

#property_nameObject

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

#selectorObject

Returns the value of attribute selector.



3
4
5
# File 'lib/doc_wrapper/base_property_definition.rb', line 3

def selector
  @selector
end

#typeObject

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 options[:namespaces]
    transform(documents[@options[:document] - 1].xpath(@selector, options[:namespaces] ))
  else
    begin
      transform(documents[@options[:document] - 1].search(@selector))
    rescue Nokogiri::CSS::SyntaxError
      transform(documents[@options[: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