Class: InsurancePolicy::Policy
- Inherits:
-
Object
- Object
- InsurancePolicy::Policy
- Defined in:
- lib/insurance_policy/policy.rb
Instance Attribute Summary collapse
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#expires_on ⇒ Object
readonly
Returns the value of attribute expires_on.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
- #description ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(company, number, expires_on = nil) ⇒ Policy
constructor
A new instance of Policy.
- #to_s ⇒ Object
Constructor Details
#initialize(company, number, expires_on = nil) ⇒ Policy
Returns a new instance of Policy.
7 8 9 10 11 12 13 |
# File 'lib/insurance_policy/policy.rb', line 7 def initialize( company, number, expires_on=nil ) @company = company @number = number @expires_on = expires_on self.freeze end |
Instance Attribute Details
#company ⇒ Object (readonly)
Returns the value of attribute company.
5 6 7 |
# File 'lib/insurance_policy/policy.rb', line 5 def company @company end |
#expires_on ⇒ Object (readonly)
Returns the value of attribute expires_on.
5 6 7 |
# File 'lib/insurance_policy/policy.rb', line 5 def expires_on @expires_on end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/insurance_policy/policy.rb', line 5 def number @number end |
Instance Method Details
#description ⇒ Object
19 20 21 22 |
# File 'lib/insurance_policy/policy.rb', line 19 def description [company, number].reject( &:blank? ). join( ' Policy No.: ' ) end |
#expired? ⇒ Boolean
15 16 17 |
# File 'lib/insurance_policy/policy.rb', line 15 def expired? !expires_on.blank? && Time.zone.now >= expires_on end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/insurance_policy/policy.rb', line 24 def to_s description end |