String and Integer Riddles
How can I tell how many characters are in a string? Do spaces count?
.length, yes
How can I capitalize the first character of a string? What happens if it is a number?
def supafizbuz(max_num) | |
range = (0..max_num).to_a | |
range.each do |num| | |
a = num % 7 == 0 ? "Super" : "" | |
b = num % 3 == 0 ? "Fizz" : "" | |
c = num % 5 == 0 ? "Buzz" : "" | |
puts (a + b + c) == "" ? num : (a + b + c) | |
end | |
return nil |
def supafizbuz(max_num) | |
range = (0..max_num).to_a | |
range.each do |num| | |
if num % 3 == 0 | |
if num % 7 == 0 | |
if num % 5 == 0 | |
puts("SuperFizzBuzz") | |
next | |
end | |
puts("SuperFizz") |
coverage/ |
An enumerable is an object that may be enumerated. "Enumerated" means to count off the members of a set/collection/category one by one (usually in order, usually by name).
"Enumerable" is Ruby's way of saying that we can access each element in a collection, one at a time. Enumerable is a mixin in the Array class and it provides several enumerators such as each, map, select and many more. Find all enumerables and enumerators in the Ruby docs.
Ruby has a tons of enumerables which means that if we pick the right enumerable for the job, our implementation will be very clean and easy to read.
This week we are going to be writing enumerables from scratch. The groups are only allowed to use each, until loops, while loops and for loops.
Group Member Names: Adrienne, Chelsea, Allan
When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed?
None of us have scheduling conflicts (Allan has one meet-up per week).
We'll go home at 7 every night, if we need or want to work individually after that, we will do that. Allan has a side project he's working on after 7.
We'll be here over the weekend.
How will group members communicate? How often will communication happen, and how will open lines of communication be maintained?
gem 'rails_12factor'
to your Gemfile. This will add error logging and the ability for your app to serve static assets.bundle
RAILS_ENV=production rake db:create db:migrate db:seed
rake secret
and copy the outputexport SECRET_KEY_BASE=output-of-rake-secret
rake assets:precompile
. This will create a folder public/assets
that contains all of your assets.RAILS_ENV=production rails s
and you should see your app.Remember to clobber your assets (rake assets:clobber
) and re-precompile (rake assets:precompile
) if you make changes.