Class: HumanID::Transliteration::Behaviour

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/humanid/transliteration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBehaviour

Returns a new instance of Behaviour.



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/humanid/transliteration.rb', line 71

def initialize
  self.separator = '-'
  self.downcase  = true
  self.normalize = true

  # Not starts with hyphen
  # Contains 1 to 255 word characters and hyphens
  # Not ends with hyphen
  # TODO Validation with custom separator
  self.validation_regex = /(?!-)\A[\w-]{1,255}(?<!-)\z/
end

Instance Attribute Details

#downcaseObject

Returns the value of attribute downcase.



69
70
71
# File 'lib/humanid/transliteration.rb', line 69

def downcase
  @downcase
end

#normalizeObject

Returns the value of attribute normalize.



69
70
71
# File 'lib/humanid/transliteration.rb', line 69

def normalize
  @normalize
end

#separatorObject

Returns the value of attribute separator.



69
70
71
# File 'lib/humanid/transliteration.rb', line 69

def separator
  @separator
end

#validation_regexObject

Returns the value of attribute validation_regex.



69
70
71
# File 'lib/humanid/transliteration.rb', line 69

def validation_regex
  @validation_regex
end

Instance Method Details

#perform_downcase?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/humanid/transliteration.rb', line 83

def perform_downcase?
  downcase
end

#perform_normalization?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/humanid/transliteration.rb', line 87

def perform_normalization?
  normalize
end