Class: Sessions::Local

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/ruby_drills/sessions/local.rb

Constant Summary collapse

DIR =
'/usr/local/var/ruby_drills'

Instance Method Summary collapse

Constructor Details

#initializeLocal

Returns a new instance of Local.



10
11
12
13
# File 'lib/ruby_drills/sessions/local.rb', line 10

def initialize
  ensure_directory_exists
  @db = PStore.new(File.join(DIR, 'progress.pstore'))
end

Instance Method Details

#attempt(name, input, reference, result) ⇒ Object



19
20
21
# File 'lib/ruby_drills/sessions/local.rb', line 19

def attempt(name, input, reference, result)
  store({context: name, input: input, reference: reference, result: result, type: 'attempt'})
end

#command(name, input) ⇒ Object



15
16
17
# File 'lib/ruby_drills/sessions/local.rb', line 15

def command(name, input)
  store({context: name, input: input, type: 'command'})
end

#statsObject



23
24
25
26
27
28
29
# File 'lib/ruby_drills/sessions/local.rb', line 23

def stats
  @db.transaction(true) do
    @db.roots.each do |key|
      puts @db[key].inspect
    end
  end
end