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 'csv' | |
require 'pry' | |
require 'active_support/all' | |
class CSVParser | |
attr_accessor :filename, :items, :rows, :options, :headers | |
# Optional params: | |
# -nh No header in csv | |
def initialize(args) |
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 CustomMailExporter | |
require 'fileutils' | |
attr_accessor :service, :target_users, :target_start_date, :target_end_date, | |
:path, :errors, :filename_counter, :emails_found | |
# Dates should be in Date or DateTime format. Users should be an array. | |
def initialize(service, target_users, target_start_date, target_end_date) | |
@service = service | |
@target_users = target_users.map(&:downcase) |
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 Car | |
def initialize(color, owner, cylinders) | |
@color = color | |
@owner = owner | |
@cylinders = cylinders | |
end | |
def color | |
@color | |
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 | |
def initialize(rank, suit) | |
@suit = suit | |
@rank = rank | |
end | |
def suit | |
@suit | |
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 television | |
def initialize(make, model, type, channel = 3, volume = 5) | |
@make = make | |
@model = model | |
@type = type | |
@channel=channel | |
@volume=volume | |
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 | |
def initialize(rank = nil, suit = nil) | |
if suit.nil? | |
@suit = ['♠', '♣', '♥', '♦'].sample | |
else | |
@suit = suit | |
end | |
if rank.nil? | |
srand() | |
@rank = rand(13)+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
SELECT title, rating FROM movies ORDER BY rating LIMIT 50; | |
SELECT title FROM movies WHERE rating = 0 ORDER BY title; | |
SELECT title FROM movies WHERE synopsis LIKE '%thrilling%'; | |
SELECT movies.title, movies.year, movies.rating FROM movies JOIN genres ON movies.genre_id = genres.id WHERE genres.name = 'Science Fiction & Fantasy' AND year BETWEEN 1980 AND 1989 ORDER BY rating DESC; | |
SELECT actors.name, movies.title, movies.year FROM movies | |
JOIN cast_members ON movies.id = cast_members.movie_id |
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
def find_average scores | |
sum = 0.0 | |
scores.each do |x| | |
sum += x | |
end | |
return sum/scores.length | |
end | |
def find_max scores | |
answer = 0 |
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 'csv' | |
require 'pry' | |
def return_sku (hash, number) | |
answer = hash.first(number) | |
return answer[-1][0] | |
end | |
NewerOlder