Class: Peachy::Parsers::REXMLWrapper

Inherits:
ParserWrapper show all
Defined in:
lib/peachy/parsers/rexml_wrapper.rb

Instance Method Summary collapse

Methods inherited from ParserWrapper

#create_from_element

Constructor Details

#initialize(rexml_element) ⇒ REXMLWrapper

Returns a new instance of REXMLWrapper.



6
7
8
# File 'lib/peachy/parsers/rexml_wrapper.rb', line 6

def initialize rexml_element
  @rexml = rexml_element
end

Instance Method Details

#contentObject



25
26
27
# File 'lib/peachy/parsers/rexml_wrapper.rb', line 25

def content
  @rexml.text
end

#find_match_by_attributes(method_name) ⇒ Object



16
17
18
19
# File 'lib/peachy/parsers/rexml_wrapper.rb', line 16

def find_match_by_attributes method_name
  match = @rexml.attributes.find {|attribute| method_name.variations.include? attribute.first }
  match.nil? ? nil : REXMLAttributeWrapper.new(match)
end

#find_matches(method_name) ⇒ Object



10
11
12
13
14
# File 'lib/peachy/parsers/rexml_wrapper.rb', line 10

def find_matches method_name
  matches = REXML::XPath.match(@rexml, method_name.as_xpath)
  return nil if matches.size < 1
  matches.map {|node| REXMLWrapper.new(node)}
end

#has_children_and_attributes?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/peachy/parsers/rexml_wrapper.rb', line 21

def has_children_and_attributes?
  has_children? and has_attributes?
end