Class: Codebeacon::Tracer::NodeSource

Inherits:
Object
  • Object
show all
Defined in:
lib/codebeacon/tracer/src/models/node_source.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, root_path) ⇒ NodeSource

Returns a new instance of NodeSource.



13
14
15
16
17
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 13

def initialize(name, root_path)
  @name = name
  @root_path = root_path
  self.class.instances << self
end

Class Attribute Details

.instancesObject

Returns the value of attribute instances.



10
11
12
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 10

def instances
  @instances
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 6

def id
  @id
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 6

def name
  @name
end

#root_pathObject

Returns the value of attribute root_path.



6
7
8
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 6

def root_path
  @root_path
end

Class Method Details

.clearObject



27
28
29
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 27

def self.clear
  self.instances = []
end

.find(path) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/codebeacon/tracer/src/models/node_source.rb', line 19

def self.find(path)
  return nil if path.nil?
  Pathname.new(path).ascend do |dir|
    source = self.instances.find { |ns| dir.to_s == ns.root_path }
    return source if source
  end
end