Class: Orientdb4r::Rid
Overview
This class represents encapsulation of RecordID.
Constant Summary collapse
- RID_REGEXP_PATTERN =
Format validation regexp.
/^#?\d+:\d+$/
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
-
#==(another_rid) ⇒ Object
:nodoc:.
-
#initialize(rid) ⇒ Rid
constructor
Constructor.
-
#to_s ⇒ Object
:nodoc:.
-
#unprefixed ⇒ Object
Gets RID’s string representation with no prefix.
Methods included from Utils
#blank?, #compare_versions, #random_string, #verify_and_sanitize_options, #verify_options
Constructor Details
#initialize(rid) ⇒ Rid
Constructor.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/orientdb4r/rid.rb', line 15 def initialize(rid) raise ArgumentError, 'RID cannot be blank' if blank? rid raise ArgumentError, 'RID is not String' unless rid.is_a? String raise ArgumentError, "bad RID format, rid=#{rid}" unless rid =~ RID_REGEXP_PATTERN rid = rid[1..-1] if rid.start_with? '#' ids = rid.split ':' self.cluster_id = ids[0].to_i self.document_id = ids[1].to_i end |
Instance Attribute Details
#cluster_id ⇒ Object
Returns the value of attribute cluster_id.
11 12 13 |
# File 'lib/orientdb4r/rid.rb', line 11 def cluster_id @cluster_id end |
#document_id ⇒ Object
Returns the value of attribute document_id.
11 12 13 |
# File 'lib/orientdb4r/rid.rb', line 11 def document_id @document_id end |
Instance Method Details
#==(another_rid) ⇒ Object
:nodoc:
48 49 50 |
# File 'lib/orientdb4r/rid.rb', line 48 def ==(another_rid) #:nodoc: self.cluster_id == another_rid.cluster_id and self.document_id == another_rid.document_id end |
#to_s ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/orientdb4r/rid.rb', line 38 def to_s #:nodoc: "##{cluster_id}:#{document_id}" end |
#unprefixed ⇒ Object
Gets RID’s string representation with no prefix.
44 45 46 |
# File 'lib/orientdb4r/rid.rb', line 44 def unprefixed "#{cluster_id}:#{document_id}" end |