Class: Kamaze::Project::Tools::Yardoc::File

Inherits:
Object
  • Object
show all
Defined in:
lib/kamaze/project/tools/yardoc/file.rb

Overview

Describe a "file"

as seen from YARD::CLI::Yardoc#files and YARD::CLI::YardocOptions#files, as result a file can be evaluating as a glob expression, else file (filepath) is a fixed string. Thus, file is castable to Array.

Direct Known Subclasses

Watchable::File

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath, glob = false) ⇒ File

Returns a new instance of File.

Parameters:

  • filepath (String)
  • glob (Boolean) (defaults to: false)


22
23
24
25
26
# File 'lib/kamaze/project/tools/yardoc/file.rb', line 22

def initialize(filepath, glob = false)
  # noinspection RubySimplifyBooleanInspection
  @glob = !!glob
  @filepath = filepath.to_s
end

Instance Attribute Details

#filepathObject (readonly, protected)

Returns the value of attribute filepath.



54
55
56
# File 'lib/kamaze/project/tools/yardoc/file.rb', line 54

def filepath
  @filepath
end

Instance Method Details

#glob?Boolean

Denote file MUST be evaluated as a glob expression

Returns:

  • (Boolean)


42
43
44
# File 'lib/kamaze/project/tools/yardoc/file.rb', line 42

def glob?
  @glob
end

#pathsArray<Pathname> Also known as: to_a

Returns:

  • (Array<Pathname>)


29
30
31
32
33
34
35
36
37
# File 'lib/kamaze/project/tools/yardoc/file.rb', line 29

def paths
  proc do
    if glob?
      Dir.glob(filepath).map { |f| Pathname.new(f).dirname }
    else
      [Pathname.new(filepath).dirname]
    end
  end.call.uniq.sort.map { |f| Pathname.new(f.to_s.gsub('./', '')) }
end

#to_sObject



46
47
48
# File 'lib/kamaze/project/tools/yardoc/file.rb', line 46

def to_s
  filepath
end