class PIM::NodeValue

Attributes

attributes[RW]
value[R]

Public Class Methods

new(value) click to toggle source
# File pim.rb, line 2164
def initialize(value)
  @value = value
  @attributes = {}
end

Public Instance Methods

!() click to toggle source
# File pim.rb, line 2199
def !
  assimilate(false) == false
end
!=(other) click to toggle source
# File pim.rb, line 2174
def !=(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) != other
end
*(other) click to toggle source
# File pim.rb, line 2203
def *(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) * other
end
+(other) click to toggle source
# File pim.rb, line 2208
def +(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) + other
end
<(other) click to toggle source
# File pim.rb, line 2189
def <(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) < other
end
<=(other) click to toggle source
# File pim.rb, line 2194
def <=(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) <= other
end
==(other) click to toggle source
# File pim.rb, line 2169
def ==(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) == other
end
>(other) click to toggle source
# File pim.rb, line 2179
def >(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) > other
end
>=(other) click to toggle source
# File pim.rb, line 2184
def >=(other)
  other = other.value if other.is_a?(NodeValue)
  assimilate(other) >= other
end
[](key) click to toggle source
# File pim.rb, line 2255
def [](key)
  @attributes["#{key}"]
end
assimilate(other) click to toggle source
# File pim.rb, line 2213
def assimilate(other)
  case other
  when Integer
    value.to_i
  when Float
    value.to_f
  when FalseClass, TrueClass
    not ['', 'false'].include?(value.to_s.downcase)
  when Date
    Date.parse(value)
  when DateTime
    DateTime.parse(value)
  else
    case value
    when 'true'
      true
    when 'false'
      false
    when nil
      value
    else
      value.to_s
    end
  end
end
fetch(key, other) click to toggle source
# File pim.rb, line 2259
def fetch(key, other)
  @attributes.fetch(key, other)
end
nil?() click to toggle source
# File pim.rb, line 2263
def nil?
  value == nil
end
to_date() click to toggle source
# File pim.rb, line 2251
def to_date
  Date.parse(value)
end
to_f() click to toggle source
# File pim.rb, line 2247
def to_f
  value.to_f
end
to_i() click to toggle source
# File pim.rb, line 2243
def to_i
  value.to_i
end
to_json() click to toggle source
# File pim.rb, line 2267
def to_json
  value.to_json
end
to_s() click to toggle source
# File pim.rb, line 2239
def to_s
  value
end