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
# Ruby-doc documentation from http://ruby-doc.org/core-2.0/Object.html#method-i-class | |
guy = "Bob" | |
guy.define_singleton_method(:hello) { "#{self}: Hello there!" } | |
guy.hello #=> "Bob: Hello there!" | |
# ------------------------------------------------------------------------------ | |
# Here is what I get on my machine: | |
guy = "Bob" |
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
ltouch() | |
{ | |
touch $1 | |
open $1 | |
} |
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
class Dog | |
def initialize(name) | |
@name = name | |
end | |
def method_missing(m, *args, &block) | |
puts "#{@name} doesn't know how to #{m} yet!" | |
end | |
def eigenclass |
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
puts "Please enter a sentence." | |
user_input = gets.chomp | |
array = user_input.downcase.split(' ') | |
punct_indices = {} | |
array.each do |x| | |
contains_punct = /[[:punct:]&&[^']]/ =~ x | |
if contains_punct |
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
name_arr = [] | |
name_str = '' | |
print "What are your initials? " | |
correct_name = gets.chomp.upcase | |
print "Thanks! Let's see how long it takes me to randomly re-create your initials." | |
sleep 3 | |
until name_str == correct_name | |
letter_set = ('A'..'Z').to_a |