Class: Saxon::XDM::Map
Overview
Class Method Summary
collapse
Instance Method Summary
collapse
#sequence_enum, #sequence_size
#append, #sequence_enum, #sequence_size
Constructor Details
#initialize(s9_xdm_map) ⇒ Map
This method is part of a private API.
You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Map.
29
30
31
|
# File 'lib/saxon/xdm/map.rb', line 29
def initialize(s9_xdm_map)
@s9_xdm_map = s9_xdm_map
end
|
Class Method Details
.create(hash) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/saxon/xdm/map.rb', line 8
def self.create(hash)
case hash
when Saxon::S9API::XdmMap
new(hash)
else
new(S9API::XdmMap.new(Hash[
hash.map { |key, value|
[XDM.AtomicValue(key).to_java, XDM.Value(value).to_java]
}
]))
end
end
|
Instance Method Details
#==(other) ⇒ Object
33
34
35
36
|
# File 'lib/saxon/xdm/map.rb', line 33
def ==(other)
return false unless other.is_a?(self.class)
to_h == other.to_h
end
|
#[](key) ⇒ Object
38
39
40
|
# File 'lib/saxon/xdm/map.rb', line 38
def [](key)
cached_hash[XDM.AtomicValue(key)]
end
|
#each(&block) ⇒ Object
46
47
48
|
# File 'lib/saxon/xdm/map.rb', line 46
def each(&block)
cached_hash.each(&block)
end
|
#fetch(key, *args, &block) ⇒ Object
42
43
44
|
# File 'lib/saxon/xdm/map.rb', line 42
def fetch(key, *args, &block)
cached_hash.fetch(XDM.AtomicValue(key), *args, &block)
end
|
#merge(other) ⇒ Object
58
59
60
|
# File 'lib/saxon/xdm/map.rb', line 58
def merge(other)
self.class.create(to_h.merge(other.to_h))
end
|
#reject(&block) ⇒ Object
54
55
56
|
# File 'lib/saxon/xdm/map.rb', line 54
def reject(&block)
self.class.create(each.reject(&block).to_h)
end
|
#select(&block) ⇒ Object
50
51
52
|
# File 'lib/saxon/xdm/map.rb', line 50
def select(&block)
self.class.create(each.select(&block).to_h)
end
|
#to_h ⇒ Object
66
67
68
|
# File 'lib/saxon/xdm/map.rb', line 66
def to_h
cached_hash
end
|
#to_java ⇒ Object
62
63
64
|
# File 'lib/saxon/xdm/map.rb', line 62
def to_java
@s9_xdm_map
end
|