This is my solution to the Library Challenge.
- rake
- rubocop
- rspec
- coveralls
- Open a ruby shell of your choice, such as irb.
- Load the person.rb file.
load './lib/person.rb'
- Create a person and pass a name as an argument.
person = Person.new('Alfred')
=> #<Person:0x0000000171eca0 @name="Alfred", @books=[]>
- Create a library.
library = Library.new
=> #<Library:0x00000001713670 @collection=[{:item=>{:title=>"Alfons och soldatpappan", :author=>"Gunilla Bergström"}, :available=>true, :return_date=>nil}, {:item=>{:title=>"Skratta lagom! Sa pappa Åberg", :author=>"Gunilla Bergström"}, :available=>true, :return_date=>nil}, {:item=>{:title=>"Osynligt med Alfons", :author=>"Gunilla Bergström"}, :available=>true, :return_date=>nil}, {:item=>{:title=>"Pippi Långstrump", :author=>"Astrid Lindgren"}, :available=>true, :return_date=>nil}, {:item=>{:title=>"Pippi Långstrump går ombord", :author=>"Astrid Lindgren"}, :available=>true, :return_date=>nil}]>
- To see what books are available, type
library.booklist
=> ["Alfons och soldatpappan by Gunilla Bergström", "Skratta lagom! Sa pappa Åberg by Gunilla Bergström", "Osynligt med Alfons by Gunilla Bergström", "Pippi Långstrump by Astrid Lindgren", "Pippi Långstrump går ombord by Astrid Lindgren"]
- To check out a book, type
library.checkout('Alfons och soldatpappan', person)
=> [{:item=>{:title=>"Alfons och soldatpappan", :author=>"Gunilla Bergström"}, :available=>false, :return_date=>"05/12/17"}]
- To see what books are in persons collection, type
person.books
=> [{:title=>"Alfons och soldatpappan", :author=>"Gunilla Bergström", :return_date=>"05/12/17"}]
- To return a book, type
library.return('Alfons och soldatpappan', person)
=> {:title=>"Alfons och soldatpappan", :author=>"Gunilla Bergström", :return_date=>"05/12/17"}