Module: Algebrick

Extended by:
Matching
Includes:
Matching, Types
Defined in:
lib/algebrick.rb,
lib/algebrick/dsl.rb,
lib/algebrick/atom.rb,
lib/algebrick/type.rb,
lib/algebrick/types.rb,
lib/algebrick/value.rb,
lib/algebrick/reclude.rb,
lib/algebrick/matchers.rb,
lib/algebrick/matching.rb,
lib/algebrick/serializer.rb,
lib/algebrick/type_check.rb,
lib/algebrick/matchers/or.rb,
lib/algebrick/serializers.rb,
lib/algebrick/matchers/and.rb,
lib/algebrick/matchers/any.rb,
lib/algebrick/matchers/not.rb,
lib/algebrick/matchers/atom.rb,
lib/algebrick/matchers/many.rb,
lib/algebrick/matchers/array.rb,
lib/algebrick/product_variant.rb,
lib/algebrick/matchers/product.rb,
lib/algebrick/matchers/variant.rb,
lib/algebrick/matchers/wrapper.rb,
lib/algebrick/matchers/abstract.rb,
lib/algebrick/parametrized_type.rb,
lib/algebrick/matcher_delegations.rb,
lib/algebrick/field_method_readers.rb,
lib/algebrick/product_constructors.rb,
lib/algebrick/matchers/abstract_logic.rb,
lib/algebrick/product_constructors/basic.rb,
lib/algebrick/product_constructors/named.rb,
lib/algebrick/product_constructors/abstract.rb

Overview

Copyright 2013 Petr Chalupa <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Defined Under Namespace

Modules: DSL, FieldMethodReaders, MatcherDelegations, Matchers, Matching, ProductConstructors, Reclude, Serializers, TypeCheck, Types, Value Classes: Atom, ParametrizedType, ProductVariant, Serializer, Type

Constant Summary

Constants included from Types

Types::Boolean

Class Method Summary collapse

Methods included from Matching

any, match, match?, on

Class Method Details

.atomObject



96
97
98
# File 'lib/algebrick/dsl.rb', line 96

def self.atom
  Atom.new nil
end

.type(*variables, &block) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/algebrick/dsl.rb', line 83

def self.type(*variables, &block)
  if block.nil?
    raise 'Atom cannot be parametrized' unless variables.empty?
    atom
  else
    if variables.empty?
      DSL::TypeDefinitionScope.new(ProductVariant.new(nil), &block).new_type
    else
      DSL::TypeDefinitionScope.new(ParametrizedType.new(variables), &block).new_type
    end
  end
end

.types(&block) ⇒ Object



100
101
102
# File 'lib/algebrick/dsl.rb', line 100

def self.types(&block)
  DSL::OuterShell.new &block
end

.versionObject



46
47
48
# File 'lib/algebrick.rb', line 46

def self.version
  @version ||= Gem::Version.new File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
end