Class: RubyDetective::SourceRepresentation::Entities::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_detective/source_representation/entities/base.rb

Direct Known Subclasses

Constant, Klass

Constant Summary collapse

ROOT_SIGN_SYMBOL =
:"::"

Instance Method Summary collapse

Instance Method Details

#absolute_path?Boolean



7
8
9
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 7

def absolute_path?
  namespace.first == ROOT_SIGN_SYMBOL
end

#namespace_as_textObject



36
37
38
39
40
41
42
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 36

def namespace_as_text
  if absolute_path?
    "::" + namespace_without_root_sign.join("::")
  else
    namespace.join("::")
  end
end

#namespace_without_root_signObject

Removes the :“::” symbol from the namespace



20
21
22
23
24
25
26
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 20

def namespace_without_root_sign
  if absolute_path?
    namespace[1..-1]
  else
    namespace
  end
end

#pathObject



11
12
13
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 11

def path
  namespace + [name]
end

#path_as_textObject



28
29
30
31
32
33
34
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 28

def path_as_text
  if absolute_path?
    "::" + path_without_root_sign.join("::")
  else
    path.join("::")
  end
end

#path_without_root_signObject



15
16
17
# File 'lib/ruby_detective/source_representation/entities/base.rb', line 15

def path_without_root_sign
  namespace_without_root_sign + [name]
end