Class: Kangaru::Inflectors::Inflector

Inherits:
Object
  • Object
show all
Extended by:
InflectorMacros
Defined in:
lib/kangaru/inflectors/inflector.rb

Constant Summary collapse

DEFAULT_GROUP_JOINER =
"/".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InflectorMacros

filter_input_with, inherited, join_groups_with, join_tokens_with, post_process_with, transform_tokens_with

Constructor Details

#initialize(string) ⇒ Inflector

Returns a new instance of Inflector.



10
11
12
# File 'lib/kangaru/inflectors/inflector.rb', line 10

def initialize(string)
  @string = filter_input(string)
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



8
9
10
# File 'lib/kangaru/inflectors/inflector.rb', line 8

def string
  @string
end

Class Method Details

.inflect(string) ⇒ Object



22
23
24
# File 'lib/kangaru/inflectors/inflector.rb', line 22

def self.inflect(string)
  new(string).inflect
end

Instance Method Details

#inflectObject



14
15
16
17
18
19
20
# File 'lib/kangaru/inflectors/inflector.rb', line 14

def inflect
  post_process(
    join_groups(
      transform_and_join_tokens(tokeniser.split)
    )
  )
end