Class: LicensePlate::Plate

Inherits:
Object
  • Object
show all
Defined in:
lib/license_plate/plate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, number, expires_on = nil) ⇒ Plate

Returns a new instance of Plate.



7
8
9
10
11
12
13
# File 'lib/license_plate/plate.rb', line 7

def initialize( state, number, expires_on=nil )
  @state      = state
  @number     = number
  @expires_on = expires_on

  self.freeze
end

Instance Attribute Details

#expires_onObject (readonly)

Returns the value of attribute expires_on.



5
6
7
# File 'lib/license_plate/plate.rb', line 5

def expires_on
  @expires_on
end

#numberObject (readonly)

Returns the value of attribute number.



5
6
7
# File 'lib/license_plate/plate.rb', line 5

def number
  @number
end

#stateObject (readonly)

Returns the value of attribute state.



5
6
7
# File 'lib/license_plate/plate.rb', line 5

def state
  @state
end

Instance Method Details

#descriptionObject



19
20
21
22
# File 'lib/license_plate/plate.rb', line 19

def description
  [state, number].reject( &:blank? ).
                  join( ' ' )
end

#expired?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/license_plate/plate.rb', line 15

def expired?
  !expires_on.blank? && Time.zone.now >= expires_on
end

#to_sObject



24
25
26
# File 'lib/license_plate/plate.rb', line 24

def to_s
  description
end