Skip to content

Instantly share code, notes, and snippets.

@troyleach
Created January 6, 2015 23:49
Show Gist options
  • Select an option

  • Save troyleach/e16edd0a8858028cd72e to your computer and use it in GitHub Desktop.

Select an option

Save troyleach/e16edd0a8858028cd72e to your computer and use it in GitHub Desktop.
#screencast #3 - Not really sure if I did this right. I have never asked for the class of a class of a string
1 => float
2 => String
3 => Range
4 => Class
5 => Class?? like I said wasn't sure what to do here, "hello".class.class is class, "hello".class is String
#screencast #4, very cool method, not sure when one would use this but I did read that it was faster then downcase
#Method number 1
"Troy" == "troy"
=> false
"Troy.casecmp("troy") == 0
=> true
#Method number 2 - this is really cool! I'm not sure why I didn't know about this nice little gem!
"troy".chars
=> ["t", "r", "o", "y"]
#method number 3 - I don't know, I thought this was pretty cool, it is like #next
1.succ
=> 2
'troy'.succ
=> 'troyz
139.succ
=> 140
#below you will find angry boss AND table of contents, run the file and it will print at the end.
# => angry_boss
print "WHAT DO YOU WANT? "
input = gets.chomp.upcase
puts "WHADDAYA MEAN \"#{input}\"?!? YOU\'RE FIRED!!"
puts "=" * 80
line_width = 80
puts "table of contents".center(line_width)
puts "- " * 40
puts "chapter 1:" + "Getting Started".center(30) + "page 1".rjust(31)
puts "chapter 2:" + "Numbers".center(21) + "page 9".rjust(40)
puts "chapter 3:" + "Letters".center(21) + "page 13".rjust(41)
puts "=" * 80
puts "- - - - - - how I could do it, per the book - - - - - -"
title = 'Table of Contents'.center(50)
chap_1 = 'Chapter 1: Getting Started'.ljust(30) + 'page 1'.rjust(20)
chap_2 = 'Chapter 2: Numbers'.ljust(30) + 'page 9'.rjust(20)
chap_3 = 'Chapter 3: Letters'.ljust(30) + 'page 13'.rjust(20)
puts "=" * 51
puts title
puts "- " * 26
puts chap_1
puts chap_2
puts chap_3
@jaywengrow

Copy link
Copy Markdown

Screencast #3 - nice! Yeah, it was vague, sorry. I did mean "hello".class.class which is indeed a class.
Screencast #4 - awesome! I never heard of casecmp before - good to know!
Angry boss - great!
Table of contents - woohoo!
You're doing great, Troy! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment