Class: MasterView::MIO::StringHashMIOTree
- Inherits:
-
Object
- Object
- MasterView::MIO::StringHashMIOTree
- Includes:
- MasterViewIOTreeMixin
- Defined in:
- lib/masterview/io.rb
Overview
MIO implemented as simple hash of path to string content This MIOTree does not keep track of mtimes and thus will always return new mtimes
Direct Known Subclasses
Constant Summary
Constants included from MasterViewIOTreeMixin
MasterViewIOTreeMixin::DefaultExtensionInstances
Instance Attribute Summary collapse
-
#string_hash ⇒ Object
Returns the value of attribute string_hash.
Instance Method Summary collapse
- #find(options = {}) ⇒ Object
-
#initialize(string_hash = {}, default_extension = nil, options = {}, &block) ⇒ StringHashMIOTree
constructor
A new instance of StringHashMIOTree.
- #path(path) ⇒ Object
Methods included from MasterViewIOTreeMixin
#apply_filters, #cleanup_path_get_relative_pathname, #default_extension, #default_extension=, #default_mio_filter_block
Constructor Details
#initialize(string_hash = {}, default_extension = nil, options = {}, &block) ⇒ StringHashMIOTree
Returns a new instance of StringHashMIOTree.
136 137 138 139 140 141 |
# File 'lib/masterview/io.rb', line 136 def initialize(string_hash = {}, default_extension=nil, ={}, &block) @string_hash = string_hash @options = self.default_extension = default_extension @new_mio_block = block end |
Instance Attribute Details
#string_hash ⇒ Object
Returns the value of attribute string_hash.
135 136 137 |
# File 'lib/masterview/io.rb', line 135 def string_hash @string_hash end |
Instance Method Details
#find(options = {}) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/masterview/io.rb', line 154 def find( = {}) path = [:path] || '' path = '' if path == '.' found = [] @string_hash.each { |p,v| found << p if p.starts_with?(path) } found = found.select { |p| Pathname.for_path(p).basename.fnmatch?([:pattern]) } if [:pattern] found.sort! found = found.collect{ |p| self.path(p) } # create mio objects found.each { |mio| yield mio } if block_given? found end |