Class: OrientDbClient::Rid
- Inherits:
-
Object
- Object
- OrientDbClient::Rid
- Defined in:
- lib/orient_db_client/rid.rb
Instance Attribute Summary collapse
-
#cluster_id ⇒ Object
readonly
Returns the value of attribute cluster_id.
-
#cluster_position ⇒ Object
readonly
Returns the value of attribute cluster_position.
Instance Method Summary collapse
-
#initialize(cluster_id_or_rid = nil, cluster_position = nil) ⇒ Rid
constructor
A new instance of Rid.
- #nil? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(cluster_id_or_rid = nil, cluster_position = nil) ⇒ Rid
Returns a new instance of Rid.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/orient_db_client/rid.rb', line 6 def initialize(cluster_id_or_rid = nil, cluster_position = nil) if cluster_id_or_rid.is_a?(String) && cluster_position.nil? rid = cluster_id_or_rid rid = rid[1..rid.length] if rid[0] == '#' @cluster_id, @cluster_position = rid.split(":") elsif cluster_id_or_rid.is_a?(OrientDbClient::Rid) rid = cluster_id_or_rid @cluster_id = rid.cluster_id @cluster_position = rid.cluster_position else @cluster_id = cluster_id_or_rid.nil? ? nil : cluster_id_or_rid @cluster_position = cluster_position.nil? ? nil : cluster_position end @cluster_id = @cluster_id.to_i unless @cluster_id.nil? @cluster_position = @cluster_position.to_i unless @cluster_position.nil? end |
Instance Attribute Details
#cluster_id ⇒ Object (readonly)
Returns the value of attribute cluster_id.
3 4 5 |
# File 'lib/orient_db_client/rid.rb', line 3 def cluster_id @cluster_id end |
#cluster_position ⇒ Object (readonly)
Returns the value of attribute cluster_position.
4 5 6 |
# File 'lib/orient_db_client/rid.rb', line 4 def cluster_position @cluster_position end |
Instance Method Details
#nil? ⇒ Boolean
27 28 29 |
# File 'lib/orient_db_client/rid.rb', line 27 def nil? @cluster_id.nil? || @cluster_position.nil? end |
#to_s ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/orient_db_client/rid.rb', line 31 def to_s if self.nil? '#' else "##{@cluster_id}:#{@cluster_position}" end end |