Class: LicensePlate::Plate
- Inherits:
-
Object
- Object
- LicensePlate::Plate
- Defined in:
- lib/license_plate/plate.rb
Instance Attribute Summary collapse
-
#expires_on ⇒ Object
readonly
Returns the value of attribute expires_on.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #description ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(state, number, expires_on = nil) ⇒ Plate
constructor
A new instance of Plate.
- #to_s ⇒ Object
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_on ⇒ Object (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 |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/license_plate/plate.rb', line 5 def number @number end |
#state ⇒ Object (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
#description ⇒ Object
19 20 21 22 |
# File 'lib/license_plate/plate.rb', line 19 def description [state, number].reject( &:blank? ). join( ' ' ) end |
#expired? ⇒ Boolean
15 16 17 |
# File 'lib/license_plate/plate.rb', line 15 def expired? !expires_on.blank? && Time.zone.now >= expires_on end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/license_plate/plate.rb', line 24 def to_s description end |