This file contains hidden or 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 Vehicle | |
WHEELS = 4 | |
attr_reader :status | |
attr_accessor :manufacturer | |
def initialize(args) | |
@manufacturer = args[:manufacturer] | |
@wheels = WHEELS | |
end | |
def brake |
This file contains hidden or 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
[4] pry(main)> true ? puts "yes" : puts "no" | |
SyntaxError: unexpected ':', expecting end-of-input | |
true ? puts "yes" : puts "no" | |
^ |
This file contains hidden or 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
# 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. |
This file contains hidden or 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 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 |
This file contains hidden or 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 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 |
This file contains hidden or 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 mode(array) | |
hash = {} | |
array.each do |number| | |
if hash[number] == nil | |
hash[number] = 1 | |
elsif hash[number] | |
hash[number] += 1 | |
end | |
end | |
This file contains hidden or 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
%p#notice= notice | |
%p | |
%b Name: | |
= @tournament.name | |
%p | |
%b Game: | |
= @tournament.game | |
%p | |
%b Starts at: |
This file contains hidden or 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
faye: bundle exec thin -p 8081 | |
rackup private_pub.ru -s thin -E production | |
heroku ps:scale faye=1 |
This file contains hidden or 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
## 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) |
This file contains hidden or 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
<% 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> |