appointment-calculator 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/appointment_calculator.rb +43 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2711b297fa9c8e02f0ebf6866bfc818ff1e9dccc3549293109cb5481c638f2f7
4
+ data.tar.gz: 90c77b9a968cb247ac164c7222775bbd13f975f62b2bd1210aeef06dbd66b671
5
+ SHA512:
6
+ metadata.gz: 3d1f31fe3be5076f1fe69eff4f06d6f11b645399eb5c5f4f79af477c3073838209e5c8a4ff9f19a45af87daad3ccdd658a933b3728813bd2c1f93323cdafe650
7
+ data.tar.gz: 437ee53301b1b3453ed1a2d395158ec06790ed127cbca08d84af6f9c796cd533828d51f3291bb1ea1f50d8cfb646c344dc19044f699987c7239e4c4df9cfb4f6
@@ -0,0 +1,43 @@
1
+ class AppointmentCalculator
2
+
3
+
4
+ @total_duration = 0
5
+ @total_cost = 0
6
+ @end_time = ""
7
+ @start_time = ""
8
+
9
+
10
+
11
+ def self.calculate(services)
12
+ @services = services
13
+ pp @services
14
+
15
+ @services.each do |service|
16
+ @total_cost =+ (service[:service_price])
17
+ @total_duration =+ (service[:service_duration])
18
+ end
19
+ puts ({"total_cost":@total_cost,"total_duration":@total_duration})
20
+ return ({"total_cost":@total_cost,"total_duration":@total_duration})
21
+ 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
+ end
31
+
32
+ #This is what's going to be passed from the Appointment controller
33
+ # 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"}]
34
+ # 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
+ # 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
+
39
+
40
+ # result = app.calculate(temp_services)
41
+
42
+ # result = AppointmentCalculator.calculate(temp_services)
43
+ # puts(result[:total_cost])
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: appointment-calculator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - matim3k
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "Appointment-Calculator gem takes in an object of services, each object
14
+ has different duration and cost. \n Appointment-Calculator iterates
15
+ through all the objects, retrieves duration and cost of each and sums them to calculate
16
+ \n total_cost and total_duration of an appointment!"
17
+ email: matim3k@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - lib/appointment_calculator.rb
23
+ homepage: https://rubygems.org/gems/appointment-calculator
24
+ licenses: []
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.0.4
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Appointment-Calculator takes an array of services and calculates total duration
45
+ and total cost of all services.
46
+ test_files: []