Class: Orientdb::RecordId
- Inherits:
-
Object
- Object
- Orientdb::RecordId
- Defined in:
- lib/orientdb_binary/record_id.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#position ⇒ Object
Returns the value of attribute position.
Instance Method Summary collapse
- #==(o) ⇒ Object
- #eql? ⇒ Object
-
#initialize(rid = nil) ⇒ RecordId
constructor
A new instance of RecordId.
- #parse_rid(rid) ⇒ Object
- #temporary? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(rid = nil) ⇒ RecordId
Returns a new instance of RecordId.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/orientdb_binary/record_id.rb', line 7 def initialize(rid=nil) @cluster = nil @position = nil if rid.is_a? String and not rid.empty? parse_rid(rid) elsif rid.is_a? Orientdb::RecordId @cluster = rid.cluster @position = rid.position end end |
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
3 4 5 |
# File 'lib/orientdb_binary/record_id.rb', line 3 def cluster @cluster end |
#position ⇒ Object
Returns the value of attribute position.
3 4 5 |
# File 'lib/orientdb_binary/record_id.rb', line 3 def position @position end |
Instance Method Details
#==(o) ⇒ Object
33 34 35 |
# File 'lib/orientdb_binary/record_id.rb', line 33 def ==(o) o.class == self.class && o.cluster == self.cluster && o.position == self.position end |
#eql? ⇒ Object
5 |
# File 'lib/orientdb_binary/record_id.rb', line 5 alias_method :eql?, :== |
#parse_rid(rid) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/orientdb_binary/record_id.rb', line 18 def parse_rid(rid) match = rid.match(/^[#]?(?<cluster>-?\d+):(?<position>\d+)$/) @cluster = match[:cluster].to_i @position = match[:position].to_i self end |
#temporary? ⇒ Boolean
29 30 31 |
# File 'lib/orientdb_binary/record_id.rb', line 29 def temporary? @cluster < 0 end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/orientdb_binary/record_id.rb', line 25 def to_s "##{cluster}:#{position}" end |