-
Notifications
You must be signed in to change notification settings - Fork 79
Working Super Fizz Buzz and Deaf Grandma drills and rspec tests. #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| source 'https://rubygems.org' | ||
| ruby '2.0.0' | ||
| ruby '2.2.9' | ||
|
|
||
| gem 'rspec', '~> 3.0.0.beta2' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,9 @@ PLATFORMS | |
|
|
||
| DEPENDENCIES | ||
| rspec (~> 3.0.0.beta2) | ||
|
|
||
| RUBY VERSION | ||
| ruby 2.2.9p480 | ||
|
|
||
| BUNDLED WITH | ||
| 1.16.1 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,29 @@ | ||
| class SuperFizzBuzz | ||
|
|
||
| def run(input) | ||
| output = "" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take a look at
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not seeing it. How would I use .tap here to avoid initializing output to an empty string?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use it to simplify your code a bit here because it returns itself. You'll see def run_service
api_service.tap do |s|
s.prepare_data
s.send_emails
s.log_something
end
endIn this particular case, you could... |
||
|
|
||
| #Implement your code here | ||
| divBy3 = input % 3 == 0 | ||
| divBy5 = input % 5 == 0 | ||
|
|
||
| end | ||
| if divBy3 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. snakecase_is_preferred. https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars |
||
| output << "Fizz" | ||
| end | ||
|
|
||
| if divBy5 | ||
| output << "Buzz" | ||
| end | ||
|
|
||
| if divBy3 || divBy5 | ||
| return output | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need an explicit return here? https://stackoverflow.com/questions/1064159/implicit-return-values-in-ruby |
||
| else | ||
| return input | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or here? |
||
| end | ||
| end | ||
| end | ||
|
|
||
| #You don't necessarily need to execute this script to complete this challenge, but how would you "run" this method (pun intended) so that it printed a value to the terminal? | ||
| # | ||
|
|
||
| # puts SuperFizzBuzz.new.run | ||
|
|
||
| #HINT: it's an instance method. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://stackoverflow.com/questions/7638502/what-does-plus-equals-mean