Sha256: 72e7b229b112aaf1d92fe31f2efc13f60e95c86c088e44b65187cd80c61a567b

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

# encoding: utf-8

module Selector

  # The condition checks if a value is included to the array
  #
  class Array < Collection

    # @private
    def initialize(array)
      super Set.new(array)
    end

    # Creates an AND composition
    #
    # If other value is a array, then creates modified array to avoid nesting
    #
    # @param (see Selector::Composition#&)
    #
    # @return (see Selector::Composition#&)
    #
    def &(other)
      return super unless other.instance_of? self.class
      self.class.new attribute & other.attribute
    end

    # Creates an OR composition
    #
    # If other value is a array, then creates modified array to avoid nesting
    #
    # @param (see Selector::Composition#|)
    #
    # @return (see Selector::Composition#|)
    #
    def |(other)
      return super unless other.instance_of? self.class
      self.class.new attribute | other.attribute
    end

  end # class Array

end # module Selector

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selector-0.0.3 lib/selector/array.rb
selector-0.0.2 lib/selector/array.rb
selector-0.0.1 lib/selector/array.rb