Class: VCDOM::XPath::Internal::AbstractValue

Inherits:
Object
  • Object
show all
Defined in:
lib/vcdom/xpath/internal/value.rb

Overview

:nodoc:

Direct Known Subclasses

BooleanValue, NodeSetValue, NumberValue, StringValue

Instance Method Summary collapse

Instance Method Details

#%(val) ⇒ Object



20
# File 'lib/vcdom/xpath/internal/value.rb', line 20

def %( val ); self.to_number_value % val end

#*(val) ⇒ Object



18
# File 'lib/vcdom/xpath/internal/value.rb', line 18

def *( val ); self.to_number_value * val end

#+(val) ⇒ Object



16
# File 'lib/vcdom/xpath/internal/value.rb', line 16

def +( val ); self.to_number_value + val end

#-(val) ⇒ Object



17
# File 'lib/vcdom/xpath/internal/value.rb', line 17

def -( val ); self.to_number_value - val end

#-@Object



15
# File 'lib/vcdom/xpath/internal/value.rb', line 15

def -@(); - self.to_number_value end

#/(val) ⇒ Object



19
# File 'lib/vcdom/xpath/internal/value.rb', line 19

def /( val ); self.to_number_value / val end

#<(val) ⇒ Object



55
56
57
# File 'lib/vcdom/xpath/internal/value.rb', line 55

def <( val )
  ( self <=> val ) < 0 ? BooleanValue.true : BooleanValue.false
end

#<=(val) ⇒ Object



58
59
60
# File 'lib/vcdom/xpath/internal/value.rb', line 58

def <=( val )
  ( self <=> val ) <= 0 ? BooleanValue.true : BooleanValue.false
end

#<=>(val) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/vcdom/xpath/internal/value.rb', line 48

def <=>( val )
  if val.value_type == :node_set then
    return ( val <=> self ) * -1
  else
    return self.to_number_value.value <=> val.to_number_value.value
  end
end

#==(val) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vcdom/xpath/internal/value.rb', line 26

def ==( val )
  types = [ self.value_type, val.value_type ]
  if types.include? :boolean then
    return val.to_boolean_value.value == self.to_boolean_value.value ? BooleanValue.true : BooleanValue.false
  elsif types.include? :node_set then
    # TODO : node-set が含まれている場合
    val == self
  elsif types.include? :number
    return val.to_number_value.value == self.to_number_value.value ? BooleanValue.true : BooleanValue.false
  else
    return val.to_string_value.value == self.to_string_value.value ? BooleanValue.true : BooleanValue.false
  end
end

#>(val) ⇒ Object



61
62
63
# File 'lib/vcdom/xpath/internal/value.rb', line 61

def >( val )
  ( self <=> val ) > 0 ? BooleanValue.true : BooleanValue.false
end

#>=(val) ⇒ Object



64
65
66
# File 'lib/vcdom/xpath/internal/value.rb', line 64

def >=( val )
  ( self <=> val ) >= 0 ? BooleanValue.true : BooleanValue.false
end

#is_command?Boolean

Returns:

  • (Boolean)


9
# File 'lib/vcdom/xpath/internal/value.rb', line 9

def is_command?; false end

#is_expr?Boolean

Returns:

  • (Boolean)


8
# File 'lib/vcdom/xpath/internal/value.rb', line 8

def is_expr?;    false end

#is_value?Boolean

Returns:

  • (Boolean)


7
# File 'lib/vcdom/xpath/internal/value.rb', line 7

def is_value?;   true  end

#neq?(val) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
# File 'lib/vcdom/xpath/internal/value.rb', line 40

def neq?( val )
  if val.value_type == :node_set then
    return val.neq? self
  else
    return ( self == val ? BooleanValue.false : BooleanValue.true )
  end
end

#to_sObject



11
12
13
# File 'lib/vcdom/xpath/internal/value.rb', line 11

def to_s()
  "XPathValue(#{value})"
end

#|(val) ⇒ Object



22
23
24
# File 'lib/vcdom/xpath/internal/value.rb', line 22

def |( val )
  raise "User Error : xpath operator \"|\" must operate NodeSet"
end