Sha256: 835bf1abe80c3c23c86f2befdef1b08f9f9f06aa91a8ad10862503b169a85872

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

require 'range_dsl'

module RangeDsl
  module ContainerExp
    class Base
      include ConnectionExp::Client

      attr_accessor :values
      def initialize(*args)
        @values = (args.length == 1 && args.first.is_a?(Array)) ? args.first : args
      end

      def inspect
        args = @values.inspect.gsub(/^\[|\]$/, '')
        "#{name_for_inspect}(#{args})"
      end
    end

    class Any < Base
      def name_for_inspect; "any"; end
      def include?(v)
        @values.any?{|value| RangeDsl.include?(value, v) }
      end
    end

    class All < Base
      def name_for_inspect; "all"; end
      def include?(v)
        @values.all?{|value| RangeDsl.include?(value, v) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
range_dsl-0.1.2 lib/range_dsl/container_exp.rb
range_dsl-0.1.1 lib/range_dsl/container_exp.rb
range_dsl-0.1.0 lib/range_dsl/container_exp.rb