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

Version Path
epub-parser-0.3.7 lib/epub/parser/utils.rb
epub-parser-0.3.6 lib/epub/parser/utils.rb
epub-parser-0.3.5 lib/epub/parser/utils.rb
epub-parser-0.3.4 lib/epub/parser/utils.rb
epub-parser-0.3.3 lib/epub/parser/utils.rb
epub-parser-0.3.2 lib/epub/parser/utils.rb
epub-parser-0.3.1 lib/epub/parser/utils.rb
epub-parser-0.3.0 lib/epub/parser/utils.rb
epub-parser-0.2.9 lib/epub/parser/utils.rb
epub-parser-0.2.8 lib/epub/parser/utils.rb
epub-parser-0.2.7 lib/epub/parser/utils.rb
epub-parser-0.2.6 lib/epub/parser/utils.rb
epub-parser-0.2.5 lib/epub/parser/utils.rb
epub-parser-0.2.4 lib/epub/parser/utils.rb
epub-parser-0.2.3 lib/epub/parser/utils.rb
epub-parser-0.2.2 lib/epub/parser/utils.rb
epub-parser-0.2.1 lib/epub/parser/utils.rb