Created
July 20, 2010 16:49
-
-
Save rickhull/483210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to define section(heading, &block) so it: | |
# prints out some "header" formatting, e.g. "\n<hr>#{heading}\n" | |
# and then indents ALL OUTPUT originating from its block | |
# | |
# e.g. | |
section 'Nerf herding' do | |
herd = [] | |
10.times { herd << rand(5) } | |
puts herd.last | |
end | |
section 'Hot grits' do | |
puts 'with extra sizurp' | |
section 'natalie portman' do | |
puts 'hello from slashdot' | |
section 'beowulf cluster' do | |
puts 'could you imagine?' | |
end | |
end | |
end | |
section 'Github rules!' do | |
puts '1. Do not talk about github' | |
end | |
puts "DONE" | |
######### DESIRED OUTPUT BELOW ######### | |
-------------------------------------------------------- | |
Nerf herding | |
3 | |
-------------------------------------------------------- | |
Hot grits | |
with extra sizurp | |
------------------------------------------------------ | |
natalie portman | |
hello from slashdot | |
---------------------------------------------------- | |
beowulf cluster | |
could you imagine? | |
-------------------------------------------------------- | |
Github rules! | |
1. Do not talk about github | |
DONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment