Class: RUUID::UUID
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #===(other) ⇒ Object
- #as_json ⇒ Object
- #hash ⇒ Object
-
#initialize(data = RUUID.default_generator.generate) ⇒ UUID
constructor
A new instance of UUID.
- #inspect ⇒ Object
- #to_json(*args) ⇒ Object
- #to_s(format = RUUID.default_format) ⇒ Object (also: #to_str)
- #version ⇒ Object
Constructor Details
#initialize(data = RUUID.default_generator.generate) ⇒ UUID
Returns a new instance of UUID.
9 10 11 12 |
# File 'lib/ruuid/uuid.rb', line 9 def initialize(data = RUUID.default_generator.generate) @data = normalize(data) validate end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
14 15 16 |
# File 'lib/ruuid/uuid.rb', line 14 def data @data end |
Class Method Details
.parse(string) ⇒ Object
5 6 7 |
# File 'lib/ruuid/uuid.rb', line 5 def self.parse(string) new(Parser.parse(string)) end |
Instance Method Details
#<=>(other) ⇒ Object
59 60 61 62 |
# File 'lib/ruuid/uuid.rb', line 59 def <=>(other) return super unless other.respond_to?(:data) data <=> other.data end |
#==(other) ⇒ Object Also known as: eql?
48 49 50 51 |
# File 'lib/ruuid/uuid.rb', line 48 def ==(other) return super unless other.respond_to?(:data) data == other.data end |
#===(other) ⇒ Object
54 55 56 57 |
# File 'lib/ruuid/uuid.rb', line 54 def ===(other) return super unless other.respond_to?(:to_str) to_str === other.to_str end |
#as_json ⇒ Object
21 22 23 |
# File 'lib/ruuid/uuid.rb', line 21 def as_json(*) to_s end |
#hash ⇒ Object
44 45 46 |
# File 'lib/ruuid/uuid.rb', line 44 def hash data.hash end |
#inspect ⇒ Object
29 30 31 |
# File 'lib/ruuid/uuid.rb', line 29 def inspect "<#{self.class}:0x#{object_id} data=#{to_s}>" end |
#to_json(*args) ⇒ Object
25 26 27 |
# File 'lib/ruuid/uuid.rb', line 25 def to_json(*args) to_s(*args).to_json end |
#to_s(format = RUUID.default_format) ⇒ Object Also known as: to_str
16 17 18 |
# File 'lib/ruuid/uuid.rb', line 16 def to_s(format = RUUID.default_format) Formatter.format(data, format) end |
#version ⇒ Object
64 65 66 |
# File 'lib/ruuid/uuid.rb', line 64 def version data.bytes[6] >> 4 end |