Class: Guid
Overview
The Guid class is what it says on the packet, but you can assert a :new one.
Instance Method Summary collapse
-
#<=>(o) ⇒ Object
:nodoc:.
- #==(value) ⇒ Object
-
#eql?(o) ⇒ Boolean
:nodoc:.
-
#equal?(value) ⇒ Boolean
if the value is unassigned, it equal?(:new).
-
#hash ⇒ Object
:nodoc:.
-
#initialize(i = :new) ⇒ Guid
constructor
A new instance of Guid.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(i = :new) ⇒ Guid
Returns a new instance of Guid.
17 18 19 20 21 22 23 24 25 |
# File 'lib/activefacts/api/guid.rb', line 17 def initialize(i = :new) if i == :new @value = SecureRandom.uuid.freeze elsif (v = i.to_s).length == 36 and !(v !~ /[^0-9a-f]/i) @value = v.clone.freeze else raise ArgumentError.new("Illegal non-Guid value #{i.inspect} given for Guid") end end |
Instance Method Details
#<=>(o) ⇒ Object
:nodoc:
52 53 54 |
# File 'lib/activefacts/api/guid.rb', line 52 def <=>(o) #:nodoc: to_s.<=>(o.to_s) end |
#==(value) ⇒ Object
36 37 38 |
# File 'lib/activefacts/api/guid.rb', line 36 def == value @value == value.to_s end |
#eql?(o) ⇒ Boolean
:nodoc:
48 49 50 |
# File 'lib/activefacts/api/guid.rb', line 48 def eql?(o) #:nodoc: to_s.eql?(o.to_s) end |
#equal?(value) ⇒ Boolean
if the value is unassigned, it equal?(:new).
32 33 34 |
# File 'lib/activefacts/api/guid.rb', line 32 def equal? value @value == value end |
#hash ⇒ Object
:nodoc:
44 45 46 |
# File 'lib/activefacts/api/guid.rb', line 44 def hash #:nodoc: @value.hash end |
#inspect ⇒ Object
40 41 42 |
# File 'lib/activefacts/api/guid.rb', line 40 def inspect "\#<Guid #{@value}>" end |
#to_s ⇒ Object
27 28 29 |
# File 'lib/activefacts/api/guid.rb', line 27 def to_s @value end |