Skip to content

Instantly share code, notes, and snippets.

class Vehicle
WHEELS = 4
attr_reader :status
attr_accessor :manufacturer
def initialize(args)
@manufacturer = args[:manufacturer]
@wheels = WHEELS
end
def brake
[4] pry(main)> true ? puts "yes" : puts "no"
SyntaxError: unexpected ':', expecting end-of-input
true ? puts "yes" : puts "no"
^
# Determine whether a string contains a Social Security number.
def has_ssn?(string)
if /\d{3}-\d{2}-\d{4}/.match(string)
true
else
false
end
end
# Return the Social Security number from a string.
def separate_comma(number)
@interjects = (number.to_s.length - 1) / 3
@number = number.to_s.split('')
@comma_number = []
@number = @number.reverse
@number.each_slice(3) do |slice|
@comma_number << slice
if @interjects > 0
@comma_number << ","
@interjects -= 1
class RPNCalculator
def evaluate(string)
@pusher = []
@solver = 0
@string_breakdown = string.split
@string_breakdown.map! do |item|
if item != '+' && item != '-' && item != '*'
item.to_i
else
item
def mode(array)
hash = {}
array.each do |number|
if hash[number] == nil
hash[number] = 1
elsif hash[number]
hash[number] += 1
end
end
@JFickel
JFickel / Tournament Show View
Created November 12, 2012 21:32
Tournament App
%p#notice= notice
%p
%b Name:
= @tournament.name
%p
%b Game:
= @tournament.game
%p
%b Starts at:
@JFickel
JFickel / gist:4049601
Created November 10, 2012 02:31
Procfile
faye: bundle exec thin -p 8081
rackup private_pub.ru -s thin -E production
heroku ps:scale faye=1
## Check if Tournament has already started
@tournament_not_started = true
if TournamentSlot.where(tournament_id: @tournament.id, round: 0).present?
@tournament_not_started = false
end
## Tournament Start
if @tournament.start && @tournament_not_started
slots = TournamentSlot.where(tournament_id: @tournament.id, round: nil)
<% content_for :javascript_includes do %>
<%= javascript_include_tag "colleges.js" %>
<% end %>
<p id="notice"><%= notice %></p>
<h2><%= @college.name %></h2>
<div id="profile_picture"><%= image_tag @college.image.url(:medium) %></div>