Class: LitleOnline::Card

Inherits:
Object
  • Object
show all
Includes:
XML::Mapping
Defined in:
lib/XMLFields.rb

Class Method Summary collapse

Class Method Details

.from_hash(hash, name = 'card') ⇒ Object



631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# File 'lib/XMLFields.rb', line 631

def self.from_hash(hash, name='card')
  base = hash[name]
  if(base)
    this = Card.new
    this.mop = base['type']
    this.track = base['track']
    this.number = base['number']
    this.expDate = base['expDate']
    this.cardValidationNum = base['cardValidationNum']
    SchemaValidation.validate_enum(this.mop, false, ['','MC','VI','AX','DC','DI','PP','JC','BL','EC','GC'], name, 'type')
    SchemaValidation.validate_length(this.track, false, 1, 256, name, 'track')
    SchemaValidation.validate_length(this.number, false, 13, 25, name, 'number')
    SchemaValidation.validate_length(this.expDate, false, 4, 4, name, 'expDate')
    SchemaValidation.validate_length(this.cardValidationNum, false, 1, 4, name, 'cardValidationNum')
    this
  else
    nil
  end
end