Class: Rubyang::Xpath::BasicType::NodeSet
- Inherits:
-
Object
- Object
- Rubyang::Xpath::BasicType::NodeSet
- Includes:
- Enumerable
- Defined in:
- lib/rubyang/xpath.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #!=(right) ⇒ Object
- #==(right) ⇒ Object
- #each ⇒ Object
-
#initialize(value = []) ⇒ NodeSet
constructor
A new instance of NodeSet.
- #to_boolean ⇒ Object
Constructor Details
#initialize(value = []) ⇒ NodeSet
Returns a new instance of NodeSet.
15 16 17 18 19 20 21 22 23 |
# File 'lib/rubyang/xpath.rb', line 15 def initialize value=[] raise "#{self.class} argument must be Array but #{value.class}" unless Array === value value.each{ |v| unless Rubyang::Database::DataTree::Node === v raise "#{self.class} argument must be Rubyang::Database::DataTree::Node but #{v.class}" end } @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
14 15 16 |
# File 'lib/rubyang/xpath.rb', line 14 def value @value end |
Instance Method Details
#!=(right) ⇒ Object
67 68 69 70 |
# File 'lib/rubyang/xpath.rb', line 67 def != right value = ! (self == right).value Boolean.new value end |
#==(right) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rubyang/xpath.rb', line 36 def == right @value.each{ |v| unless Rubyang::Database::DataTree::Leaf === v raise "#{self.class} argument must be Rubyang::Database::DataTree::Leaf but #{v.class}" end } case right when NodeSet right.value.each{ |v| unless Rubyang::Database::DataTree::Leaf === v raise "#{right.class} argument must be Rubyang::Database::DataTree::Leaf but #{v.class}" end } value = if (@value.map{ |v| v.value } & right.value.map{ |v| v.value }).size > 0 then true else false end Boolean.new value when Boolean value = if @value.size > 0 if right.value then true else false end else if right.value then false else true end end Boolean.new value when Number value = @value.any?{ |v| Float(v.value) == right.value rescue false } Boolean.new value when String value = @value.any?{ |v| v.value == right.value } Boolean.new value end end |
#each ⇒ Object
25 26 27 28 29 |
# File 'lib/rubyang/xpath.rb', line 25 def each @value.each do |v| yield v end end |