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
require 'yaml' | |
class TimeTrack | |
def initialize | |
@time_list = 'times.yml' | |
#Storing all of the time entries in a yml file and reading them into an array | |
prepare_file(@time_list) | |
all_times = YAML.load(open(@time_list)) |
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
require 'yaml' | |
def time_get | |
puts "Please hit Enter to start time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_get | |
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
def time_get | |
puts "Please hit Enter to start time tracking" | |
if gets.chomp == "" | |
Time.now | |
else | |
time_get | |
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
# http://en.wikibooks.org/wiki/Algorithm_implementation/Sorting/Merge_sort | |
def mergesort(list) | |
return list if list.size <= 1 | |
mid = list.size / 2 | |
left = list[0, mid] | |
right = list[mid, list.size] | |
merge(mergesort(left), mergesort(right)) | |
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
def insertion_sort(words) | |
words.each_with_index do |word, index| | |
index.downto(0) do |placement| | |
if (placement > 0 && word < words[placement-1]) | |
words[placement] = words[placement-1] | |
else | |
words[placement] = word | |
break | |
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
# http://sheelkapur.com/2008/09/22/ruby-insertion-sort/ | |
def insertion_sort (list) | |
list.each_with_index do |element, index| | |
index.downto(0) do |j| | |
if (j > 0 && element < list[j-1]) then | |
list[j] = list[j-1] | |
else | |
list[j] = element | |
break | |
end |
NewerOlder