Class: Raz::DirEntry
- Inherits:
-
Object
- Object
- Raz::DirEntry
- Defined in:
- lib/raz/entries.rb
Instance Attribute Summary collapse
- #absolute_path ⇒ String readonly
- #entries ⇒ Hash<String, FileEntry | DirEntry>
- #ignored_entries ⇒ Hash<String, FileEntry | DirEntry>
- #name ⇒ String readonly
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #dir_entries ⇒ Hash<String, FileEntry | DirEntry>
- #file_entries ⇒ Hash<String, FileEntry | DirEntry>
-
#initialize(name, absolute_path) ⇒ DirEntry
constructor
A new instance of DirEntry.
- #recursive_entries ⇒ Array<FileEntry | DirEntry>
- #recursive_ignored_empty? ⇒ Bool
Constructor Details
#initialize(name, absolute_path) ⇒ DirEntry
Returns a new instance of DirEntry.
68 69 70 71 72 73 |
# File 'lib/raz/entries.rb', line 68 def initialize(name, absolute_path) @name = name @absolute_path = absolute_path @entries = {} @ignored_entries = {} end |
Instance Attribute Details
#absolute_path ⇒ String (readonly)
64 65 66 |
# File 'lib/raz/entries.rb', line 64 def absolute_path @absolute_path end |
#entries ⇒ Hash<String, FileEntry | DirEntry>
52 53 54 |
# File 'lib/raz/entries.rb', line 52 def entries @entries end |
#ignored_entries ⇒ Hash<String, FileEntry | DirEntry>
56 57 58 |
# File 'lib/raz/entries.rb', line 56 def ignored_entries @ignored_entries end |
#name ⇒ String (readonly)
60 61 62 |
# File 'lib/raz/entries.rb', line 60 def name @name end |
Instance Method Details
#==(other) ⇒ Object
83 84 85 |
# File 'lib/raz/entries.rb', line 83 def ==(other) name == other.name && entries == other.entries end |
#[](key) ⇒ Object
75 76 77 |
# File 'lib/raz/entries.rb', line 75 def [](key) @entries[key] end |
#[]=(key, value) ⇒ Object
79 80 81 |
# File 'lib/raz/entries.rb', line 79 def []=(key, value) @entries[key] = value end |
#dir_entries ⇒ Hash<String, FileEntry | DirEntry>
99 100 101 |
# File 'lib/raz/entries.rb', line 99 def dir_entries entries.select { |_k, v| v.is_a?(DirEntry) } end |
#file_entries ⇒ Hash<String, FileEntry | DirEntry>
105 106 107 |
# File 'lib/raz/entries.rb', line 105 def file_entries entries.select { |_k, v| v.is_a?(FileEntry) } end |
#recursive_entries ⇒ Array<FileEntry | DirEntry>
111 112 113 114 115 116 117 118 |
# File 'lib/raz/entries.rb', line 111 def recursive_entries all_entries = [] all_entries += entries.values all_entries += dir_entries.values.flat_map(&:recursive_entries) all_entries end |
#recursive_ignored_empty? ⇒ Bool
89 90 91 92 93 94 95 |
# File 'lib/raz/entries.rb', line 89 def recursive_ignored_empty? return false unless ignored_entries.empty? dir_entries.all? do |key, entry| entry.recursive_ignored_empty? end end |