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 '../config/environment' | |
class CLI | |
attr_accessor :songs | |
def initialize | |
@songs = Song.all | |
@on = true | |
call | |
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
class Song | |
attr_accessor :title, :artist | |
def serialize | |
File.new("#{self.title.gsub(" ", "_")}.txt", "w") | |
File.open("#{self.title.gsub(" ", "_")}.txt", "w") do |f| | |
f.print "#{self.artist.name} - #{self.title}" | |
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
tweet1 = "Hey guys, can anyone teach me how to be cool? I really want to be the best at everything, you know what I mean? Tweeting is super fun you guys!!!!" | |
tweet2 = "OMG you guys, you won't believe how sweet my kitten is. My kitten is like super cuddly and too cute to be believed right?", "I'm running out of example tweets for you guys, which is weird, because I'm a writer and this is just writing and I tweet all day. For real, you guys. For real." | |
tweet3 = "GUISEEEEE this is so fun! I'm tweeting for you guys and this tweet is SOOOO long it's gonna be way more than you would think twitter can handle, so shorten it up you know what I mean? I just can never tell how long to keep typing!" | |
def shortener(tweet) | |
tweet.join(" ") | |
array = tweet.split(" ") | |
i = 0 | |
array.each do |word| |
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
# assignment.rb | |
# FizzBuzz - The Programmer's Stairway to Heaven | |
# Define the fizzbuzz method to do the following: 10pts | |
# Use the modulo % method (divisible by) | |
# 2 % 2 #=> true | |
# 1 % 2 #=> false | |
# If a number is divisible by 3, puts "Fizz". | |
# If a number is divisible by 5, puts "Buzz". | |
# If a number is divisible by 3 and 5, puts "FizzBuzz" |
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 Integer | |
def to_roman | |
numeral = "" | |
number = self | |
hash = {1000 => "M", 900 => "CM", 500 => "D", 400 => "CD", 100 => "C", 90 => "XC", 50 => "L", 40 => "XL", 10 => "X", 9 => "IX", 5 => "V", 4 => "IV", 1 => "I"} | |
hash.each do |key, value| | |
until number < key | |
numeral << value |
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 Integer | |
def to_roman | |
numeral = "" | |
number = self | |
until number == 0 do | |
if number >= 1000 | |
number -= 1000 | |
numeral << "M" | |
elsif number >= 900 |
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 'simplecov' | |
SimpleCov.start | |
require 'json' | |
require 'rspec' | |
require_relative 'jukebox' | |
require_relative 'song' | |
describe Song do | |
it 'can have a name' do |
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 Triangle | |
attr_accessor :side1, :side2, :side3 | |
def initialize(side1, side2, side3) | |
@side1 = side1 | |
@side2 = side2 | |
@side3 = side3 | |
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
songs = [ | |
"1. The Phoenix - 1901", | |
"2. Tokyo Police Club - Wait Up", | |
"3. Sufjan Stevens - Too Much", | |
"4. The Naked and the Famous - Young Blood", | |
"5. (Far From) Home - Tiga", | |
"6. The Cults - Abducted", | |
"7. The Phoenix - Consolation Prizes" | |
] |
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 | |
def initialize(word) | |
@name = word | |
end | |
def match(array) | |
matched = [] | |
array.each do |string| | |
if string.chars.sort == @name.chars.sort | |
matched << string |