Class: Kangaru::Inflectors::Tokeniser

Inherits:
Object
  • Object
show all
Defined in:
lib/kangaru/inflectors/tokeniser.rb

Constant Summary collapse

GROUP_DELIMITER =
%r{/|::}
TOKEN_DELIMITER =
/[_-]+|(?=[A-Z][a-z])/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Tokeniser

Returns a new instance of Tokeniser.



9
10
11
# File 'lib/kangaru/inflectors/tokeniser.rb', line 9

def initialize(string)
  @string = string
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



7
8
9
# File 'lib/kangaru/inflectors/tokeniser.rb', line 7

def string
  @string
end

Instance Method Details

#splitObject



13
14
15
16
17
# File 'lib/kangaru/inflectors/tokeniser.rb', line 13

def split
  string.split(GROUP_DELIMITER).map do |group|
    group.split(TOKEN_DELIMITER)
  end
end