Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/library
. To experiment with that code, run bin/console
for an interactive prompt.
TODO: Delete this and the text above, and describe your gem
Add this line to your application's Gemfile:
gem 'library'
And then execute:
$ bundle
Or install it yourself as:
$ gem install library
Create an empty library and fill it:
require 'bundler/setup'
require "library"
library = Library::Library.new
library.add_book("fst book", "JL")
library.add_book("scn book", "JL")
library.add_book("trd book", "JL2")
library.add_book("super book", "JL2")
library.add_book("super book 2", "JL2")
library.add_book("super book 3", "JL2")
# create readers
reader = library.add_reader("amdj15", "[email protected]", "Dp")
reader_2 = library.add_reader("reader_2", "[email protected]", "Dp")
reader_3 = library.add_reader("reader_3", "[email protected]", "Dp")
# create orders
library.add_order(reader, "fst book", "JL")
library.add_order(reader, "scn book", "JL")
library.add_order(reader, "trd book", "JL2")
library.add_order(reader_2, "scn book", "JL")
library.add_order(reader_2, "trd book", "JL2")
library.add_order(reader_3, "scn book", "JL")
# save to file
library.save
Or load from file:
library = Library::Library.load "data"
Actions:
puts library.who_often_takes_the_book.name
puts library.most_popular_book
library.how_many_people_ordered_one_of_the_three_most_popular_books.each {|book| puts "#{book.title} : #{book.ordersCnt}"}
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
- Fork it ( https://github.com/[my-github-username]/library/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request