Class: Hx::Listing::Limit

Inherits:
Object
  • Object
show all
Includes:
Filter
Defined in:
lib/hx/listing/limit.rb

Instance Method Summary collapse

Methods included from Filter

#each_entry_path, #get_entry

Methods included from View

#edit_entry

Constructor Details

#initialize(input, options) ⇒ Limit

Returns a new instance of Limit.



32
33
34
35
# File 'lib/hx/listing/limit.rb', line 32

def initialize(input, options)
  @input = input
  @limit = options[:limit]
end

Instance Method Details

#each_entry(selector) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hx/listing/limit.rb', line 37

def each_entry(selector)
  @input.each_entry(selector) do |path, entry|
    if entry['items']
      trimmed_entry = entry.dup
      trimmed_entry['items'] = entry['items'][0...@limit]
    else
      trimmed_entry = entry
    end
    yield path, trimmed_entry
  end
  self
end