Sha256: e0a9f5801c567d92e4f0e71cbe1d58200347441cb4a4072471429e6cf2f84c27

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

module LibXMLJRuby
  module XML
    class Attr < Node
      class << self
        def from_java(java_obj)
          return nil unless java_obj
          a = allocate
          a.java_obj = java_obj
          a
        end
      end
      
      attr_accessor :java_obj
      
      def initialize(node, name, value, ns = nil)
        self.java_obj = node.java_obj
        java_obj.set_attribute(name, value)
      end
      
      def remove!
        java_obj.owner_element.remove_attribute(name)
      end
      
      def parent?
        !!parent
      end
      
      def parent
        LibXMLJRuby::XML::Node.from_java(java_obj.owner_element)
      end
      
      def name
        java_obj.respond_to?(:name) ? java_obj.name : java_obj.node_name
      end
      
      def value
        java_obj.value
      end
      
      def value=(value)
        raise TypeError if value.nil?
        java_obj.value = value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
libxml-fixed-jruby-1.0.0-jruby lib/libxml-jruby/xml/attr.rb
libxml-jruby-fixed-1.0.0-jruby lib/libxml-jruby/xml/attr.rb