Class: LicenseValidator::Driver
- Inherits:
-
Object
- Object
- LicenseValidator::Driver
- Includes:
- ActiveModel::Model
- Defined in:
- lib/license_validator/driver.rb
Instance Attribute Summary collapse
- #age ⇒ Integer
- #bad ⇒ Boolean
- #cdl_class ⇒ String
- #dob ⇒ Date
- #first_name ⇒ String
- #last_name ⇒ String
- #license_num ⇒ String
-
#state ⇒ String
Abv.
- #years_exp ⇒ Integer
Class Method Summary collapse
Instance Method Summary collapse
- #attributes ⇒ Hash
-
#initialize(attributes = {}) ⇒ Driver
constructor
A new instance of Driver.
Constructor Details
#initialize(attributes = {}) ⇒ Driver
Returns a new instance of Driver.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/license_validator/driver.rb', line 42 def initialize(attributes = {}) super if dob.blank? && !dob.is_a?(Date) @dob = nil end @license_num = license_num.to_s validate! end |
Instance Attribute Details
#age ⇒ Integer
14 15 16 |
# File 'lib/license_validator/driver.rb', line 14 def age @age end |
#bad ⇒ Boolean
16 17 18 |
# File 'lib/license_validator/driver.rb', line 16 def bad @bad end |
#cdl_class ⇒ String
18 19 20 |
# File 'lib/license_validator/driver.rb', line 18 def cdl_class @cdl_class end |
#dob ⇒ Date
20 21 22 |
# File 'lib/license_validator/driver.rb', line 20 def dob @dob end |
#first_name ⇒ String
22 23 24 |
# File 'lib/license_validator/driver.rb', line 22 def first_name @first_name end |
#last_name ⇒ String
24 25 26 |
# File 'lib/license_validator/driver.rb', line 24 def last_name @last_name end |
#license_num ⇒ String
26 27 28 |
# File 'lib/license_validator/driver.rb', line 26 def license_num @license_num end |
#state ⇒ String
Returns abv.
28 29 30 |
# File 'lib/license_validator/driver.rb', line 28 def state @state end |
#years_exp ⇒ Integer
30 31 32 |
# File 'lib/license_validator/driver.rb', line 30 def years_exp @years_exp end |
Class Method Details
.human_attribute_name(attr, options = {}) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/license_validator/driver.rb', line 33 def self.human_attribute_name(attr, = {}) return 'CDL Class' if attr == 'cdl_class' return 'License #' if attr == 'license_num' super end |
Instance Method Details
#attributes ⇒ Hash
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/license_validator/driver.rb', line 55 def attributes { state: state, years_exp: years_exp, dob: dob, age: age, cdl_class: cdl_class, license_num: license_num, first_name: first_name, last_name: last_name, bad: bad } end |