Skip to content

Instantly share code, notes, and snippets.

@foglabs
foglabs / Cash Register I
Created August 12, 2014 17:12
Cash Register I
price = 0
cash = 0
time = Time.now
puts "Please enter the amount due: "
price = gets.chomp.to_f
puts "Please enter the cash tendered: "
cash = gets.chomp.to_f
@foglabs
foglabs / Cash Register II
Last active August 29, 2015 14:05
Cash Register II
input = "beep"
subtotal_items = []
cash = 0
time = Time.now
#puts "Please enter the amount due: "
#price = gets.chomp.to_f
while input.downcase != "done"
@foglabs
foglabs / Hash Movies Example
Last active August 29, 2015 14:05
Hash Movies Example
favorite_movies = [
{ title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 },
{ title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 },
{ title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 }
]
favorite_movies.each do |element|
puts "#{element[:year_released]}: #{element[:title]}"
@foglabs
foglabs / Cash Register III
Created August 14, 2014 21:25
Cash Register III
require 'pry'
require 'csv'
def calc_subtotal(menu, order)
runtotal = 0
order.each do |sku, qty|
subtotal_item = menu.find {|item| item["SKU"] == sku}
runtotal += subtotal_item["retail_price"] * qty
@foglabs
foglabs / Hangman
Created August 17, 2014 15:39
Hangman
require 'pry'
#!/usr/bin/env ruby
wordbank = ['hundred', 'bozo', 'swag', 'lariat', 'bowler', 'ape', 'master']
display_word = String.new
secret_word = String.new
guess = String.new
chances = 10
@foglabs
foglabs / Min-Max-Average Systems Check
Created August 17, 2014 16:03
Min-Max-Average Systems Check
scores = [75, 100, 85, 65, 84, 87, 95]
def min(numb_array)
sorter = numb_array[0]
numb_array.each do |each_num|
if each_num.to_f <= sorter
sorter = each_num.to_f
end
end
sorter
@foglabs
foglabs / comments.html
Last active August 29, 2015 14:05
Swagger News
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>SWAGGER NEWS</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="wrapper">
@foglabs
foglabs / Compound Data Example
Created August 19, 2014 14:49
Compound Data Example
favorite_movies = [
{ title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 },
{ title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 },
{ title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 }
]
favorite_movies.each do |movie|
puts "#{movie[:year_released]}: #{movie[:title]}"
end
@foglabs
foglabs / OOP Card Example
Created August 29, 2014 15:34
OOP Card Example
class Card
def initialize(rank = nil, suit = nil)
if suit.nil?
@suit = ['♠', '♣', '♥', '♦'].sample
else
@suit = suit
end
if rank.nil?
@rank = ['A','2','3','4','5','6','7','8','9','10','J','Q','K'].sample
@foglabs
foglabs / OOP Fake Class Examp
Created August 29, 2014 15:52
OOP Fake Class Examp
class Television
def initialize(size, channel)
@channel = channel
@size = size
end
def change_chan(@channel)
puts "Channel changed to #{@channel}."