Skip to content

Instantly share code, notes, and snippets.

@Martin-Alexander
Martin-Alexander / in_check.rb
Last active August 1, 2019 01:49
in_check.rb
def in_check?(input_string)
board = format_input_string(input_string)
king_coords = king_location(board)
king_x = king_coords[:x]
king_y = king_coords[:y]
# Pawns
return true if piece_at_coords(board, relative_coords(king_coords, { x: 1, y: -1 })) == "P"
return true if piece_at_coords(board, relative_coords(king_coords, { x: 1, y: 1 })) == "P"
require_relative 'cookbook' # You need to create this file!
require_relative 'controller' # You need to create this file!
require_relative 'router'
csv_file = File.join(__dir__, 'recipes.csv')
cookbook = Cookbook.new(csv_file)
controller = Controller.new(cookbook)
router = Router.new(controller)
require_relative 'cookbook' # You need to create this file!
require_relative 'controller' # You need to create this file!
require_relative 'router'
csv_file = File.join(__dir__, 'recipes.csv')
cookbook = Cookbook.new(csv_file)
controller = Controller.new(cookbook)
router = Router.new(controller)
require_relative "task"
require_relative "repository"
require_relative "view"
require_relative "controller"
require_relative "router"
repository = Repository.new
view = View.new
controller = Controller.new(view, repository)
router = Router.new(controller)
# Say hello to the user
# Prompt the user for a first number
# Get user input
# Prompt the user for a second number
# Get user input
# Prompt the user for an operator
# Run the appropraite calculation on the two numbers
# Print the result
puts "Welcome to the calculator app"
require 'open-uri'
require 'nokogiri'
def display_wishlist(wishlist_array)
wishlist_array.each_with_index do |item_hash, index|
if item_hash[:marked]
checkbox = "[X]"
else
checkbox = "[ ]"
end
@Martin-Alexander
Martin-Alexander / app.rb
Last active April 29, 2019 02:43
Food Delivery App
require "csv"
require_relative "router"
require_relative "app/models/meal"
require_relative "app/controllers/meals_controller"
require_relative "app/repositories/meal_repository"
require_relative "app/views/meal_view"
require_relative "app/models/customer"
require "csv"
require_relative "router"
require_relative "app/models/meal"
require_relative "app/controllers/meals_controller"
require_relative "app/repositories/meal_repository"
require_relative "app/views/meal_view"
require_relative "app/models/customer"
require "csv"
require_relative "router"
require_relative "app/models/meal"
require_relative "app/controllers/meals_controller"
require_relative "app/repositories/meal_repository"
require_relative "app/views/meal_view"
require_relative "app/models/customer"
begin
require_relative "../app/models/meal"
rescue LoadError => e
if e.message =~ /meal/
describe "Meal" do
it "You need a `meal.rb` file for your `Meal` model" do
fail
end
end
else