Class: Smartware::Driver::CardReader::Dummy

Inherits:
Object
  • Object
show all
Defined in:
lib/smartware/drivers/card_reader/dummy.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Dummy

Returns a new instance of Dummy.



5
6
7
8
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 5

def initialize(config)
  @accepting = false
  @state = nil
end

Instance Method Details

#accepting=(accepting) ⇒ Object



26
27
28
29
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 26

def accepting=(accepting)
  @state = :accepting if accepting
  @accepting = accepting
end

#accepting?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 22

def accepting?
  @accepting
end

#captureObject



37
38
39
40
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 37

def capture
  @state = :eject
  self
end

#ejectObject



31
32
33
34
35
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 31

def eject
  @state = :eject

  self
end

#modelObject



10
11
12
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 10

def model
  "Dummy card reader"
end

#read_magstripObject



60
61
62
63
64
65
66
67
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 60

def read_magstrip
  [
    "B4154000000000000^IVANOV/IVAN^1501101000",
    "4154000000000000=1501101000",
    nil,
    nil
  ]
end

#ready?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 18

def ready?
  true
end

#statusObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 42

def status
  case @state
  when nil
    :ready

  when :accepting
    @state = :inserted
    :card_at_gate

  when :inserted
    :card_inserted

  when :eject
    @state = nil
    :card_at_gate
  end
end

#versionObject



14
15
16
# File 'lib/smartware/drivers/card_reader/dummy.rb', line 14

def version
  ""
end