Class: Verilog::Path
- Inherits:
-
Object
- Object
- Verilog::Path
- Defined in:
- lib/verilog/path.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
- #find_by_module(name) ⇒ Object
- #includes_file(name) ⇒ Object
-
#initialize(path = "") ⇒ Path
constructor
A new instance of Path.
- #instantiates_module(name) ⇒ Object
- #load_file(file) ⇒ Object
- #load_path(paths) ⇒ Object
- #read_all ⇒ Object
Constructor Details
#initialize(path = "") ⇒ Path
Returns a new instance of Path.
6 7 8 9 |
# File 'lib/verilog/path.rb', line 6 def initialize( path="" ) @files = [] load_path( path ) end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
4 5 6 |
# File 'lib/verilog/path.rb', line 4 def files @files end |
Instance Method Details
#find_by_module(name) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/verilog/path.rb', line 38 def find_by_module( name ) result = @files.select do |file| file.module_name == name end return result[0] end |
#includes_file(name) ⇒ Object
46 47 48 |
# File 'lib/verilog/path.rb', line 46 def includes_file( name ) @files.select { |file| file.includes.include?( name ) } end |
#instantiates_module(name) ⇒ Object
50 51 52 |
# File 'lib/verilog/path.rb', line 50 def instantiates_module( name ) @files.select { |file| file.instantiations.include?( name ) } end |
#load_file(file) ⇒ Object
28 29 30 |
# File 'lib/verilog/path.rb', line 28 def load_file file @files << Verilog::File.new( file ) end |
#load_path(paths) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/verilog/path.rb', line 11 def load_path( paths ) #path is single string or array of strings # Splat '*' to turn into array paths = *paths paths.each do |path| files = Dir.glob( ::File.join( path, '*.*') ) files.each do |file| #Skip if Directory got passed *.* Filter next if ::File.directory?( file ) file_name = ::File.basename(file) @files << Verilog::File.new(file_name, {:path => path}) end end end |
#read_all ⇒ Object
32 33 34 35 36 |
# File 'lib/verilog/path.rb', line 32 def read_all @files.each do |file| file.read_from_disk end end |