Sha256: 335675db9b05232382b98a06b1a593a98b531afdcc2e83f7ca069e2f32cbb912
Contents?: true
Size: 1.44 KB
Versions: 12
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module ConvenientService module Utils module String ## # @example # demodulize('ActiveSupport::Inflector::Inflections') # => "Inflections" # demodulize('Inflections') # => "Inflections" # demodulize('::Inflections') # => "Inflections" # demodulize('') # => "" # # @see https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-demodulize # class Demodulize < Support::Command ## # @!attribute [r] string # @return [String] # attr_reader :string ## # @param string [#to_s] # @return [void] # def initialize(string) @string = string.to_s end ## # @return [String] # # @internal # NOTE: Copied with cosmetic modifications from: # - https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-demodulize # # NOTE: Modifications. # - `string` is `path.to_s` is the original implementation. # - Fixed Rubocop complaint about `Style/SlicingWithRange`. # - Fixed Rubocop complaint about `Lint/AssignmentInCondition`. # def call i = string.rindex("::") i ? string[(i + 2)..] : string end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems