ruby-nuggets 0.3.1.277 → 0.3.2.280

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to ruby-nuggets version 0.3.1
5
+ This documentation refers to ruby-nuggets version 0.3.2
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -34,8 +34,7 @@ class Numeric
34
34
  # _num_. Otherwise returns _num_.
35
35
  def limit(min, max)
36
36
  min, max = max, min if max < min
37
-
38
- self.min(min).max(max)
37
+ min(min).max(max)
39
38
  end
40
39
 
41
40
  alias_method :between, :limit
@@ -0,0 +1,69 @@
1
+ #--
2
+ ###############################################################################
3
+ # #
4
+ # A component of ruby-nuggets, some extensions to the Ruby programming #
5
+ # language. #
6
+ # #
7
+ # Copyright (C) 2007-2008 Jens Wille #
8
+ # #
9
+ # Authors: #
10
+ # Jens Wille <jens.wille@uni-koeln.de> #
11
+ # #
12
+ # ruby-nuggets is free software; you can redistribute it and/or modify it #
13
+ # under the terms of the GNU General Public License as published by the Free #
14
+ # Software Foundation; either version 3 of the License, or (at your option) #
15
+ # any later version. #
16
+ # #
17
+ # ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
18
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
19
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
20
+ # more details. #
21
+ # #
22
+ # You should have received a copy of the GNU General Public License along #
23
+ # with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
24
+ # #
25
+ ###############################################################################
26
+ #++
27
+
28
+ class Object
29
+
30
+ # call-seq:
31
+ # object.boolean? => true or false
32
+ #
33
+ #
34
+ def boolean?
35
+ is_a?(TrueClass) || is_a?(FalseClass)
36
+ end
37
+
38
+ # call-seq:
39
+ # object.negate => true or false
40
+ #
41
+ #
42
+ def negate
43
+ not self
44
+ end
45
+
46
+ alias_method :false?, :negate
47
+
48
+ # call-seq:
49
+ # object.to_bool => true or false
50
+ #
51
+ #
52
+ def to_bool
53
+ negate.negate
54
+ end
55
+
56
+ alias_method :true?, :to_bool
57
+
58
+ end
59
+
60
+ if $0 == __FILE__
61
+ [0, 1, nil, '', 'abc', true, false, Class, Object.new].each { |o|
62
+ p o
63
+ p o.boolean?
64
+ p o.negate
65
+ p o.to_bool
66
+ p o.true?
67
+ p o.false?
68
+ }
69
+ end
@@ -33,11 +33,8 @@ class Object
33
33
  # Sends _object_ multiple +messages+ and returns an array of the individual
34
34
  # return values.
35
35
  def msend(*messages)
36
- messages_with_args = messages.last.is_a?(Hash) ? messages.pop : {}
37
-
38
- (messages + messages_with_args.keys).map { |msg|
39
- messages_with_args.has_key?(msg) ? send(msg, *messages_with_args[msg]) : send(msg)
40
- }
36
+ hash = messages.last.is_a?(Hash) ? messages.pop : {}
37
+ (messages + hash.to_a).map { |msg| send *msg.is_a?(Array) ? msg : [msg] }
41
38
  end
42
39
 
43
40
  end
@@ -50,6 +47,7 @@ if $0 == __FILE__
50
47
  o = 42
51
48
  p o
52
49
  p o.msend(:to_s, :* => 2)
50
+ p o.msend([:to_s, 2], '-@')
53
51
 
54
52
  o = Time.now
55
53
  p o
@@ -4,7 +4,7 @@ module Nuggets
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 3
7
- TINY = 1
7
+ TINY = 2
8
8
 
9
9
  class << self
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nuggets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.277
4
+ version: 0.3.2.280
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-19 00:00:00 +02:00
12
+ date: 2008-09-02 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -34,6 +34,7 @@ files:
34
34
  - lib/nuggets/object/ghost_class.rb
35
35
  - lib/nuggets/object/eigenclass.rb
36
36
  - lib/nuggets/object/blank.rb
37
+ - lib/nuggets/object/boolean.rb
37
38
  - lib/nuggets/object/msend.rb
38
39
  - lib/nuggets/object/uniclass.rb
39
40
  - lib/nuggets/enumerable/agrep.rb