Class: REXML::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/feed_tools/monkey_patch.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#base_uriObject

:nodoc:



640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/feed_tools/monkey_patch.rb', line 640

def base_uri # :nodoc:
  begin
    base_attribute = FeedTools::XmlHelper.try_xpaths(self, [
      '@xml:base'
    ])
    if parent == nil || parent.kind_of?(REXML::Document)
      return nil if base_attribute == nil
      return base_attribute.value
    end
    if base_attribute != nil && parent == nil
      return base_attribute.value
    elsif parent != nil && base_attribute == nil
      return parent.base_uri
    elsif parent != nil && base_attribute != nil
      parent_base_uri = parent.base_uri
      if parent_base_uri != nil
        uri = URI.parse(parent_base_uri)
        return (uri + base_attribute.value).to_s
      else
        return base_attribute.value
      end
    end
    return nil
  rescue
    return nil
  end
end

#inner_xmlObject

:nodoc:



625
626
627
628
629
630
631
632
633
634
635
# File 'lib/feed_tools/monkey_patch.rb', line 625

def inner_xml # :nodoc:
  result = ""
  self.each_child do |child|
    if child.kind_of? REXML::Comment
      result << "<!--" + child.to_s + "-->"
    else
      result << child.to_s
    end
  end
  return result.strip
end