diff options
Diffstat (limited to 'lib/raindrops/struct.rb')
-rw-r--r-- | lib/raindrops/struct.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/raindrops/struct.rb b/lib/raindrops/struct.rb index ca5404d..e81a78e 100644 --- a/lib/raindrops/struct.rb +++ b/lib/raindrops/struct.rb @@ -1,7 +1,22 @@ # -*- encoding: binary -*- +# This is a wrapper around Raindrops objects much like the core Ruby +# \Struct can be seen as a wrapper around the core \Array class. +# It's usage is similar to the core \Struct class, except its fields +# may only be used to house unsigned long integers. +# +# class Foo < Raindrops::Struct.new(:readers, :writers) +# end +# +# foo = Foo.new 0, 0 +# +# foo.incr_writers -> 1 +# foo.incr_readers -> 1 +# class Raindrops::Struct + # returns a new class derived from Raindrops::Struct and supporting + # the given +members+ as fields, just like \Struct.new in core Ruby. def self.new(*members) members = members.map { |x| x.to_sym }.freeze str = <<EOS |