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 0df2d0f..58c155e 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,13 +11,13 @@ 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." + @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.split.count(@special_word) # ================================================================================ # Your code goes above. @@ -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.