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-1.2.5 lib/code/type.rb
code-ruby-1.2.4 lib/code/type.rb
code-ruby-1.2.3 lib/code/type.rb
code-ruby-1.2.2 lib/code/type.rb
code-ruby-1.2.1 lib/code/type.rb
code-ruby-1.1.3 lib/code/type.rb
code-ruby-1.1.1 lib/code/type.rb
code-ruby-1.1.0 lib/code/type.rb
code-ruby-1.0.0 lib/code/type.rb
code-ruby-0.15.16 lib/code/type.rb
code-ruby-0.15.15 lib/code/type.rb
code-ruby-0.15.14 lib/code/type.rb
code-ruby-0.15.13 lib/code/type.rb
code-ruby-0.15.12 lib/code/type.rb
code-ruby-0.15.11 lib/code/type.rb
code-ruby-0.15.10 lib/code/type.rb
code-ruby-0.15.9 lib/code/type.rb
code-ruby-0.15.8 lib/code/type.rb
code-ruby-0.15.7 lib/code/type.rb
code-ruby-0.15.6 lib/code/type.rb