-
Notifications
You must be signed in to change notification settings - Fork 15
/
contract.rb
38 lines (30 loc) · 1.04 KB
/
contract.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'securerandom'
require_relative './product'
# Contract represents an extended warranty for a covered product.
# A contract is in a PENDING state prior to the effective date,
# ACTIVE between effective and expiration dates, and EXPIRED after
# the expiration date.
class Contract
attr_reader :id # unique id
attr_reader :purchase_price
attr_reader :covered_product
attr_accessor :purchase_date
attr_accessor :effective_date
attr_accessor :expiration_date
attr_accessor :status
attr_accessor :claims
def initialize(purchase_price, covered_product, purchase_date, effective_date, expiration_date)
@id = SecureRandom.uuid
@purchase_price = purchase_price
@status = "PENDING"
@covered_product = covered_product
@purchase_date = purchase_date
@effective_date = effective_date
@expiration_date = expiration_date
@claims = Array.new
end
# Equality for entities is based on unique id
def ==(other)
self.id == other.id
end
end