Module: Hx::Filter

Overview

minimal complete definition: each_entry_path + get_entry, or each_entry

Instance Method Summary collapse

Instance Method Details

#each_entry(selector) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/hx.rb', line 52

def each_entry(selector)
  each_entry_path(selector) do |path|
    begin
      entry = get_entry(path)
    rescue NoSuchEntryError
      next # entries may come and go during the enumeration
    end
    yield path, entry
  end
end

#each_entry_path(selector) ⇒ Object



48
49
50
# File 'lib/hx.rb', line 48

def each_entry_path(selector)
  each_entry(selector) { |path, entry| yield path }
end

#edit_entry(path, prototype = nil) ⇒ Object



44
45
46
# File 'lib/hx.rb', line 44

def edit_entry(path, prototype=nil)
  raise EditingNotSupportedError, "Editing not supported for #{path}"
end

#get_entry(path) ⇒ Object

Raises:



63
64
65
66
67
68
# File 'lib/hx.rb', line 63

def get_entry(path)
  each_entry(Path.literal(path)) do |entry_path, entry|
    return entry
  end
  raise NoSuchEntryError, path
end