Class: ConvenientService::Utils::String::Demodulize Private

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/string/demodulize.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Examples:

demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections"
demodulize('Inflections')                           # => "Inflections"
demodulize('::Inflections')                         # => "Inflections"
demodulize('')                                      # => ""

See Also:

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(string) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • string (#to_s)

Since:

  • 1.0.0



31
32
33
# File 'lib/convenient_service/utils/string/demodulize.rb', line 31

def initialize(string)
  @string = string.to_s
end

Instance Attribute Details

#stringObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



25
26
27
# File 'lib/convenient_service/utils/string/demodulize.rb', line 25

def string
  @string
end

Instance Method Details

#callString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

Since:

  • 1.0.0



47
48
49
50
51
# File 'lib/convenient_service/utils/string/demodulize.rb', line 47

def call
  i = string.rindex("::")

  i ? string[(i + 2)..] : string
end