Class: LastValueStore

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

Instance Method Summary collapse

Constructor Details

#initialize(path, name) ⇒ LastValueStore

Returns a new instance of LastValueStore.



63
64
65
# File 'lib/mongo/mongo.rb', line 63

def initialize(path, name)
  @file_full_name = "#{path}/#{name}"
end

Instance Method Details

#get_last_valueObject



76
77
78
# File 'lib/mongo/mongo.rb', line 76

def get_last_value
  File.read(@file_full_name)
end

#save_last_value(value) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/mongo/mongo.rb', line 67

def save_last_value(value)
  file = File.open(@file_full_name, 'a+')

  file.truncate(0)
  file.puts(value)

  file.close
end