Class: Magnet::Card
- Inherits:
-
Object
- Object
- Magnet::Card
- Defined in:
- lib/magnet/card.rb
Constant Summary collapse
- ALLOWED_SERVICES =
{ 0..1 => :no_restrictions, 2 => :goods_and_services_only, 3 => :atm_only, 4 => :cash_only, 5 => :goods_and_services_only, 6 => :no_restrictions, 7 => :goods_and_services_only }.freeze
- AUTHORIZATION_PROCESSING =
{ 0 => :normal, 2 => :by_issuer, 4 => :by_issuer_unless_explicit_agreement }.freeze
- FORMAT =
{ "A" => :reserved, "B" => :bank, "C".."M" => :reserved, "N".."Z" => :available }.freeze
- INTERCHANGE =
{ 1..2 => :international, 5..6 => :national, 7 => :private, 9 => :test }.freeze
- PIN_REQUIREMENTS =
{ 0 => :pin_required, 3 => :pin_required, 5 => :pin_required, 6..7 => :prompt_for_pin_if_ped_present }.freeze
- TECHNOLOGY =
{ 2 => :integrated_circuit_card, 6 => :integrated_circuit_card }.freeze
Instance Attribute Summary collapse
-
#allowed_services ⇒ Object
Returns the value of attribute allowed_services.
-
#authorization_processing ⇒ Object
Returns the value of attribute authorization_processing.
-
#discretionary_data ⇒ Object
Returns the value of attribute discretionary_data.
-
#expiration_month ⇒ Object
Returns the value of attribute expiration_month.
-
#expiration_year ⇒ Object
Returns the value of attribute expiration_year.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#format ⇒ Object
Returns the value of attribute format.
-
#initial ⇒ Object
Returns the value of attribute initial.
-
#interchange ⇒ Object
Returns the value of attribute interchange.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#number ⇒ Object
Returns the value of attribute number.
-
#pin_requirements ⇒ Object
Returns the value of attribute pin_requirements.
-
#technology ⇒ Object
Returns the value of attribute technology.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #atm_only? ⇒ Boolean
- #cash_only? ⇒ Boolean
- #goods_and_services_only? ⇒ Boolean
- #integrated_circuit_card? ⇒ Boolean
- #international? ⇒ Boolean
- #national? ⇒ Boolean
- #no_service_restrictions? ⇒ Boolean
- #pin_required? ⇒ Boolean
- #private? ⇒ Boolean
- #process_by_issuer? ⇒ Boolean
- #process_by_issuer_unless_explicit_agreement? ⇒ Boolean
- #process_normally? ⇒ Boolean
- #prompt_for_pin_if_ped_present? ⇒ Boolean
- #test? ⇒ Boolean
Instance Attribute Details
#allowed_services ⇒ Object
Returns the value of attribute allowed_services.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def allowed_services @allowed_services end |
#authorization_processing ⇒ Object
Returns the value of attribute authorization_processing.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def @authorization_processing end |
#discretionary_data ⇒ Object
Returns the value of attribute discretionary_data.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def discretionary_data @discretionary_data end |
#expiration_month ⇒ Object
Returns the value of attribute expiration_month.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def expiration_month @expiration_month end |
#expiration_year ⇒ Object
Returns the value of attribute expiration_year.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def expiration_year @expiration_year end |
#first_name ⇒ Object
Returns the value of attribute first_name.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def first_name @first_name end |
#format ⇒ Object
Returns the value of attribute format.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def format @format end |
#initial ⇒ Object
Returns the value of attribute initial.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def initial @initial end |
#interchange ⇒ Object
Returns the value of attribute interchange.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def interchange @interchange end |
#last_name ⇒ Object
Returns the value of attribute last_name.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def last_name @last_name end |
#number ⇒ Object
Returns the value of attribute number.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def number @number end |
#pin_requirements ⇒ Object
Returns the value of attribute pin_requirements.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def pin_requirements @pin_requirements end |
#technology ⇒ Object
Returns the value of attribute technology.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def technology @technology end |
#title ⇒ Object
Returns the value of attribute title.
45 46 47 |
# File 'lib/magnet/card.rb', line 45 def title @title end |
Class Method Details
.parse(track_data, parser = Parser.new(:auto)) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/magnet/card.rb', line 48 def parse(track_data, parser = Parser.new(:auto)) attributes = parser.parse(track_data) position1, position2, position3 = (attributes[:service_code] || "").scan(/\d/).map(&:to_i) year, month = (attributes[:expiration] || "").scan(/\d\d/).map(&:to_i) title, first_name, initial, last_name = parse_name(attributes[:name].rstrip) if attributes[:name] card = new card.allowed_services = hash_lookup(ALLOWED_SERVICES, position3) card. = hash_lookup(AUTHORIZATION_PROCESSING, position2) card.discretionary_data = attributes[:discretionary_data] card.expiration_month = month card.expiration_year = year card.first_name = first_name card.format = hash_lookup(FORMAT, attributes[:format]) card.initial = initial card.interchange = hash_lookup(INTERCHANGE, position1) card.last_name = last_name card.number = parse_pan(attributes[:pan]) card.pin_requirements = hash_lookup(PIN_REQUIREMENTS, position3) card.technology = hash_lookup(TECHNOLOGY, position1) card.title = title card end |
Instance Method Details
#atm_only? ⇒ Boolean
92 93 94 |
# File 'lib/magnet/card.rb', line 92 def atm_only? allowed_services == :atm_only end |
#cash_only? ⇒ Boolean
96 97 98 |
# File 'lib/magnet/card.rb', line 96 def cash_only? allowed_services == :cash_only end |
#goods_and_services_only? ⇒ Boolean
100 101 102 |
# File 'lib/magnet/card.rb', line 100 def goods_and_services_only? allowed_services == :goods_and_services_only end |
#integrated_circuit_card? ⇒ Boolean
104 105 106 |
# File 'lib/magnet/card.rb', line 104 def integrated_circuit_card? technology == :integrated_circuit_card end |
#international? ⇒ Boolean
108 109 110 |
# File 'lib/magnet/card.rb', line 108 def international? interchange == :international end |
#national? ⇒ Boolean
112 113 114 |
# File 'lib/magnet/card.rb', line 112 def national? interchange == :national end |
#no_service_restrictions? ⇒ Boolean
116 117 118 |
# File 'lib/magnet/card.rb', line 116 def no_service_restrictions? allowed_services = :no_restrictions end |
#pin_required? ⇒ Boolean
120 121 122 |
# File 'lib/magnet/card.rb', line 120 def pin_required? pin_requirements == :pin_required end |
#private? ⇒ Boolean
124 125 126 |
# File 'lib/magnet/card.rb', line 124 def private? interchange == :private end |
#process_by_issuer? ⇒ Boolean
128 129 130 |
# File 'lib/magnet/card.rb', line 128 def process_by_issuer? == :by_issuer end |
#process_by_issuer_unless_explicit_agreement? ⇒ Boolean
132 133 134 |
# File 'lib/magnet/card.rb', line 132 def process_by_issuer_unless_explicit_agreement? == :by_issuer_unless_explicit_agreement end |
#process_normally? ⇒ Boolean
136 137 138 |
# File 'lib/magnet/card.rb', line 136 def process_normally? == :normal end |
#prompt_for_pin_if_ped_present? ⇒ Boolean
140 141 142 |
# File 'lib/magnet/card.rb', line 140 def prompt_for_pin_if_ped_present? pin_requirements == :prompt_for_pin_if_ped_present end |
#test? ⇒ Boolean
144 145 146 |
# File 'lib/magnet/card.rb', line 144 def test? interchange == :test end |