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 Car | |
attr_reader :color, :owner, :cylinders | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
end |
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 Card | |
attr_reader :rank, :suit | |
def initalize(rank, suit) | |
@suit = suit | |
@rank = rank | |
end | |
end |
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 Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def erase | |
@contents = [] | |
end |
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 Whiteboard | |
attr_accessor :contents | |
def initialize(contents = []) | |
@contents = contents | |
end | |
def erase | |
@contents = [] | |
end |
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 Circle | |
def initialize(radius) | |
@radius = radius | |
end | |
def diameter | |
2 * @radius | |
end | |
def circumference |
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
salutations = [['Mr.', 'Mrs.'], 'Mrs.', ['Mr.', 'Mrs.'], ['Dr.'], 'Ms.'] | |
first_names = ['John', 'Jane', 'Sam', 'Louise', 'Kyle'] | |
last_names = ['Dillinger', 'Cook', 'Livingston', 'Levinger', 'Merlotte'] | |
addresses = ['33 Foolish Lane, Boston, MA 02210', | |
'45 Cottage Way, Dartmouth, MA 02342', | |
"54 Sally's Court, Bridgewater, MA 02324", | |
'4534 Broadway, Boston, MA 02110', | |
'4231 Cynthina Drive, Raynham, MA 02767'] | |
mail_list = [] |
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 Animal | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def eat | |
3.times { puts "chomp" } | |
end |
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
select * from tasks where title = "Buy milk"; |
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
#!/usr/bin/env ruby | |
# run via command line: ./anagrams.rb word | |
p ARGV[0].chars.to_a.permutation.map(&:join) |
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
-- What 3 towns have the highest population of citizens that are 65 years and older? | |
select city, population_over_65_in_2005 | |
from town_health_records | |
order by population_over_65_in_2005 desc | |
limit 3; | |
-- city population_over_65_in_2005 | |
-- ---------- -------------------------- | |
-- Boston 59950 | |
-- Worcester 23062 |