summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo k <m@mokhan.ca>2011-11-11 20:14:56 -0700
committermo k <m@mokhan.ca>2011-11-11 20:14:56 -0700
commit50bfdb46921374cefe0f49fc01b62ad04e1284ab (patch)
treeb3f02ea1c049b3330f15c313bcb8c119c3eec5b6 /lib
parentd44be018966cc153ff5501ff3fbd065f6c91b2ad (diff)
move to lib and test folder and add rakefile.
Diffstat (limited to 'lib')
-rw-r--r--lib/book.rb9
-rw-r--r--lib/stack.rb14
2 files changed, 23 insertions, 0 deletions
diff --git a/lib/book.rb b/lib/book.rb
new file mode 100644
index 0000000..56f9c5a
--- /dev/null
+++ b/lib/book.rb
@@ -0,0 +1,9 @@
+class Book
+ attr_reader :title
+ def initialize(title)
+ @title=title
+ end
+ def ==(other)
+ other.kind_of?( Book ) && @title == other.title
+ end
+end
diff --git a/lib/stack.rb b/lib/stack.rb
new file mode 100644
index 0000000..a2b8c04
--- /dev/null
+++ b/lib/stack.rb
@@ -0,0 +1,14 @@
+class Stack
+ def initialize
+ @items = []
+ end
+ def push(item)
+ @items << item
+ end
+ def pop
+ @items.delete_at(-1)
+ end
+ def total_items
+ @items.length
+ end
+end