Class: Hashira::Coupling::Naming

Inherits:
Object
  • Object
show all
Defined in:
lib/hashira/coupling/naming.rb

Instance Method Summary collapse

Constructor Details

#initialize(definitions) ⇒ Naming

Returns a new instance of Naming.



4
5
6
# File 'lib/hashira/coupling/naming.rb', line 4

def initialize(definitions)
  @definitions = definitions
end

Instance Method Details

#segmentsObject



8
# File 'lib/hashira/coupling/naming.rb', line 8

def segments = @_segments ||= Hashira::Coupling::NamespacePrefix.infer(@definitions)

#strip(path) ⇒ Object



10
11
12
13
# File 'lib/hashira/coupling/naming.rb', line 10

def strip(path)
  return [] if segments.first(path.length) == path
  path.drop(segments.length.downto(0).find { path.first(it) == segments.last(it) })
end