Skip to content

Instantly share code, notes, and snippets.

View mfifth's full-sized avatar

Matt Quinto mfifth

View GitHub Profile
class Animal
def initialize(name, age, color, type)
@name = name
@age = age
@color = color
@type = type
end
def describe
puts "This is #{@name}, he/she is #{@age}, is #{@color}, and is a #{@type}."
class Dungeon
attr_accessor :player #Is this an instance variable? or a class variable?
def initialize(player_name) #Why is this here?
@player = Player.new(player_name) #What is this code doing?
@rooms = [] #Why is there an "@" before rooms? This isn't an instance variable is it?
end
def add_room (reference, name, description, connections)
@rooms << Room.new(reference, name, description, connections)
class Dungeon
attr_accessor :player #Is this an instance variable? or a class variable?
def initialize(player_name) #Why is this here?
@player = Player.new(player_name) #What is this code doing?
@rooms = [] #Why is there an "@" before rooms? This isn't an instance variable is it?
end
def add_room (reference, name, description, connections)
@rooms << Room.new(reference, name, description, connections)
class Dungeon
attr_accessor :player #Is this an instance variable? or a class variable?
def initialize(player_name) #Why is this here?
@player = Player.new(player_name) #What is this code doing?
@rooms = []
end
def add_room (reference, name, description, connections)
@rooms << Room.new(reference, name, description, connections)
@mfifth
mfifth / gist:8d6bcb3cb132431a1b03
Created October 17, 2015 22:08
Caesar_Cipher
class Caesar_Cipher
def initialize(string, shift)
@string = string
@shift = shift
@lowercase = ("a".."z")
@uppercase = ("A".."Z")
@output = []
end
def letter_shift
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
Showing /home/ubuntu/workspace/app/views/tickets/show.html.erb where line #21 raised:
undefined method `email' for nil:NilClass
Extracted source (around line #21):
19
20
21
22
23
24
class TicketsController < ApplicationController
before action :validate_user, only: [:create, :new]
before_action :set_project
before_action :set_ticket, only: [:show, :edit, :update, :destroy]
def new
@ticket = @project.tickets.build
end
def destroy
@mfifth
mfifth / gist:77b45f25d2ed0904c1dab8bae626c63b
Created April 27, 2016 20:06
Pundit Matcher for user roles
RSpec::Matchers.define :permit_action do |action|
match do |policy|
policy.public_send("#{action}?")
end
failure_message do |policy|
"#{policy.class} does not allow #{policy.user || "nil"} to " +
"perform :#{action}? on #{policy.record}."
end
require 'rails_helper'
RSpec.describe "Administrators can create posts and enable user privileges" do
let(:admin) { FactoryGirl.create(:user, :admin) }
before do
login_as(admin)
visit '/'
end