Class: DocWrapper::InnerHtmlPropertyDefinition

Inherits:
BasePropertyDefinition show all
Defined in:
lib/doc_wrapper/inner_html_property_definition.rb

Instance Attribute Summary

Attributes inherited from BasePropertyDefinition

#block, #options, #property_name, #selector, #type

Instance Method Summary collapse

Methods inherited from BasePropertyDefinition

#initialize, #transform

Constructor Details

This class inherits a constructor from DocWrapper::BasePropertyDefinition

Instance Method Details

#get_nodes(documents) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/doc_wrapper/inner_html_property_definition.rb', line 15

def get_nodes (documents)
  if options[:namespaces]
    documents[@options[:document] - 1].xpath(@selector, options[:namespaces])
  else
    begin
      documents[@options[:document] - 1].search(@selector)
    rescue Nokogiri::CSS::SyntaxError
      documents[@options[:document] - 1].xpath(@selector)
    end
  end
end

#property(documents) ⇒ Object



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

def property (documents)
  transform(raw_property(documents))
end

#raw_property(documents) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/doc_wrapper/inner_html_property_definition.rb', line 7

def raw_property (documents)
  if options[:use_attribute]
    get_nodes(documents).first[options[:use_attribute]]
  else
    get_nodes(documents).inner_html.strip
  end
end