Class: Balboa::Interactor::CapybaraInteractor

Inherits:
Object
  • Object
show all
Defined in:
lib/balboa/interactor/capybara_interactor.rb

Constant Summary collapse

CommandNotFound =
Class.new(RuntimeError)
LoginCommandNotFound =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CapybaraInteractor

Returns a new instance of CapybaraInteractor.



13
14
15
16
17
# File 'lib/balboa/interactor/capybara_interactor.rb', line 13

def initialize(options={})
  @options = options
  @commands = Hash.new { fail CommandNotFound }
  @signed_in = false
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/balboa/interactor/capybara_interactor.rb', line 11

def options
  @options
end

Instance Method Details

#add_command(key, command) ⇒ Object



19
20
21
# File 'lib/balboa/interactor/capybara_interactor.rb', line 19

def add_command(key, command)
  @commands[key.to_s] = command
end

#lastObject



23
24
25
26
# File 'lib/balboa/interactor/capybara_interactor.rb', line 23

def last
   unless signed_in?
  @commands['last'].execute
end

#punch(date) ⇒ Object



28
29
30
31
# File 'lib/balboa/interactor/capybara_interactor.rb', line 28

def punch(date)
   unless signed_in?
  @commands['punch'].execute(date)
end