typed-array 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +37 -14
- data/VERSION +1 -1
- data/lib/typed-array.rb +1 -40
- data/typed-array.gemspec +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,19 +1,42 @@
|
|
1
1
|
= typed-array
|
2
2
|
|
3
|
-
|
3
|
+
Gem provides enforced-type functionality to Arrays
|
4
4
|
|
5
|
-
|
5
|
+
Copyright (c) 2011 Ryan Biesemeyer
|
6
|
+
See LICENSE.txt for details
|
7
|
+
|
8
|
+
Ryan Biesemeyer mailto:ruby-dev@yaauie.com
|
9
|
+
|
10
|
+
== Example
|
11
|
+
|
12
|
+
=== Create Standard Class
|
13
|
+
|
14
|
+
require 'typed-array'
|
15
|
+
class Things < Array
|
16
|
+
extend TypedArray
|
17
|
+
restrict_types Thing1,Thing2
|
18
|
+
end
|
19
|
+
|
20
|
+
=== Generate Class using Factory
|
21
|
+
|
22
|
+
require 'typed-array'
|
23
|
+
things = TypedArray(Thing1,Thing2)
|
24
|
+
|
25
|
+
=== Adding items to the Array
|
26
|
+
|
27
|
+
# All standard Array interfaces are implemented, including block-processing
|
28
|
+
# and variable-number of arguments. For methods that would usually return an
|
29
|
+
# Array, they instead return an instance of the current class (except to_a).
|
30
|
+
#
|
31
|
+
# The difference is that if the method would generate an Array including the
|
32
|
+
# wrong types, TypedArray::UnexpectedTypeException is raised and the call is
|
33
|
+
# aborted before modifying the enforced TypedArray instance.
|
6
34
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2011 Ryan Biesemeyer. See LICENSE.txt for
|
18
|
-
further details.
|
35
|
+
require 'typed-array'
|
36
|
+
symbols = TypedArray(Symbol).new([:foo,:bar,:baz,:bingo])
|
37
|
+
begin
|
38
|
+
integers = TypedArray(Integer).new([1,3,7,2,:symbol])
|
39
|
+
rescue TypedArray::UnexpectedTypeException
|
40
|
+
puts "An error occured: #{$!}"
|
41
|
+
end
|
19
42
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/typed-array.rb
CHANGED
@@ -1,43 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (c) 2011 Ryan Biesemeyer
|
4
|
-
# See LICENSE.txt for details
|
5
|
-
#
|
6
|
-
# Ryan Biesemeyer mailto:ruby-dev@yaauie.com
|
7
|
-
#
|
8
|
-
# == Example
|
9
|
-
#
|
10
|
-
# === Create Standard Class
|
11
|
-
#
|
12
|
-
# require 'typed-array'
|
13
|
-
# class Things < Array
|
14
|
-
# extend TypedArray
|
15
|
-
# restrict_types Thing1,Thing2
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# === Generate Class using Factory
|
19
|
-
#
|
20
|
-
# require 'typed-array'
|
21
|
-
# things = TypedArray(Thing1,Thing2)
|
22
|
-
#
|
23
|
-
# === Adding items to the Array
|
24
|
-
#
|
25
|
-
# # All standard Array interfaces are implemented, including block-processing
|
26
|
-
# # and variable-number of arguments. For methods that would usually return an
|
27
|
-
# # Array, they instead return an instance of the current class (except to_a).
|
28
|
-
# #
|
29
|
-
# # The difference is that if the method would generate an Array including the
|
30
|
-
# # wrong types, TypedArray::UnexpectedTypeException is raised and the call is
|
31
|
-
# # aborted before modifying the enforced TypedArray instance.
|
32
|
-
#
|
33
|
-
# require 'typed-array'
|
34
|
-
# symbols = TypedArray(Symbol).new([:foo,:bar,:baz,:bingo])
|
35
|
-
# begin
|
36
|
-
# integers = TypedArray(Integer).new([1,3,7,2,:symbol])
|
37
|
-
# rescue TypedArray::UnexpectedTypeException
|
38
|
-
# puts "An error occured: #{$!}"
|
39
|
-
# end
|
40
|
-
#
|
1
|
+
# :include: ../README.rdoc
|
41
2
|
|
42
3
|
require "typed-array/functions"
|
43
4
|
|
data/typed-array.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: typed-array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Biesemeyer
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
96
|
+
hash: 2753660141613797258
|
97
97
|
segments:
|
98
98
|
- 0
|
99
99
|
version: "0"
|