Sha256: 8fd43afba11cb08dbfa9b786f2fe6ef8f1605f21238ac2c2aef8cac625c379a7

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 Bytes

Contents

module Druid
  class SectionCollection
    include Enumerable

    def initialize sections
      @sections = sections
    end

    def each &block
      @sections.each &block
    end

    def [] index
      @sections[index]
    end

    def find_by values_hash
      @sections.find { |section|
        values_hash.all? { |key, value| value === section.public_send(key) }
      }
    end

    def select_by values_hash
      SectionCollection.new @sections.select { |section|
        values_hash.all? { |key, value| value === section.public_send(key) }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
druid-ts-1.2.0 lib/druid/sections.rb