Class: DiverDown::Web::DefinitionEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/diver_down/web/definition_enumerator.rb

Instance Method Summary collapse

Constructor Details

#initialize(store, title: '', source: '', definition_group: '') ⇒ DefinitionEnumerator

Returns a new instance of DefinitionEnumerator.

Parameters:

  • store (DiverDown::Definition::Store)
  • query (String)
  • definition_group (String) (defaults to: '')


11
12
13
14
15
16
# File 'lib/diver_down/web/definition_enumerator.rb', line 11

def initialize(store, title: '', source: '', definition_group: '')
  @store = store
  @title = title
  @source = source
  @definition_group = definition_group
end

Instance Method Details

#each {|parent_bit_id, bit_id, definition| ... } ⇒ Object

Yields:

  • (parent_bit_id, bit_id, definition)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/diver_down/web/definition_enumerator.rb', line 19

def each
  return enum_for(__method__) unless block_given?

  definition_groups = @store.definition_groups
  definition_groups.each do |definition_group|
    definitions = @store.filter_by_definition_group(definition_group)
    definitions.each do
      next unless match_definition?(_1)

      yield(_1)
    end
  end
end

#sizeInteger Also known as: length

Returns:

  • (Integer)


34
35
36
# File 'lib/diver_down/web/definition_enumerator.rb', line 34

def size
  @store.size
end