appointment-calculator 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2711b297fa9c8e02f0ebf6866bfc818ff1e9dccc3549293109cb5481c638f2f7
4
- data.tar.gz: 90c77b9a968cb247ac164c7222775bbd13f975f62b2bd1210aeef06dbd66b671
3
+ metadata.gz: cc14c5081910b5009b54da3ab7b4aaed44d54f881dcfddd7e905aa2d9639dc96
4
+ data.tar.gz: 5f07e81d3b7c07cf21dba46f27d4060b52c57e5618015a7382748e5cad96239f
5
5
  SHA512:
6
- metadata.gz: 3d1f31fe3be5076f1fe69eff4f06d6f11b645399eb5c5f4f79af477c3073838209e5c8a4ff9f19a45af87daad3ccdd658a933b3728813bd2c1f93323cdafe650
7
- data.tar.gz: 437ee53301b1b3453ed1a2d395158ec06790ed127cbca08d84af6f9c796cd533828d51f3291bb1ea1f50d8cfb646c344dc19044f699987c7239e4c4df9cfb4f6
6
+ metadata.gz: ac702440f5892f95e95ccde704286485475f6ef8302dcfb2f2ade082296b0108431f0b90bd719e219ceb45eaba63dade6e1139d9da1bf8b727ecd284a060b75e
7
+ data.tar.gz: 937a7cd507e8da3a877e6867e4f36521a06f50f0c3f9bacd80a11dba7f4a219bc5a72230ac7b6fa5ba9b2400678869508f130e69728a4bb6f61ad8ffe7cf7d22
@@ -1,43 +1,51 @@
1
1
  class AppointmentCalculator
2
2
 
3
3
 
4
- @total_duration = 0
5
- @total_cost = 0
6
- @end_time = ""
7
- @start_time = ""
8
-
9
-
10
-
11
- def self.calculate(services)
4
+ def self.calculate(services)
12
5
  @services = services
13
- pp @services
14
-
6
+ @total_duration = 0
7
+ @total_cost = 0
8
+ # @end_time = ""
9
+ # @start_time = ""
10
+
15
11
  @services.each do |service|
16
- @total_cost =+ (service[:service_price])
17
- @total_duration =+ (service[:service_duration])
12
+ service_cost = service[:service_price].to_f
13
+ service_duration = service[:service_duration].to_i
14
+ @total_cost += service_cost
15
+ @total_duration += service_duration
18
16
  end
19
- puts ({"total_cost":@total_cost,"total_duration":@total_duration})
17
+ # puts(@total_cost)
18
+ # puts ({"total_cost":@total_cost,"total_duration":@total_duration})
20
19
  return ({"total_cost":@total_cost,"total_duration":@total_duration})
21
20
  end
22
- # def get_end_time(appointment, services)
23
- # @services = services
24
-
25
- # @appointment = appointment
26
- # pp @appointment
27
- # # @start_time = @appointment[:appointment_time]
28
- # # puts(@start_time)
29
- # end
30
21
  end
31
22
 
32
- #This is what's going to be passed from the Appointment controller
23
+
24
+ #TESTING THE GEM
25
+ #We create 'temp_services' variable which mimics the services that will be selected during Appointment creation
33
26
  # temp_services= [{"id":3,"service_name":"Hot Towel Shave","service_description":"Our famous Hot Towel Shave will make you and your skin feel amazing! Try it now!.Quisque malesuada metus turpis, vitae dignissim elit congue sed.","service_duration":10,"service_price":"15.0","created_at":"2019-08-20T14:59:27.897Z","updated_at":"2019-08-20T15:00:32.345Z"},{"id":2,"service_name":"Beard Trim","service_description":"Regular Beard Trim with an electric trimmer and razor blade finish! Vestibulum ullamcorper elementum. Mauris elementum efficitur sollicitudin. Aliquam condimentum dignissim.","service_duration":10,"service_price":"10.0","created_at":"2019-08-20T14:59:27.896Z","updated_at":"2019-08-20T15:00:52.326Z"},{"id":1,"service_name":"Haircut","service_description":"Standard Haircut. Get your hair cut for only €15! Suspendisse eget luctus urna, sit amet ultricies dolor. Sed iaculis pretium viverra. Nunc viverra pulvinar esta.","service_duration":20,"service_price":"15.0","created_at":"2019-08-20T14:59:27.891Z","updated_at":"2019-08-20T19:48:58.326Z"}]
