Class: Antlr4::Runtime::UUID
- Inherits:
-
Object
- Object
- Antlr4::Runtime::UUID
- Defined in:
- lib/antlr4/runtime/uuid.rb
Instance Attribute Summary collapse
-
#lower ⇒ Object
readonly
Returns the value of attribute lower.
-
#upper ⇒ Object
readonly
Returns the value of attribute upper.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(upper, lower) ⇒ UUID
constructor
A new instance of UUID.
- #to_s ⇒ Object
Constructor Details
#initialize(upper, lower) ⇒ UUID
Returns a new instance of UUID.
6 7 8 9 |
# File 'lib/antlr4/runtime/uuid.rb', line 6 def initialize(upper, lower) @lower = lower @upper = upper end |
Instance Attribute Details
#lower ⇒ Object (readonly)
Returns the value of attribute lower.
4 5 6 |
# File 'lib/antlr4/runtime/uuid.rb', line 4 def lower @lower end |
#upper ⇒ Object (readonly)
Returns the value of attribute upper.
3 4 5 |
# File 'lib/antlr4/runtime/uuid.rb', line 3 def upper @upper end |
Class Method Details
.decode(hex_string) ⇒ Object
42 43 44 |
# File 'lib/antlr4/runtime/uuid.rb', line 42 def self.decode(hex_string) hex_string.to_i(16) end |
.from_string(name) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/antlr4/runtime/uuid.rb', line 23 def self.from_string(name) components = name.split('-') if components.length != 5 raise IllegalArgumentException, 'Invalid UUID string: ' + name end upper = decode(components[0]) upper = upper << 16 upper |= decode(components[1]) upper = upper << 16 upper |= decode(components[2]) lower = decode(components[3]) lower = lower << 48 lower |= decode(components[4]) UUID.new(upper, lower) end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/antlr4/runtime/uuid.rb', line 15 def ==(other) if !other.nil? @lower == other.lower && @upper == other.upper else false end end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/antlr4/runtime/uuid.rb', line 11 def to_s @upper.to_s + @lower.to_s end |