Class: Iso7813::Track2
- Inherits:
-
Object
- Object
- Iso7813::Track2
- Includes:
- Iso7812::CardNumber
- Defined in:
- lib/iso7813/track2.rb
Instance Attribute Summary collapse
-
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
-
#pan ⇒ Object
Returns the value of attribute pan.
-
#service_code ⇒ Object
Returns the value of attribute service_code.
Class Method Summary collapse
Instance Method Summary collapse
- #dd ⇒ Object
- #ed ⇒ Object
- #etx ⇒ Object
- #fs ⇒ Object
- #lrc(_track) ⇒ Object
- #sc ⇒ Object
- #stx ⇒ Object
- #track(include_lrc_and_sentinel = false) ⇒ Object
Instance Attribute Details
#expiration_date ⇒ Object
Returns the value of attribute expiration_date.
10 11 12 |
# File 'lib/iso7813/track2.rb', line 10 def expiration_date @expiration_date end |
#pan ⇒ Object
Returns the value of attribute pan.
9 10 11 |
# File 'lib/iso7813/track2.rb', line 9 def pan @pan end |
#service_code ⇒ Object
Returns the value of attribute service_code.
11 12 13 |
# File 'lib/iso7813/track2.rb', line 11 def service_code @service_code end |
Class Method Details
.generate(fields = {}, include_lrc_and_sentinel = false) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/iso7813/track2.rb', line 47 def self.generate(fields = {}, include_lrc_and_sentinel = false) track2 = Track2.new track2.pan = fields[:pan] track2.expiration_date = fields[:expiration_date] track2.service_code = fields[:service_code] track2.track(include_lrc_and_sentinel) end |
Instance Method Details
#dd ⇒ Object
25 26 27 |
# File 'lib/iso7813/track2.rb', line 25 def dd "#{stx}#{pan}#{fs}#{ed}#{sc}".length.to_s end |
#ed ⇒ Object
17 18 19 |
# File 'lib/iso7813/track2.rb', line 17 def ed expiration_date || "=" end |
#etx ⇒ Object
29 30 31 |
# File 'lib/iso7813/track2.rb', line 29 def etx "?" end |
#fs ⇒ Object
33 34 35 |
# File 'lib/iso7813/track2.rb', line 33 def fs '=' end |
#lrc(_track) ⇒ Object
37 38 39 |
# File 'lib/iso7813/track2.rb', line 37 def lrc(_track) raise 'The track printer should do that, not the track generation software (parity)' end |
#sc ⇒ Object
21 22 23 |
# File 'lib/iso7813/track2.rb', line 21 def sc service_code || "=" end |
#stx ⇒ Object
13 14 15 |
# File 'lib/iso7813/track2.rb', line 13 def stx ';' end |
#track(include_lrc_and_sentinel = false) ⇒ Object
41 42 43 44 45 |
# File 'lib/iso7813/track2.rb', line 41 def track(include_lrc_and_sentinel = false) _track = "#{stx}#{pan}#{fs}#{ed}#{sc}#{dd}" _track << "#{etx}#{lrc(_track)}" if include_lrc_and_sentinel _track end |