27
+ # result = AppointmentCalculator.calculate(temp_services)
28
+ # puts(result)
29
+ #{:total_cost=>"15.0", :total_duration=>20}
30
+
31
+
32
+
33
+
34
+
35
+ #attempt at implementation of Calculate End Time function
34
36
  # temp_appointment = {"appointment_time":"2019-08-21T00:43:00.000Z","appointment_date":"2019-08-21","appointment_duration":0,"total_cost":"0.0","status":"active","customer_id":1,"barber_id":1}
35
37
  # temp_barber = JSON.parse('{"id":1,"barber_name":"Edward","barber_bio":"Handy with scissors! Edward has been cutting hair since the age of 5. Vivamus aliquam sagittis sapien sit amet pulvinar. Nam et semper leo. Vivamus vel enim neque. Suspendisse eget luctus urna, sit amet ultricies dolor. Sed iaculis pretium viverra. Nunc viverra pulvinar est a interdum.","barber_photo_path":"avatar1","created_at":"2019-08-20T14:46:56.210Z","updated_at":"2019-08-20T14:46:56.210Z"}')
36
- # temp_customer = JSON.parse({"id":1,"customer_name":"Administrator","customer_number":"0894488338","customer_photo_path":"avatar3","user_id":1,"created_at":"2019-08-20T14:48:19.205Z","updated_at":"2019-08-20T14:48:28.707Z"} )
37
- # app = AppointmentCalculator.new
38
-
38
+ # temp_customer = JSON.parse({"id":1,"customer_name":"Administrator","customer_number":"0894488338","customer_photo_path":"avatar3","user_id":1,"created_at":"2019-08-20T14:48:19.205Z","updated_at":"2019-08-20T14:48:28.707Z"} )# app = AppointmentCalculator.new
39
39
 
40
40
  # result = app.calculate(temp_services)
41
+ # services = '[{\"id\":3,\"service_name\":\"Hot Towel Shave\",\"service_description\":\"Our famous Hot Towel Shave will make you and your skin feel amazing! Try it now!.Quisque malesuada metus turpis, vitae dignissim elit congue sed.\",\"service_duration\":10,\"service_price\":\"15.0\",\"created_at\":\"2019-08-20T14:59:27.897Z\",\"updated_at\":\"2019-08-20T15:00:32.345Z\"},{\"id\":2,\"service_name\":\"Beard Trim\",\"service_description\":\"Regular Beard Trim with an electric trimmer and razor blade finish! Vestibulum ullamcorper elementum. Mauris elementum efficitur sollicitudin. Aliquam condimentum dignissim.\",
42
+ # \"service_duration\":10,\"service_price\":\"10.0\",\"created_at\":\"2019-08-20T14:59:27.896Z\",\"updated_at\":\"2019-08-20T15:00:52.326Z\"}]'
41
43
 
42
- # result = AppointmentCalculator.calculate(temp_services)
43
- # puts(result[:total_cost])
44
+ # def get_end_time(appointment, services)
45
+ # @services = services
46
+
47
+ # @appointment = appointment
48
+ # pp @appointment
49
+ # # @start_time = @appointment[:appointment_time]
50
+ # # puts(@start_time)
51
+ # end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appointment-calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - matim3k
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "Appointment-Calculator gem takes in an object of services, each object
14
14
  has different duration and cost. \n Appointment-Calculator iterates
@@ -19,7 +19,7 @@ executables: []
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
- - lib/appointment_calculator.rb
22
+ - lib/appointment-calculator.rb
23
23
  homepage: https://rubygems.org/gems/appointment-calculator
24
24
  licenses: []
25
25
  metadata: {}