layout: post
title: Maple Bacon Waffle
date: 2017-6-20
Back to the morning schedule, and just in time!
I walked into the Cantina this morning to a fresh maple bacon waffle.
There was homemade apple cinnamon butter and fresh apple juice to boot!
I ate the tasty breakfast outside after a few moments in the warming sun.
A sausage patty was served with the meal along with optional cereal.
Today is sure to be a great day!
Today I'm thinking about Ruby:
As the learning continues on campus it would be a shame for it to stop here!
I an awesome test-driven-development resource for learning ruby.
Let's do the first few steps together.
Here is the website: http://rubykoans.com/
Download the Koans and install ruby on your computer.
Open up the command line and navigate into the unzipped Ruby Koans directory.
Type and run: ruby path_to_enlightenment.rb
You should see some slightly esoteric colored output, let's see what it says:
qst0s-iMac:koans qst0$ ruby path_to_enlightenment.rb
AboutAsserts#test_assert_truth has damaged your karma.
The Master says:
You have not yet reached enlightenment.
The answers you seek...
Failed assertion.
Please meditate on the following code:
/Users/qst0/Desktop/koans/about_asserts.rb:10:in `test_assert_truth'
mountains are merely mountains
your path thus far [X_________________________________________________] 0/282
My output in the post isn't colorful, but we can solve our first puzzle.
Remember:
RED - Write a failing test and run it (Hey we just ran a failing test!)
Green - Make the test pass. (Okay so now let's do that.)
Open up the Koans directory in your favorite text editor:
I use vim: vim .
" ============================================================================
" Netrw Directory Listing (netrw v140)
" /Users/qst0/Desktop/koans
" Sorted by name
" Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
.path_progress
GREED_RULES.txt*
README.rdoc*
Rakefile*
about_array_assignment.rb*
about_arrays.rb*
about_asserts.rb*
about_blocks.rb*
about_class_methods.rb*
about_classes.rb*
about_constants.rb*
about_control_statements.rb*
about_dice_project.rb*
about_exceptions.rb*
about_extra_credit.rb*
about_hashes.rb*
"." is a directory
The command vim . works because our current directory can be referred to with .
select about_asserts.rb and let's read the code.
#!/usr/bin/env ruby
# -*- ruby -*-
require File.expand_path(File.dirname(__FILE__) + '/neo')
class AboutAsserts < Neo::Koan
# We shall contemplate truth by testing reality, via asserts.
def test_assert_truth
assert false # This should be true
end
# Enlightenment may be more easily achieved with appropriate
# messages.
def test_assert_with_message
assert false, "This should be true -- Please fix this"
end
# To understand reality, we must compare our expectations against
# reality.
def test_assert_equality
expected_value = __
actual_value = 1 + 1
assert expected_value == actual_value
end
We shall contemplate truth by testing reality, via asserts!
Change the assert false # This should be true to true
Feel free to fix more of the broken code, but don't forget the third step:
Refactor: Look at the code and see what you can make better.
I might as well add a step 3.2:
Reflect: Think about what fixing this error is teaching you!
Return to the command line and run: ruby path_to_enlightenment.rb again.
Mountains are merely mountains.
The TODO list:
The Ice Box:
I hope you join me again tomorrow for more breakfast and code!
What did you learn yesterday that you can learn again today?
Have a wonderful day,
- qst0
Next: 2017-6-21-18
Prev: 2017-6-19-16