Module: Petrarca
- Extended by:
- Petrarca
- Included in:
- Petrarca
- Defined in:
- lib/petrarca.rb,
lib/petrarca/isbn10.rb,
lib/petrarca/isbn13.rb,
lib/petrarca/helpers.rb,
lib/petrarca/version.rb
Defined Under Namespace
Modules: Helpers, ISBN10, ISBN13
Classes: Error, IncorrectFormatError, InvalidEANPrefixError, InvalidRangeError
Constant Summary
collapse
- REGISTRATION_GROUP_RANGES =
Helpers.load_ranges("#{data_dir}/registration_group_ranges.txt")
- REGISTRANT_RANGES =
Helpers.load_ranges("#{data_dir}/registrant_ranges.txt")
- VERSION =
"0.5.0"
Instance Method Summary
collapse
Instance Method Details
#calc_check_digit(isbn) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/petrarca.rb', line 28
def correct_format?(isbn)
case isbn.to_s.delete("-").size
when 13
ISBN13.correct_format?(isbn)
when 10
ISBN10.correct_format?(isbn)
else
false
end
end
|
#hyphenate(isbn) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/petrarca.rb', line 51
def hyphenate(isbn)
isbn = isbn.to_s
case isbn.size
when 13
ISBN13.hyphenate(isbn)
when 10
ISBN10.hyphenate(isbn)
end
end
|
#valid?(isbn) ⇒ Boolean
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/petrarca.rb', line 17
def valid?(isbn)
case isbn.to_s.delete("-").size
when 13
ISBN13.valid?(isbn)
when 10
ISBN10.valid?(isbn)
else
false
end
end
|