Class: OrientDB::RID

Inherits:
Object
  • Object
show all
Defined in:
lib/orientdb/rid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rid = '#-1:-1') ⇒ RID

Returns a new instance of RID.



5
6
7
8
9
10
11
12
13
# File 'lib/orientdb/rid.rb', line 5

def initialize(rid = '#-1:-1')
  parts = rid.to_s.gsub('#', '').split ":"
  if parts.size == 2
    self.cluster_id = parts.first.to_i
    self.document_id = parts.last.to_i
  else
    raise "Unknown rid [#{rid}]"
  end
end

Instance Attribute Details

#cluster_idObject

Returns the value of attribute cluster_id.



3
4
5
# File 'lib/orientdb/rid.rb', line 3

def cluster_id
  @cluster_id
end

#document_idObject

Returns the value of attribute document_id.



3
4
5
# File 'lib/orientdb/rid.rb', line 3

def document_id
  @document_id
end

Instance Method Details

#inspectObject Also known as: to_s



23
24
25
# File 'lib/orientdb/rid.rb', line 23

def inspect
  "##{cluster_id}:#{@document_id}"
end

#saved?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/orientdb/rid.rb', line 33

def saved?
  cluster_id > 0 && document_id >= 0
end

#unsaved?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/orientdb/rid.rb', line 29

def unsaved?
  to_s == '#-1:-1'
end

#valid?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/orientdb/rid.rb', line 37

def valid?
  saved? || unsaved?
end