Class: OrientDB::RID
- Inherits:
-
Object
- Object
- OrientDB::RID
- Defined in:
- lib/orientdb/rid.rb
Instance Attribute Summary collapse
-
#cluster_id ⇒ Object
Returns the value of attribute cluster_id.
-
#document_id ⇒ Object
Returns the value of attribute document_id.
Instance Method Summary collapse
-
#initialize(rid = '#-1:-1') ⇒ RID
constructor
A new instance of RID.
- #inspect ⇒ Object (also: #to_s)
- #saved? ⇒ Boolean
- #unsaved? ⇒ Boolean
- #valid? ⇒ Boolean
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_id ⇒ Object
Returns the value of attribute cluster_id.
3 4 5 |
# File 'lib/orientdb/rid.rb', line 3 def cluster_id @cluster_id end |
#document_id ⇒ Object
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
#inspect ⇒ Object Also known as: to_s
23 24 25 |
# File 'lib/orientdb/rid.rb', line 23 def inspect "##{cluster_id}:#{@document_id}" end |
#saved? ⇒ Boolean
33 34 35 |
# File 'lib/orientdb/rid.rb', line 33 def saved? cluster_id > 0 && document_id >= 0 end |
#unsaved? ⇒ Boolean
29 30 31 |
# File 'lib/orientdb/rid.rb', line 29 def unsaved? to_s == '#-1:-1' end |
#valid? ⇒ Boolean
37 38 39 |
# File 'lib/orientdb/rid.rb', line 37 def valid? saved? || unsaved? end |