-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rb
46 lines (42 loc) · 1.05 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding: utf-8
$:.unshift File.dirname(__FILE__)
require "stringio"
require "circulation_status"
require "book"
require "database"
class Main
class << self
def book_to_database(path)
b1 = Book.new({
:id => "001",
:title=>"刀語 第一話 絶刀・鉋",
:author=>"西尾 維新",
:isbn=>"9784062836111",
:status=>CirculationStatus::BACKORDERED
})
b2 = Book.new({
:id => "002",
:title=>"刀語 第二話 斬刀・鈍",
:author=>"西尾 維新",
:isbn=>"9784062836043"
})
b3 = Book.new({
:id => "003",
:title=>"刀語 第三話 千刀・ツルギ",
:author=>"西尾 維新",
:isbn=>"9784062836197",
:status=>CirculationStatus::LENDING
})
Database.new(path){|d|
puts d.list
[b1,b2,b3].each{ |b| d.add(b) }
puts d.list
p d.find("002")
}
end
end
end
if __FILE__ == $PROGRAM_NAME
abort "1.9 only" unless RUBY_VERSION >= "1.9"
Main.book_to_database("book.bin")
end