Module: Sjekksum

Extended by:
Sjekksum
Included in:
Sjekksum
Defined in:
lib/sjekksum.rb,
lib/sjekksum/upc.rb,
lib/sjekksum/luhn.rb,
lib/sjekksum/damm.rb,
lib/sjekksum/shared.rb,
lib/sjekksum/isbn13.rb,
lib/sjekksum/isbn10.rb,
lib/sjekksum/version.rb,
lib/sjekksum/verhoeff.rb,
lib/sjekksum/primitive.rb,
lib/sjekksum/primitive97.rb

Overview

Base module with convenient shortcuts

Defined Under Namespace

Modules: Damm, ISBN10, ISBN13, Luhn, Primitive, Primitive97, Shared, UPC, Verhoeff

Constant Summary collapse

VERSION =

Version constant

"0.1.1"

Instance Method Summary collapse

Instance Method Details

#damm_of(number) ⇒ Integer Also known as: damm

Calculates Damm checksum

Examples:

Sjekksum.damm(572) #=> 4

See Also:


29
30
31
# File 'lib/sjekksum.rb', line 29

def damm_of number
  Damm.of number
end

#isbn10_of(number) ⇒ Integer, String Also known as: isbn10

Calculates ISBN-10 checksum

Examples:

Sjekksum.isbn10("147743025") #=> 3
Sjekksum.isbn10("193435600") #=> "X"

See Also:


46
47
48
# File 'lib/sjekksum.rb', line 46

def isbn10_of number
  ISBN10.of number
end

#isbn13_of(number) ⇒ Integer, String Also known as: isbn13

Calculates ISBN-13 checksum

Examples:

Sjekksum.isbn13("978-0-306-40615-") #=> 7

See Also:


62
63
64
# File 'lib/sjekksum.rb', line 62

def isbn13_of number
  ISBN13.of number
end

#luhn_of(number) ⇒ Integer Also known as: luhn

Calculates Luhn checksum

Examples:

Sjekksum.luhn(7992739871) #=> 3

See Also:


78
79
80
# File 'lib/sjekksum.rb', line 78

def luhn_of number
  Luhn.of number
end

#make_damm(number) ⇒ Integer, String Also known as: damm!

Transforms a number by appending the Damm checksum digit

Examples:

Sjekksum.damm!(572) #=> 5724

See Also:


287
288
289
# File 'lib/sjekksum.rb', line 287

def make_damm number
  Damm.convert number
end

#make_isbn10(number) ⇒ Integer, String Also known as: isbn10!

Transforms a number by appending the ISBN-10 checksum digit

Examples:

Sjekksum.isbn10!("147743025") #=> "1477430253"
Sjekksum.isbn10!("193435600") #=> "193435600X"

See Also:


304
305
306
# File 'lib/sjekksum.rb', line 304

def make_isbn10 number
  ISBN10.convert number
end

#make_isbn13(number) ⇒ Integer, String Also known as: isbn13!

Transforms a number by appending the ISBN-13 checksum digit

Examples:

Sjekksum.isbn13("978-0-306-40615-") #=> "978-0-306-40615-7"

See Also:


320
321
322
# File 'lib/sjekksum.rb', line 320

def make_isbn13 number
  ISBN13.convert number
end

#make_luhn(number) ⇒ Integer, String Also known as: luhn!

Transforms a number by appending the Luhn checksum digit

Examples:

Sjekksum.luhn!(7992739871) #=> 79927398713

See Also:


336
337
338
# File 'lib/sjekksum.rb', line 336

def make_luhn number
  Luhn.convert number
end

#make_primitive(number) ⇒ Integer, String Also known as: primitive!

Transforms a number by appending the Primitive checksum digit

Examples:

Sjekksum.primitive!(232323) #=> 2323236

See Also:


384
385
386
# File 'lib/sjekksum.rb', line 384

def make_primitive number
  Primitive.convert number
end

#make_primitive97(number) ⇒ Integer, String Also known as: primitive97!

Transforms a number by appending the Primitive97 checksum digit

Examples:

Sjekksum.primitive97!(232323) #=> 2323235

See Also:


400
401
402
# File 'lib/sjekksum.rb', line 400

def make_primitive97 number
  Primitive97.convert number
end

#make_upc(number) ⇒ Integer, String Also known as: upc!

Transforms a number by appending the UPC checksum digit

