This file contains hidden or 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
# Download this file: | |
# https://gist.github.com/aviflombaum/872638777f7511d2a30a/download | |
# Run it from your terminal with: | |
# ruby ruby.basics.rb | |
# (Just make sure you are in the right directory) | |
# ====================================== | |
# Ignore All This Code | |
# ====================================== |
This file contains hidden or 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 Person | |
attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, | |
:complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width | |
def initialize(attributes) | |
attributes.each do |key, value| | |
self.instance_variable_set("@#{key}", value) | |
end | |
end |
This file contains hidden or 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
require 'sqlite3' | |
class Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :id | |
@@db = SQLite3::Database.new 'students.db' | |
@@students = [] | |
def initialize |
This file contains hidden or 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 TriangleError < Exception | |
end | |
class Triangle | |
attr_accessor :side1, :side2, :side3 | |
def initialize(side1, side2, side3) | |
@side1 = side1 | |
@side2 = side2 | |
@side3 = side3 |
This file contains hidden or 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
songs = { | |
"The Phoenix - 1901" => "https://www.youtube.com/watch?v=gvss3uhSKjw", | |
"Tokyo Police Club - Wait Up" => "https://www.youtube.com/watch?v=ZAxRozTgoXM", | |
"Sufjan Stevens - Too Much" => "https://www.youtube.com/watch?v=K0g7R3xqdcM", | |
"The Naked and the Famous - Young Blood" => "https://www.youtube.com/watch?v=0YuSg4mts9E", | |
"(Far From) Home - Tiga" => "https://www.youtube.com/watch?v=jTwQbc9kkUc", | |
"The Cults - Abducted" => "https://www.youtube.com/watch?v=9i1MXHGB8g0", | |
"The Phoenix - Consolation Prizes" => "https://www.youtube.com/watch?v=gnkVUReUVpQ" | |
} |
This file contains hidden or 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 Anagram | |
attr_accessor :word | |
def initialize(word) | |
@word = word | |
end | |
def match(words_array) | |
words_array.select {|element| element.chars.sort == @word.chars.sort} | |
end |
This file contains hidden or 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
def full_library | |
{ | |
:"U2" => { | |
:albums => { | |
:"The Joshua Tree" => { | |
:songs => ["With or Without You", "Still Haven't Found What I'm Looking For", "Bullet the Blue Sky"] | |
}, | |
:"Zooropa" => { | |
:songs => ["Numb"] | |
} |
This file contains hidden or 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
require_relative './jukebox.rb' | |
def run | |
puts "Welcome to Ruby Console Jukebox!" | |
command = "" | |
while command.downcase != "exit" do | |
puts "Enter a command to continue. Type 'help' for a list of commands." | |
command = get_command | |
run_command(command) unless command.downcase == "exit" | |
end |
This file contains hidden or 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
require_relative './song_library.rb' | |
def jukebox(command) | |
if command.downcase == "list" | |
list_library | |
else | |
parse_command(command) | |
end | |
end |
This file contains hidden or 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
#table/database 003-students | |
#student_name h4 class="ib_main_header" | |
#twitter_link div class="social-icons" ahref | |
#linkedin_link div class="social-icons" ahref | |
#github_link div class="social-icons" ahref | |
#quote div class="textwidget" h3 | |
#biography div class="services" where h3(div class="services-title") is Biography (text for bio in p) | |
#education div class="services" where h3(div class="services-title") is Education (text for University in li) | |
#work div class="services" h4 | |
#treehouse_link div class="column-fourth" ahref with img alt="Treehouse" |