Class: Hx::Listing::FlatIndex
- Inherits:
-
Object
- Object
- Hx::Listing::FlatIndex
- Includes:
- Filter
- Defined in:
- lib/hx/listing/flatindex.rb
Class Method Summary collapse
Instance Method Summary collapse
- #each_entry_path(selector) {|@index_name| ... } ⇒ Object
- #get_entry(path) ⇒ Object
-
#initialize(input, options) ⇒ FlatIndex
constructor
A new instance of FlatIndex.
Methods included from Filter
Methods included from View
Constructor Details
#initialize(input, options) ⇒ FlatIndex
Returns a new instance of FlatIndex.
39 40 41 42 |
# File 'lib/hx/listing/flatindex.rb', line 39 def initialize(input, ) @input = input @index_name = [:index_name] || "index" end |
Class Method Details
.new(input, options) ⇒ Object
34 35 36 37 |
# File 'lib/hx/listing/flatindex.rb', line 34 def self.new(input, ) listing = super(input, ) Listing.(listing, ) end |
Instance Method Details
#each_entry_path(selector) {|@index_name| ... } ⇒ Object
44 45 46 47 |
# File 'lib/hx/listing/flatindex.rb', line 44 def each_entry_path(selector) yield @index_name if selector.accept_path? @index_name self end |
#get_entry(path) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hx/listing/flatindex.rb', line 49 def get_entry(path) raise NoSuchEntryError, path unless path == @index_name index = {'items' => []} @input.each_entry(Path::ALL) do |path, entry| index['items'] << {'path' => path, 'entry' => entry} updated = [entry['updated'], index['updated']].compact.max index['updated'] = updated if updated end index end |