Class: CodeMetrics::StatsDirectories::StatDirectory

Inherits:
Struct
  • Object
show all
Defined in:
lib/code_metrics/stats_directories.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



5
6
7
# File 'lib/code_metrics/stats_directories.rb', line 5

def description
  @description
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



5
6
7
# File 'lib/code_metrics/stats_directories.rb', line 5

def path
  @path
end

Class Method Details

.from_list(list, path_prefix = '') ⇒ Object



18
19
20
21
22
# File 'lib/code_metrics/stats_directories.rb', line 18

def self.from_list(list, path_prefix='')
  list.map do |description, path|
    new(description, [path_prefix,path].compact.join('/'))
  end.select(&:directory?)
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/code_metrics/stats_directories.rb', line 12

def directory?
  File.directory?(path)
end

#inspectObject



9
10
11
# File 'lib/code_metrics/stats_directories.rb', line 9

def inspect
  to_a.inspect
end

#name(file_pattern) ⇒ Object



15
16
17
# File 'lib/code_metrics/stats_directories.rb', line 15

def name(file_pattern)
  path.sub(/^\.\/(#{file_pattern}\/\w+)\/.*/, '\\1')
end

#to_aObject



6
7
8
# File 'lib/code_metrics/stats_directories.rb', line 6

def to_a
  [description, path]
end