Sha256: 19dfbd33bffa6005575e26e04e924ed09d476c0f79b493683dfa446ffed30557

Contents?: true

Size: 611 Bytes

Versions: 37

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

class Code
  class Type
    def maybe
      Maybe.new(self)
    end

    def repeat(minimum = 0, maximum = nil)
      Repeat.new(self, minimum:, maximum:)
    end

    def |(other)
      Or.new(self, other)
    end

    def valid?(_argument)
      false
    end

    def valid_for?(expected:, actual:)
      expected.is_a?(Type) ? expected.valid?(actual) : actual.is_a?(expected)
    end

    def min_arguments_of(clazz)
      clazz.is_a?(Type) ? clazz.min_arguments : 1
    end

    def max_arguments_of(clazz)
      clazz.is_a?(Type) ? clazz.max_arguments : 1
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
code-ruby-0.15.5 lib/code/type.rb
code-ruby-0.15.4 lib/code/type.rb
code-ruby-0.15.3 lib/code/type.rb
code-ruby-0.15.2 lib/code/type.rb
code-ruby-0.15.0 lib/code/type.rb
code-ruby-0.14.9 lib/code/type.rb
code-ruby-0.14.8 lib/code/type.rb
code-ruby-0.14.6 lib/code/type.rb
code-ruby-0.14.5 lib/code/type.rb
code-ruby-0.14.4 lib/code/type.rb
code-ruby-0.14.3 lib/code/type.rb
code-ruby-0.14.2 lib/code/type.rb
code-ruby-0.14.1 lib/code/type.rb
code-ruby-0.14.0 lib/code/type.rb
code-ruby-0.13.1 lib/code/type.rb
code-ruby-0.13.0 lib/code/type.rb
code-ruby-0.12.0 lib/code/type.rb