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
bottle_lyric = ->(count) { "#{count} #{count == 1 ? "bottle" : "bottles"} of beer" } | |
99.downto(2) do |c| | |
puts "#{bottle_lyric.call(c)} on the wall," | |
puts "#{bottle_lyric.call(c)}!" | |
puts "Take one down, pass it around" | |
puts "#{bottle_lyric.call(c-1)} on the wall!" | |
puts | |
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 UpvoteCalculator | |
attr_reader :story, :category | |
def initialize story, category | |
@story = story | |
@category = category | |
end | |
def upvotes | |
upvotes = 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
require 'minitest/autorun' | |
describe Toy do | |
it "has a name, description, and a player" do | |
bopit = Toy.new "Bop-it!", "A game for grabby people", "Steven" | |
bopit.welcome.must_equal "Welcome to Bop-it! Steven! A game for grabby people" | |
end | |
it "can have the player changed" do | |
bopit = Toy.new "Bop-it!", "A game for grabby people", "Steven" |
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
require 'minitest/autorun' | |
describe Person do | |
it "is initialized with a name and profession" do | |
person = Person.new "Steven", "Software Developer" | |
person.introduce.must_equal "Hi! My name is Steven. I'm a Software Developer" | |
person.introduce_from_across_the_room.must_equal "HI! MY NAME IS STEVEN. I'M A SOFTWARE DEVELOPER" | |
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
Toy = Class.new do | |
def initialize name, description, player | |
@name = name | |
@description = description | |
@player = player | |
end | |
def player player_name | |
@player = player_name | |
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
# We created a folder to house our code for the class | |
mkdir code | |
# We changed into that directory | |
cd code | |
# We verified git was installed | |
which git | |
# After forking on github, we cloned OUR copy | |
git clone https://github.com/StevenNunez/BEWD_NYC_5.git | |
# We checked what folders are in our code folder. Cloning creates a folder named after the repository. | |
ls |
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
require 'date' | |
class Email | |
attr_reader :email_text | |
def initialize(email_text) | |
@email_text = email_text | |
end | |
def date | |
@date ||= parsed_date.strftime('%a %d %b %Y') | |
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
# Cup | |
# You can ask if it's full or not | |
# | |
# You can fill it | |
# You can empty | |
# if You try to empty it and it's empty is says "I'm already empty" | |
# if You try to fill it and it's full is says "I'm already full" | |
class Cup | |
attr_accessor :owner |
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
int speakerPin = 9; | |
int length = 70; | |
String notes[] = {"G4","G4", "G4", "D#4/Eb4", "A#4/Bb4", "G4", "D#4/Eb4","A#4/Bb4", "G4", "D5", "D5", "D5", "D#5/Eb5", "A#4/Bb4", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4", "G5","G4","G4","G5","F#5/Gb5", "F5","E5","D#5/Eb5","E5", "rest", "G4", "rest","C#5/Db5","C5","B4","A#4/Bb4","A4","A#4/Bb4", "rest", "D#4/Eb4", "rest", "F#4/Gb4", "D#4/Eb4","A#4/Bb4", "G4" ,"D#4/Eb4","A#4/Bb4", "G4"}; | |
int beats[] = { 8, 8, 8, 6, 2, 8, 6 , 2 ,16 , 8, 8, 8, 6, 2, 8, 6, 2, 16,8,6,2,8,6,2,2, 2, 2,6,2,2,8,6,2,2,2,2,6,2,2,9,6,2,8,6,2,16 }; | |
int tempo = 50; | |
void playTone(int tone, int duration) { | |
for (long i = 0; i < duration * 1000L; i += tone * 2) { | |
digitalWrite(speakerPin, HIGH); | |
delayMicroseconds(tone); |
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
# This file should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | |
# | |
# Examples: | |
# | |
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | |
# Mayor.create(name: 'Emanuel', city: cities.first) | |
# | |
puts "Adding a Whole bunch of movies" | |
Movie.create [ |