Sha256: f5753871ffb25537267e50592482c6910d7808154e27f3e2c8f92875bf0df29e

Contents?: true

Size: 856 Bytes

Versions: 1

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module Shiyo
  # The class to create a composite specification for checking
  # whether the candidate satisfies both of the two specifications.
  class And
    include Shiyo::Specification
    # A new instance of Shiyo::And
    #
    # @param one [Shiyo::Specification] A specification object.
    # @param other [Shiyo::Specification] The other specification object.
    def initialize(one, other)
      super()
      @one = Shiyo::Specification(one)
      @other = Shiyo::Specification(other)
    end

    # Inspects whether the candidate satisfies the both of the wrapped specifications.
    #
    # @param candidate [Object] The candidate object to be inspected.
    # @return [Boolean] The result.
    def satisfied_by?(candidate)
      @one.satisfied_by?(candidate) && @other.satisfied_by?(candidate)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shiyo-0.1.0 lib/shiyo/and.rb