Class: Gtiny::ISBN13

Inherits:
ISBN show all
Defined in:
lib/gtiny/isbn13.rb

Overview

ISBN-13: Used for all books published on or after January 1st, 2007.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ISBN

#check_digit, #group_identifier, normalize, #publisher_identifier, #title_identifier, #valid?

Methods inherited from Encoding

#initialize, matches?, normalize, #to_s, #valid?, #zeroes?

Constructor Details

This class inherits a constructor from Gtiny::Encoding

Class Method Details

.regexObject

The ISBN-13 format consists of 5 groups, separated by hyphens (or spaces).

  1. The prefix element, 3 digits - so far only 978 and 979 are used.

  2. The group identifier, up to five digits

  3. The publisher identifier, up to seven digits

  4. The title identifier, up to 6 digits

  5. The check digit



15
16
17
# File 'lib/gtiny/isbn13.rb', line 15

def self.regex
  /\A97(?:8|9)[- ]?[0-9]{1,5}[- ]?[0-9]{1,7}[- ]?[0-9]{1,6}[- ]?[0-9]\z/
end

Instance Method Details

#prefix_elementObject



23
24
25
26
27
# File 'lib/gtiny/isbn13.rb', line 23

def prefix_element
  check_number_of_groups!

  groups[0]
end

#typeObject



19
20
21
# File 'lib/gtiny/isbn13.rb', line 19

def type
  "ISBN-13"
end