Sha256: 3eaf2ce14f3791b05c3b4bb881c0d351fca8ba53f22363b0d374a4988ba36ffb
Contents?: true
Size: 778 Bytes
Versions: 17
Compression:
Stored size: 778 Bytes
Contents
module EPUB class Parser module Utils # Extract the value of attribute of element # # @todo Refinement Nokogiri::XML::Node instead of use this method after Ruby 2.0 becomes popular # # @param [Nokogiri::XML::Element] element # @param [String] name name of attribute excluding namespace prefix # @param [String, nil] prefix XML namespace prefix in {EPUB::NAMESPACES} keys # @return [String] value of attribute when the attribute exists # @return nil when the attribute doesn't exist def extract_attribute(element, name, prefix=nil) attr = element.attribute_with_ns(name, EPUB::NAMESPACES[prefix]) attr.nil? ? nil : attr.value end module_function :extract_attribute end end end
Version data entries
17 entries across 17 versions & 1 rubygems