Class: JsDuck::ClassName

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/class_name.rb

Overview

Common routines for manipulating class names.

Class Method Summary collapse

Class Method Details

.short(name) ⇒ Object

Given a full class name extracts the “class”-part of the name.

ClassName.short("My.package.Foo") --> "Foo"

Because we try to emulate ext-doc, it’s not as simple as just taking the last part. See class_spec.rb for details.



12
13
14
15
16
17
18
19
# File 'lib/jsduck/class_name.rb', line 12

def self.short(name)
  parts = name.split(/\./)
  short = parts.pop
  while parts.length > 1 && parts.last =~ /^[A-Z]/
    short = parts.pop + "." + short
  end
  short
end