Class: Peanuts::Mapping

Inherits:
Object
  • Object
show all
Defined in:
lib/peanuts/mappings.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_name, options) ⇒ Mapping

Returns a new instance of Mapping.



11
12
13
# File 'lib/peanuts/mappings.rb', line 11

def initialize(local_name, options)
  @local_name, @namespace_uri, @prefix, @options = local_name.to_s, options.delete(:ns), options.delete(:prefix), options
end

Instance Attribute Details

#local_nameObject (readonly)

Returns the value of attribute local_name.



9
10
11
# File 'lib/peanuts/mappings.rb', line 9

def local_name
  @local_name
end

#namespace_uriObject (readonly)

Returns the value of attribute namespace_uri.



9
10
11
# File 'lib/peanuts/mappings.rb', line 9

def namespace_uri
  @namespace_uri
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/peanuts/mappings.rb', line 9

def options
  @options
end

#prefixObject (readonly)

Returns the value of attribute prefix.



9
10
11
# File 'lib/peanuts/mappings.rb', line 9

def prefix
  @prefix
end

Class Method Details

.node_type(node_type) ⇒ Object



21
22
23
# File 'lib/peanuts/mappings.rb', line 21

def self.node_type(node_type)
  define_method(:node_type) { node_type }
end

Instance Method Details

#matches?(reader) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/peanuts/mappings.rb', line 15

def matches?(reader)
  node_type == reader.node_type &&
    local_name == reader.local_name &&
    namespace_uri == reader.namespace_uri
end