Examples:

Sjekksum.upc!("03600024145") #=> "03600024147"

See Also:


352
353
354
# File 'lib/sjekksum.rb', line 352

def make_upc number
  UPC.convert number
end

#make_verhoeff(number) ⇒ Integer, String Also known as: verhoeff!

Transforms a number by appending the Verhoeff checksum digit

Examples:

Sjekksum.verhoeff!(142857) #=> 1428570

See Also:


368
369
370
# File 'lib/sjekksum.rb', line 368

def make_verhoeff number
  Verhoeff.convert number
end

#primitive97_of(number) ⇒ Integer Also known as: primitive97

Calculates Primitive97 checksum

Examples:

Sjekksum.primitive97(232323) #=> 6

See Also:


142
143
144
# File 'lib/sjekksum.rb', line 142

def primitive97_of number
  Primitive97.of number
end

#primitive_of(number) ⇒ Integer Also known as: primitive

Calculates Primitive checksum

Examples:

Sjekksum.primitive(232323) #=> 6

See Also:


126
127
128
# File 'lib/sjekksum.rb', line 126

def primitive_of number
  Primitive.of number
end

#upc_of(number) ⇒ Integer Also known as: upc

Calculates UPC checksum

Examples:

Sjekksum.upc("03600024145") #=> 7

See Also:


94
95
96
# File 'lib/sjekksum.rb', line 94

def upc_of number
  UPC.of number
end

#valid_damm?(number) ⇒ Boolean Also known as: damm?

Damm validation of provided number

Examples:

Sjekksum.damm?(5724) #=> true

See Also:


158
159
160
# File 'lib/sjekksum.rb', line 158

def valid_damm? number
  Damm.valid? number
end

#valid_isbn10?(number) ⇒ Boolean Also known as: isbn10?

ISBN-10 validation of provided number

Examples:

Sjekksum.isbn10?("1477430253") #=> true
Sjekksum.isbn10?("193435600X") #=> true

See Also:


175
176
177
# File 'lib/sjekksum.rb', line 175

def valid_isbn10? number
  ISBN10.valid? number
end

#valid_isbn13?(number) ⇒ Boolean Also known as: isbn13?

ISBN-13 validation of provided number

Examples:

Sjekksum.isbn13?("978-0-306-40615-7") #=> true

See Also:


191
192
193
# File 'lib/sjekksum.rb', line 191

def valid_isbn13? number
  ISBN13.valid? number
end

#valid_luhn?(number) ⇒ Boolean Also known as: luhn?

Luhn validation of provided number

Examples:

Sjekksum.luhn?(79927398713) #=> true

See Also:


207
208
209
# File 'lib/sjekksum.rb', line 207

def valid_luhn? number
  Luhn.valid? number
end

#valid_primitive97?(number) ⇒ Boolean Also known as: primitive97?

Primitive97 validation of provided number

Examples:

Sjekksum.primitive97?(2323235) #=> true

See Also:


271
272
273
# File 'lib/sjekksum.rb', line 271

def valid_primitive97? number
  Primitive97.valid? number
end

#valid_primitive?(number) ⇒ Boolean Also known as: primitive?

Primitive validation of provided number

Examples:

Sjekksum.primitive?(2323236) #=> true

See Also:


255
256
257
# File 'lib/sjekksum.rb', line 255

def valid_primitive? number
  Primitive.valid? number
end

#valid_upc?(number) ⇒ Boolean Also known as: upc?

UPC validation of provided number

Examples:

Sjekksum.upc?("036000241457") #=> true

See Also:


223
224
225
# File 'lib/sjekksum.rb', line 223

def valid_upc? number
  UPC.valid? number
end

#valid_verhoeff?(number) ⇒ Boolean Also known as: verhoeff?

Verhoeff validation of provided number

Examples:

Sjekksum.verhoeff?(1428570) #=> true

See Also:


239
240
241
# File 'lib/sjekksum.rb', line 239

def valid_verhoeff? number
  Verhoeff.valid? number
end

#verhoeff_of(number) ⇒ Integer Also known as: verhoeff

Calculates Verhoeff checksum

Examples:

Sjekksum.verhoeff(142857) #=> 0

See Also:


110
111
112
# File 'lib/sjekksum.rb', line 110

def verhoeff_of number
  Verhoeff.of number
end