class GxG::Tuple
Public Class Methods
new(key=nil,value=nil)
click to toggle source
Inspired by Python's Tuple class, in this case: allows any object to be a key for any other object Monkey-patch notes: stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i (Array integration)
# File lib/gxg/gxg_elements.rb, line 397 def initialize(key=nil,value=nil) @thread_safety = ::Mutex.new @key = key @value = value end
Public Instance Methods
<=>(other_value=nil)
click to toggle source
# File lib/gxg/gxg_elements.rb, line 417 def <=>(other_value=nil) if other_value.respone_to?(:<=>) if other_value.is_a?(GxG::Tuple) @thread_safety.synchronize { @value <=> other_value.value } else @thread_safety.synchronize { @value <=> other_value } end else # taking liberties here, if other object does not support compare, then this obj is construed as greater than. (bias) 1 end end
inspect()
click to toggle source
# File lib/gxg/gxg_elements.rb, line 432 def inspect() @thread_safety.synchronize { "#{@key.inspect} => #{@value.inspect}" } end
key()
click to toggle source
# File lib/gxg/gxg_elements.rb, line 403 def key() @thread_safety.synchronize { @key } end
key=(new_key=nil)
click to toggle source
# File lib/gxg/gxg_elements.rb, line 406 def key= (new_key=nil) @thread_safety.synchronize { @key = new_key } end
to_s()
click to toggle source
# File lib/gxg/gxg_elements.rb, line 429 def to_s() @thread_safety.synchronize { @value.to_s } end
value()
click to toggle source
# File lib/gxg/gxg_elements.rb, line 410 def value() @thread_safety.synchronize { @value } end
value=(new_value=nil)
click to toggle source
# File lib/gxg/gxg_elements.rb, line 413 def value= (new_value=nil) @thread_safety.synchronize { @value = new_value } end