class Value
BASE CLASS == Value
… a wrapper for any ruby object
Public Class Methods
freeze_raise?()
click to toggle source
# File lib/primitive_wrapper.rb, line 146 def self.freeze_raise? @freeze_raise end
ignore_on_freeze()
click to toggle source
# File lib/primitive_wrapper.rb, line 143 def self.ignore_on_freeze @freeze_raise = false end
new(obj=nil)
click to toggle source
# File lib/primitive_wrapper.rb, line 151 def initialize(obj=nil) obj = obj.prim_value ensure_valid(obj) @value = obj end
raise_on_freeze()
click to toggle source
# File lib/primitive_wrapper.rb, line 140 def self.raise_on_freeze @freeze_raise = true end
Public Instance Methods
!=(other)
click to toggle source
# File lib/primitive_wrapper.rb, line 209 def !=(other) other.prim_value != @value end
==(other)
click to toggle source
# File lib/primitive_wrapper.rb, line 205 def ==(other) other.prim_value == @value end
ensure_valid(obj, mess = "Incompatible type")
click to toggle source
# File lib/primitive_wrapper.rb, line 175 def ensure_valid(obj, mess = "Incompatible type") unless valid_type(obj) raise mess end end
freeze()
click to toggle source
# File lib/primitive_wrapper.rb, line 181 def freeze # never allow the wrapper to be frozen raise "this object cannot be frozen" if self.class.freeze_raise? end
inspect()
click to toggle source
# File lib/primitive_wrapper.rb, line 225 def inspect str = @value.nil? ? "nil" : @value.inspect "(#{self.class}==>#{str})" end
prim_value()
click to toggle source
# File lib/primitive_wrapper.rb, line 197 def prim_value @value end
replace(other)
click to toggle source
# File lib/primitive_wrapper.rb, line 217 def replace(other) @value = other.prim_value if valid_type(other) end
to_s()
click to toggle source
# File lib/primitive_wrapper.rb, line 221 def to_s @value.to_s end
to_wrapper()
click to toggle source
# File lib/primitive_wrapper.rb, line 157 def to_wrapper self end
type()
click to toggle source
# File lib/primitive_wrapper.rb, line 171 def type @value.class end
type_of?(cls)
click to toggle source
# File lib/primitive_wrapper.rb, line 165 def type_of?(cls) return true if @value.kind_of? cls return true if self.kind_of? cls false end
unwrap()
click to toggle source
# File lib/primitive_wrapper.rb, line 201 def unwrap @value end
val()
click to toggle source
# File lib/primitive_wrapper.rb, line 185 def val @value end
val=(dat)
click to toggle source
# File lib/primitive_wrapper.rb, line 193 def val=(dat) replace(dat) end
valid_type(prm=nil)
click to toggle source
# File lib/primitive_wrapper.rb, line 213 def valid_type(prm=nil) true end
wrapped?()
click to toggle source
# File lib/primitive_wrapper.rb, line 161 def wrapped? true end
~()
click to toggle source
# File lib/primitive_wrapper.rb, line 189 def ~ @value end