Skip to content

Instantly share code, notes, and snippets.

@BrianJoyce
BrianJoyce / todo.rb
Created October 16, 2012 03:43
todo 1.9
require_relative 'todoList'
my_new_todo = Todo.new("some interesting stuff")
top_to_do = Todo.new("This at the top")
todo_list = TodoList.new
# todo_list.list
puts "ID | Date | Item | Priority | Completed | Tags |"
puts "--------------------------------------------------------------------------------------------------------------------"
# todo_list.append(my_new_todo.todo)
# todo_list.prepend(top_to_do.todo)
@BrianJoyce
BrianJoyce / todo_more.rb
Created October 15, 2012 08:46
todo_stuff
class Todo
@@todo_id = 0
attr_accessor :todo
def initialize(todo)
@todo = {}
text(todo)
date_time(Time.now)
todo_id
end
@BrianJoyce
BrianJoyce / todo.rb
Created October 15, 2012 06:03
todo_Arne
class TodoFile
attr_accessor :todo_file
def initialize(filename)
@filename = filename
end
def read(access='r')
@todo_file = File.open(@filename, access)
end
@BrianJoyce
BrianJoyce / todo_working.rb
Created October 15, 2012 01:45
todo list working
require_relative 'todo_class'
input = ARGV
action = input.slice!(0)
my_task = Todo.new
puts "My TODO list"
puts "---------------------"
my_task.list if action == "list"
@BrianJoyce
BrianJoyce / todo_list_3.rb
Created October 15, 2012 01:45
todo_list_refactoring.rb
class Todo_file
attr_accessor :todo_file
def initialize(filename)
@filename = filename
end
def read(access='r')
@todo_file = File.open(@filename, access)
end
@BrianJoyce
BrianJoyce / hospital.rb
Created October 14, 2012 07:25
hospital
#People
# class Database
#
# attr_accessor :records
#
# @@max_record_id = 0
# @@records = []
#
# def next_id
@BrianJoyce
BrianJoyce / c_and_o.rb
Created October 13, 2012 08:29
cookies and ovens
class Oven
def initialize
end
def heat(temperature=350)
temperature
end
def has_batch?
@BrianJoyce
BrianJoyce / c_and_o.rb
Created October 13, 2012 08:28
cookies and ovens
class Oven
def initialize
end
def heat(temperature=350)
temperature
end
def has_batch?
@BrianJoyce
BrianJoyce / nums_to_words.rb
Created October 13, 2012 00:06
numbers_words
require 'pry'
class NumbersToWords
def initialize
@single = %w[zero one two three four five six seven eight nine ten elevin
twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen]
@tens = %w[twenty thirty fourty fifty sixty seventy eighty ninety]
@words = ""
end
@BrianJoyce
BrianJoyce / binary_search.rb
Created October 12, 2012 00:23
binary_search_fail
=begin
Given an array and a number that we are looking for
Find midpoint of array
is number equal to the midpoint?
return index of number
Is it greater?
set midpoint + 1 as new_min
recurse
Is it less?