Class: Reedb::Version1

Inherits:
Object
  • Object
show all
Defined in:
lib/reedb/utils/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(existing = nil) ⇒ Version1

Returns a new instance of Version1.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/reedb/utils/version.rb', line 16

def initialize(existing = nil)

  # If a version is created from an existing pattern
  if existing != nil
    existing["R"] = "" if existing[0] == "R"
    data = existing.split('::')
    @revision = data[0].to_i
    @timestamp = data[1].to_i
    return self
  end

  # This creates a new version
  @revision = 1
  @timestamp = DateTime.now.strftime('%Q')
end

Instance Attribute Details

#revisionObject (readonly)

Returns the value of attribute revision.



14
15
16
# File 'lib/reedb/utils/version.rb', line 14

def revision
  @revision
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



14
15
16
# File 'lib/reedb/utils/version.rb', line 14

def timestamp
  @timestamp
end

Instance Method Details

#to_sObject

This formatting is actually used in the dataset



38
39
40
# File 'lib/reedb/utils/version.rb', line 38

def to_s
  return "R#{@revision}::#{@timestamp}"
end

#updateObject



32
33
34
35
# File 'lib/reedb/utils/version.rb', line 32

def update
  @revision += 1
  @timestamp = DateTime.now.strftime('%Q')
end