Module: Alf::Types
- Defined in:
- lib/alf-types/alf/types.rb,
lib/alf-types/alf/types/keys.rb,
lib/alf-types/alf/types/size.rb,
lib/alf-types/alf/types/boolean.rb,
lib/alf-types/alf/types/heading.rb,
lib/alf-types/alf/types/ordering.rb,
lib/alf-types/alf/types/renaming.rb,
lib/alf-types/alf/types/attr_list.rb,
lib/alf-types/alf/types/attr_name.rb,
lib/alf-types/alf/types/type_check.rb,
lib/alf-types/alf/types/summarization.rb,
lib/alf-types/alf/types/tuple_expression.rb,
lib/alf-types/alf/types/tuple_computation.rb
Overview
This module defines a namespace for useful datatypes as well as a few typing tools. Defined types are automatically defined as constants on the Alf module itself.
Defined Under Namespace
Classes: AttrList, AttrName, Heading, Keys, Ordering, Renaming, Size, Summarization, TupleComputation, TupleExpression, TypeCheck
Constant Summary collapse
- Boolean =
Defines the Boolean type which is missing to ruby.
Myrrha::Boolean
Class Method Summary collapse
-
.common_super_type(c1, c2) ⇒ Class
Returns the (least) common super type of c1 and c2.
Class Method Details
.common_super_type(c1, c2) ⇒ Class
Returns the (least) common super type of c1 and c2.
The least common super type is defined as the lowest ancestor shared between c1 and c2.
Examples:
Types.common_super_type(String, String) # => String
Types.common_super_type(Integer, Float) # => Numeric
Types.common_super_type(Integer, String) # => Object
22 23 24 25 26 27 28 29 |
# File 'lib/alf-types/alf/types.rb', line 22 def common_super_type(c1, c2) if x = (c1 <=> c2) x >= 0 ? c1 : c2 else ancestors = [c1, c2].map{|c| c.ancestors.select{|a| a.is_a?(Class)} } (ancestors[0] & ancestors[1]).first end end |