Sha256: 3d565d322957a8ec8a1623ca77bbd8b886bcf1ae227939f4b1dde883e49985f5

Contents?: true

Size: 536 Bytes

Versions: 15

Compression:

Stored size: 536 Bytes

Contents

# frozen_string_literal: true
class Module
  # Returns the class name of a full module namespace path
  #
  # @example
  #   module A::B::C; class_name end # => "C"
  # @return [String] the last part of a module path
  def class_name
    name.split("::").last
  end

  # Returns the module namespace path minus the class/module name
  #
  # @example
  #   module A::B::C; namespace_name end # => "A::B"
  # @return [String] the namespace minus the class/module name
  def namespace_name
    name.split("::")[0..-2].join("::")
  end
end

Version data entries

15 entries across 14 versions & 4 rubygems

Version Path
yard-0.9.16 lib/yard/core_ext/module.rb
yard-0.9.15 lib/yard/core_ext/module.rb
yard-0.9.14 lib/yard/core_ext/module.rb
yard-0.9.13 lib/yard/core_ext/module.rb
yard-0.9.12 lib/yard/core_ext/module.rb
yard-0.9.11 lib/yard/core_ext/module.rb
yard-0.9.10 lib/yard/core_ext/module.rb
yard-0.9.9 lib/yard/core_ext/module.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/lib/yard/core_ext/module.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/lib/yard/core_ext/module.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/lib/yard/core_ext/module.rb
yard-0.9.8 lib/yard/core_ext/module.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/lib/yard/core_ext/module.rb
yard-0.9.7 lib/yard/core_ext/module.rb
yard-0.9.6 lib/yard/core_ext/module.rb