From 8982ef7fa5484324359fdd5cf89f1a1ccd90df9a Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Wed, 5 Jul 2017 23:25:30 +0000 Subject: [PATCH 1/6] I think I solved the first part --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..d087423 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,7 +11,7 @@ def word_count # ================================================================================ - @word_count = "Replace this string with your answer." + @word_count = @text.split.count @character_count_with_spaces = "Replace this string with your answer." From 5372a0538e139e6b4e55797e167424a0fea25496 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Wed, 5 Jul 2017 23:41:42 +0000 Subject: [PATCH 2/6] Solved count with spaces --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index d087423..c6cdaa4 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -13,7 +13,7 @@ def word_count @word_count = @text.split.count - @character_count_with_spaces = "Replace this string with your answer." + @character_count_with_spaces = @text.length @character_count_without_spaces = "Replace this string with your answer." From eead4e8cde0e87b976c9ecfd590e8b5432b5d745 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Thu, 6 Jul 2017 00:06:45 +0000 Subject: [PATCH 3/6] Solved count without spaces --- app/controllers/calculations_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index c6cdaa4..499c8fb 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -15,9 +15,9 @@ def word_count @character_count_with_spaces = @text.length - @character_count_without_spaces = "Replace this string with your answer." + @character_count_without_spaces = @text.gsub(/\s+/, "").length - @occurrences = "Replace this string with your answer." + @occurrences = @text.count(@special_word) # ================================================================================ # Your code goes above. From 319ab48051e2cf16fb9ed58c77794406eed44541 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Thu, 6 Jul 2017 00:22:01 +0000 Subject: [PATCH 4/6] Solved occurrences --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 499c8fb..b865e1b 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -17,7 +17,7 @@ def word_count @character_count_without_spaces = @text.gsub(/\s+/, "").length - @occurrences = @text.count(@special_word) + @occurrences = @special_word.split.count # ================================================================================ # Your code goes above. From 1df4697799724545b8e1bee8daad933ea5c78d46 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Thu, 6 Jul 2017 00:26:29 +0000 Subject: [PATCH 5/6] Solved occurrences v2 --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index b865e1b..8bc8c45 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -17,7 +17,7 @@ def word_count @character_count_without_spaces = @text.gsub(/\s+/, "").length - @occurrences = @special_word.split.count + @occurrences = @text.split.count(@special_word) # ================================================================================ # Your code goes above. From ff086cfff269f0a5bd6ff49ae28cc62df0d3ca71 Mon Sep 17 00:00:00 2001 From: Kent Richard Date: Sat, 8 Jul 2017 17:06:11 +0000 Subject: [PATCH 6/6] Solved Loan Payment --- Gemfile | 4 +++- Gemfile.lock | 8 ++++++++ app/assets/javascripts/application.js | 7 +++++++ app/controllers/calculations_controller.rb | 8 +++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index b625ba3..97bf45a 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,9 @@ git_source(:github) do |repo_name| "https://github.com/#{repo_name}.git" end - +gem 'momentjs-rails' +gem 'bootstrap3-datetimepicker-rails' +gem 'chronic' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.2' # Use sqlite3 as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index a4b753b..d911ad9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,6 +75,8 @@ GEM bootstrap (4.0.0.alpha6) autoprefixer-rails (>= 6.0.3) sass (>= 3.4.19) + bootstrap3-datetimepicker-rails (4.17.47) + momentjs-rails (>= 2.8.1) builder (3.2.3) byebug (9.0.6) callsite (0.0.11) @@ -85,6 +87,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) + chronic (0.10.2) coderay (1.1.1) concurrent-ruby (1.0.5) crack (0.4.3) @@ -140,6 +143,8 @@ GEM mime-types-data (3.2016.0521) mini_portile2 (2.2.0) minitest (5.10.2) + momentjs-rails (2.17.1) + railties (>= 3.1) multi_json (1.12.1) nio4r (2.1.0) nokogiri (1.8.0) @@ -262,8 +267,10 @@ DEPENDENCIES better_errors binding_of_caller bootstrap (~> 4.0.0.alpha6) + bootstrap3-datetimepicker-rails byebug capybara + chronic dotenv-rails factory_girl_rails firstdraft_generators @@ -274,6 +281,7 @@ DEPENDENCIES letter_opener listen (>= 3.0.5, < 3.2) meta_request + momentjs-rails pry-rails puma (~> 3.7) rails (~> 5.1.2) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 739c2fe..da0725c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -14,3 +14,10 @@ //= require bootstrap //= require turbolinks //= require_tree . +//= require jquery +//= require moment +//= require bootstrap-datetimepicker + +$(function () { + $('.datetimepicker').datetimepicker(); +}); \ No newline at end of file diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 8bc8c45..58c155e 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -38,7 +38,13 @@ def loan_payment # The principal value the user input is in the decimal @principal. # ================================================================================ - @monthly_payment = "Replace this string with your answer." + term_months = @years * 12 + new_apr = @apr * 1/100 + principal_month = @principal / term_months + interest_term = @principal * new_apr + interest_month = interest_term / term_months + + @monthly_payment = principal_month + interest_month # ================================================================================ # Your code goes above.