ribbon 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ribbon.rb CHANGED
@@ -96,6 +96,8 @@ class Ribbon < BasicObject
96
96
  Wrapper.new ribbon
97
97
  end
98
98
 
99
+ # Unwraps the +ribbon+ if it is wrapped and returns its hash. Returns nil in
100
+ # any other case.
99
101
  def self.extract_hash_from(ribbon)
100
102
  ribbon = ribbon.ribbon if ::Ribbon.wrapped? ribbon
101
103
  ribbon = ribbon.__hash__ if ::Ribbon.instance? ribbon
@@ -16,7 +16,7 @@ class Ribbon < BasicObject
16
16
  # Patch version.
17
17
  #
18
18
  # Increments denote changes in implementation.
19
- PATCH = 1
19
+ PATCH = 2
20
20
 
21
21
  # Build version.
22
22
  #
@@ -32,7 +32,19 @@ class Ribbon < BasicObject
32
32
  end
33
33
 
34
34
  # The wrapped Ribbon object.
35
- attr_accessor :ribbon
35
+ attr :ribbon
36
+
37
+ # Wraps +ribbon+. If it is already wrapped, uses the wrapped ribbon as this
38
+ # wrapper's ribbon. If it is a hash, creates a new Ribbon with its data. If
39
+ # it is something else, an ArgumentError will be raised.
40
+ def ribbon=(ribbon)
41
+ @ribbon = case ribbon
42
+ when Wrapper then ribbon.ribbon
43
+ when Hash then Ribbon.new ribbon
44
+ when Ribbon then ribbon
45
+ else raise ArgumentError, "Can't wrap #{ribbon.class}"
46
+ end
47
+ end
36
48
 
37
49
  # Wraps a Ribbon object, providing many general-purpose methods that were
38
50
  # not defined in the Ribbon itself.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribbon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rookie
16
- requirement: &13625980 !ruby/object:Gem::Requirement
16
+ requirement: &5737360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *13625980
24
+ version_requirements: *5737360
25
25
  description: Ruby Object Notation. Inspired by JSON and OpenStruct.
26
26
  email: matheus.a.m.moreira@gmail.com
27
27
  executables: []