types 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/types.rb +41 -3
  3. data/types.gemspec +2 -2
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/types.rb CHANGED
@@ -3,12 +3,25 @@
3
3
 
4
4
  require "multitype-introspection"
5
5
 
6
+ ##
7
+ # Root library module.
8
+ #
9
+
6
10
  module Types
11
+
12
+ ##
13
+ # Type defining class.
14
+ # @abstract
15
+ #
16
+
7
17
  class Type
8
18
 
9
19
  ##
10
20
  # Returns classes which are part of this type.
11
21
  #
22
+ # @return [Array] array of class objects
23
+ # @abstract
24
+ #
12
25
 
13
26
  def type_classes
14
27
  raise Exception::new("Class is abstract.")
@@ -16,6 +29,7 @@ module Types
16
29
 
17
30
  ##
18
31
  # Returns types which are part of this type.
32
+ # @return [Array] array of types objects
19
33
  #
20
34
 
21
35
  def type_types
@@ -25,6 +39,9 @@ module Types
25
39
  ##
26
40
  # Matches object is of this type.
27
41
  #
42
+ # @param [Object] object object for type matching
43
+ # @return [Boolean] 'true' if match, 'false' in otherwise
44
+ #
28
45
 
29
46
  def match_type?(object)
30
47
  result = object.kind_of_any? self.type_classes
@@ -37,12 +54,19 @@ module Types
37
54
 
38
55
  end
39
56
 
57
+ ##
58
+ # Defines generic boolean type.
59
+ # @abstract
60
+ #
61
+
40
62
  class Boolean < Type
41
63
 
42
64
  ##
43
65
  # Returns classes which are part of this type.
44
66
  # In case of boolean <tt>TrueClass</tt> and <tt>FalseClass</tt>.
45
67
  #
68
+ # @return [Array] array of types objects
69
+ #
46
70
 
47
71
  def type_classes
48
72
  [TrueClass, FalseClass]
@@ -51,11 +75,18 @@ module Types
51
75
  end
52
76
  end
53
77
 
78
+ ##
79
+ # Extension of built-in Object class.
80
+ #
81
+
54
82
  class Object
55
83
 
56
84
  ##
57
85
  # Indicates object is type of some class.
58
- # If class isn't Type, matches against kind_of?.
86
+ # If class isn't Type, matches against #kind_of?.
87
+ #
88
+ # @param [Types::Type, Class] cls some type or class specification
89
+ # @return [Boolean] 'true' if it is, 'false' in otherwise
59
90
  #
60
91
 
61
92
  def type_of?(cls)
@@ -67,10 +98,12 @@ class Object
67
98
  end
68
99
  end
69
100
 
70
-
71
101
  ##
72
102
  # Indicates object is type of some class in the list.
73
- # If class isn't Type, matches against kind_of?.
103
+ # If class isn't Type, matches against #kind_of?.
104
+ #
105
+ # @param [Array] classes array of Type or Class objects
106
+ # @return [Boolean] 'true' if it is, 'false' in otherwise
74
107
  #
75
108
 
76
109
  def type_of_any?(classes)
@@ -88,5 +121,10 @@ class Object
88
121
  end
89
122
  end
90
123
 
124
+ ##
125
+ # Redefines generic boolean type in main namespace.
126
+ # @abstract
127
+ #
128
+
91
129
  class Boolean < Types::Boolean
92
130
  end
data/types.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{types}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Kozák"]
12
- s.date = %q{2011-01-12}
12
+ s.date = %q{2011-01-19}
13
13
  s.email = %q{martinkozak@martinkozak.net}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Martin Koz\xC3\xA1k"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-12 00:00:00 +01:00
17
+ date: 2011-01-19 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="
97
97
  - !ruby/object:Gem::Version
98
- hash: 2336525954248439529
98
+ hash: -4017891773010528090
99
99
  segments:
100
100
  - 0
101
101
  version: "0"