Skip to content

Instantly share code, notes, and snippets.

@seth-at-at
Created February 9, 2017 17:37
Show Gist options
  • Save seth-at-at/008bc0ea0135e66e0426e8dbf6c288ce to your computer and use it in GitHub Desktop.
Save seth-at-at/008bc0ea0135e66e0426e8dbf6c288ce to your computer and use it in GitHub Desktop.
class PizzaOven
def cook_pizza
"mmm 'za"
end
end
class Student
attr_reader :name
def initialize(name = "name")
@name = name
end
end
class ArrayDiagnostic
def array
[1, 2, 3, 4, 5]
end
def doubles
array.map do |num|
num * 2
end
end
def sum_of_doubles
doubles.reduce(:+)
end
end
class PizzaTest < Minitest::Test
def test_returns_if_tasty
pizza = Pizza.new
assert_equal true, Pizza.is_tasty?
end
def test_is_pizza_any_of_three_styles
pizza = Pizza.new
assert_equal "supreme" || "mediterranean" || "cheese", pizza.style
end
end
# Steps to create git repo
# git init
# git add .
# git commit -m "first commit"
# git remote add origin (git repository link)
# git push -u origin master
class Student
attr_reader :attitude, :assignment
def initialize(attitude = "cheerful")
@attitude = attitude
@assignment = []
end
def asssign_homework(description)
assignment << description
if attitude == "cheerful"
attitude = "dubious"
elsif attitude == "dubious"
attitude = "perturbed"
elsif attitude == "perturbed"
attitude = "dazed"
else
attitude
end
end
def assignments
assignment.join(", ")
end
end
hw = students.map do |student|
student.assignments
end
"x: 4"
"b: 12"
class ReadFile
def initialize
@read = File.read("given").split("\n")
end
def print_each_line
File.open(ARGV[0], 'w') { |text| text.puts @read.join("\n")
end
def how_many_lines
File.open(given, 'w' { |text| text.puts @read.count)
end
end
class Corgi
attr_reader :name, :posture
def initialize(name, posture = "standing")
@name = name
@posture = posture
end
def lay_down
posture = "laying"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment