Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/kennitala_string.rb

Overview

Monkey patch for the String class

Instance Method Summary collapse

Instance Method Details

#kt?Boolean Also known as: kennitala?

Checks if the String is valid for initializing a Kennitala object

This is useful if you want to deal with conditionals before catching errors.

Returns:

  • (Boolean)

    Boolean



17
18
19
20
21
# File 'lib/kennitala_string.rb', line 17

def kt?
  true if Kennitala.new(self)
rescue ArgumentError, TypeError
  false
end

#to_ktKennitala Also known as: to_kennitala

Converts a String to a Kennitala object

Returns:



8
9
10
# File 'lib/kennitala_string.rb', line 8

def to_kt
  Kennitala.new(self)
end