Skip to content

changed valid? method to check also correctness of isbn13#16

Open
jbutton wants to merge 2 commits intoragalie:mainfrom
jbutton:master
Open

changed valid? method to check also correctness of isbn13#16
jbutton wants to merge 2 commits intoragalie:mainfrom
jbutton:master

Conversation

@jbutton
Copy link
Copy Markdown
Contributor

@jbutton jbutton commented Mar 5, 2019

I've renamed current valid? method to valid_checksum?
in new valid? method i'm using parts method to find if ISBN is valid.

But I'm not sure if parts method check is needed for ISBN10 since it is valid when checksum is correct.
So perhaps:

 def valid_isbn_10?
    valid_checksum_isbn_10? #would be better
    # instead of !parts(4).blank?
  end

  def valid_isbn_13?
    !parts.blank?
  end

@jbutton
Copy link
Copy Markdown
Contributor Author

jbutton commented Mar 5, 2019

Ok
First thing to correct: forgot to cache new methods. I'll add it to cache_method with feedback.

Comment thread lib/lisbn/lisbn.rb Outdated
# Returns nil if the ISBN is invalid or incapable of conversion to ISBN-10.
def isbn10
return unless valid?
return unless valid_checksum?
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use valid??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, it's now doing proper isbn10 validation.

Copy link
Copy Markdown
Owner

@ragalie ragalie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! If these changes are ready to go fix the conflicts and let us know and we'll get them merged in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants