Class: Isbnify::IISBNA
- Inherits:
-
Object
- Object
- Isbnify::IISBNA
- Defined in:
- lib/isbnify/iisbna.rb
Instance Attribute Summary collapse
-
#country_group ⇒ Object
Returns the value of attribute country_group.
-
#group_hash ⇒ Object
Returns the value of attribute group_hash.
-
#isbn ⇒ Object
Returns the value of attribute isbn.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#publisher ⇒ Object
Returns the value of attribute publisher.
-
#range_hash ⇒ Object
Returns the value of attribute range_hash.
Instance Method Summary collapse
- #create_valid_isbn ⇒ Object
- #hyphinate ⇒ Object
-
#initialize(isbn = "") ⇒ IISBNA
constructor
A new instance of IISBNA.
Constructor Details
#initialize(isbn = "") ⇒ IISBNA
Returns a new instance of IISBNA.
9 10 11 12 |
# File 'lib/isbnify/iisbna.rb', line 9 def initialize(isbn = "") @isbn = isbn.to_s @range_hash = xml_parse end |
Instance Attribute Details
#country_group ⇒ Object
Returns the value of attribute country_group.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def country_group @country_group end |
#group_hash ⇒ Object
Returns the value of attribute group_hash.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def group_hash @group_hash end |
#isbn ⇒ Object
Returns the value of attribute isbn.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def isbn @isbn end |
#prefix ⇒ Object
Returns the value of attribute prefix.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def prefix @prefix end |
#publisher ⇒ Object
Returns the value of attribute publisher.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def publisher @publisher end |
#range_hash ⇒ Object
Returns the value of attribute range_hash.
7 8 9 |
# File 'lib/isbnify/iisbna.rb', line 7 def range_hash @range_hash end |
Instance Method Details
#create_valid_isbn ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/isbnify/iisbna.rb', line 19 def create_valid_isbn random_group = range_hash[:"ISBNRangeMessage"][:"RegistrationGroups"][:"Group"].shuffle[0] group = random_group[:Prefix] rule = random_group[:Rules][:Rule].is_a?(Array) ? random_group[:Rules][:Rule].shuffle[0] : random_group[:Rules][:Rule] r_publisher = random_publisher(rule) create_isbn(group, r_publisher) end |
#hyphinate ⇒ Object
14 15 16 17 |
# File 'lib/isbnify/iisbna.rb', line 14 def hyphinate return "invalid international ISBN13 number" unless valid_prefix? && valid_group? && valid_publisher? hyphinate_with_values end |