Class: RocketGate::CreditCard
- Inherits:
-
Object
- Object
- RocketGate::CreditCard
- Includes:
- Hashable, Validatable
- Defined in:
- lib/rocketgate/credit_card.rb
Instance Attribute Summary collapse
-
#card_hash ⇒ Object
Returns the value of attribute card_hash.
-
#cvv ⇒ Object
Returns the value of attribute cvv.
-
#exp_month ⇒ Object
Returns the value of attribute exp_month.
-
#exp_year ⇒ Object
Returns the value of attribute exp_year.
-
#number ⇒ Object
Returns the value of attribute number.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ CreditCard
constructor
A new instance of CreditCard.
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
Methods included from Hashable
Methods included from Validatable
included, #invalid_attributes, #validate!
Constructor Details
#initialize(*args) ⇒ CreditCard
Returns a new instance of CreditCard.
16 17 18 19 20 |
# File 'lib/rocketgate/credit_card.rb', line 16 def initialize(*args) @number, @exp_month, @exp_year, @cvv = *args clean_number! if @number end |
Instance Attribute Details
#card_hash ⇒ Object
Returns the value of attribute card_hash.
5 6 7 |
# File 'lib/rocketgate/credit_card.rb', line 5 def card_hash @card_hash end |
#cvv ⇒ Object
Returns the value of attribute cvv.
5 6 7 |
# File 'lib/rocketgate/credit_card.rb', line 5 def cvv @cvv end |
#exp_month ⇒ Object
Returns the value of attribute exp_month.
5 6 7 |
# File 'lib/rocketgate/credit_card.rb', line 5 def exp_month @exp_month end |
#exp_year ⇒ Object
Returns the value of attribute exp_year.
5 6 7 |
# File 'lib/rocketgate/credit_card.rb', line 5 def exp_year @exp_year end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/rocketgate/credit_card.rb', line 5 def number @number end |
Class Method Details
.from_card_hash(card_hash) ⇒ Object
22 23 24 25 26 |
# File 'lib/rocketgate/credit_card.rb', line 22 def self.from_card_hash(card_hash) new.tap do |cc| cc.card_hash = card_hash end end |
Instance Method Details
#to_hash ⇒ Object
28 29 30 |
# File 'lib/rocketgate/credit_card.rb', line 28 def to_hash card_hash ? { cardHash: card_hash } : super end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/rocketgate/credit_card.rb', line 32 def valid? !card_hash.nil? || super end |