Class: LicenseValidator::Driver

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/license_validator/driver.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Driver

Returns a new instance of Driver.

Parameters:

  • attributes (Hash) (defaults to: {})


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

#ageInteger

Returns:

  • (Integer)


14
15
16
# File 'lib/license_validator/driver.rb', line 14

def age
  @age
end

#badBoolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/license_validator/driver.rb', line 16

def bad
  @bad
end

#cdl_classString

Returns:

  • (String)


18
19
20
# File 'lib/license_validator/driver.rb', line 18

def cdl_class
  @cdl_class
end

#dobDate

Returns:

  • (Date)


20
21
22
# File 'lib/license_validator/driver.rb', line 20

def dob
  @dob
end

#first_nameString

Returns:

  • (String)


22
23
24
# File 'lib/license_validator/driver.rb', line 22

def first_name
  @first_name
end

#last_nameString

Returns:

  • (String)


24
25
26
# File 'lib/license_validator/driver.rb', line 24

def last_name
  @last_name
end

#license_numString

Returns:

  • (String)


26
27
28
# File 'lib/license_validator/driver.rb', line 26

def license_num
  @license_num
end

#stateString

Returns abv.

Returns:

  • (String)

    abv



28
29
30
# File 'lib/license_validator/driver.rb', line 28

def state
  @state
end

#years_expInteger

Returns:

  • (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

See Also:

  • super


33
34
35
36
37
38
39
# File 'lib/license_validator/driver.rb', line 33

def self.human_attribute_name(attr, options = {})
  return 'CDL Class' if attr == 'cdl_class'

  return 'License #' if attr == 'license_num'

  super
end

Instance Method Details

#attributesHash

Returns:

  • (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