id3 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,105 @@
1
+ # ==============================================================================
2
+ # EXTENDING CLASS HASH
3
+ # ==============================================================================
4
+ #
5
+ # (C) Copyright 2004 by Tilo Sloboda <tools@unixgods.org>
6
+ #
7
+ # updated: Time-stamp: <Sat 18-Dec-2004 12:44:13 Tilo Sloboda>
8
+ #
9
+ # License:
10
+ # Freely available under the terms of the OpenSource "Artistic License"
11
+ # in combination with the Addendum A (below)
12
+ #
13
+ # In case you did not get a copy of the license along with the software,
14
+ # it is also available at: http://www.unixgods.org/~tilo/artistic-license.html
15
+ #
16
+ # Addendum A:
17
+ # THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU!
18
+ # SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
19
+ # REPAIR OR CORRECTION.
20
+ #
21
+ # IN NO EVENT WILL THE COPYRIGHT HOLDERS BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
22
+ # SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY
23
+ # TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
24
+ # INACCURATE OR USELESS OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
25
+ # TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF THE COPYRIGHT HOLDERS OR OTHER PARTY HAS BEEN
26
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
27
+
28
+ # ==============================================================================
29
+ #
30
+ # Homepage: http://www.unixgods.org/~tilo/Ruby/invert_hash.html
31
+ #
32
+ #
33
+ # Ruby's Hash.invert method leaves a lot to wish for.. it can't handle the
34
+ # common case that two or more hash entries point to the same value..
35
+ #
36
+ # e.g.:
37
+ # h = {"ooh gott"=>3, "bla"=>3, "aua"=>3, "kotz"=>2, "blubb"=>9, "seier"=>3, "schigga"=>9}
38
+ # h.invert
39
+ # => {2=>"kotz", 3=>"seier", 9=>"schigga"}
40
+ #
41
+ # the above result IS SIMPLY WRONG!
42
+ #
43
+ # h.invert.invert
44
+ # => {"kotz"=>2, "seier"=>3, "schigga"=>9}
45
+ #
46
+ # h.invert.invert == h
47
+ # => false
48
+ #
49
+ # Let's conclude that Ruby's built-in Hash.invert method is REALLY BROKEN!
50
+ #
51
+ #
52
+ # OK, let's try this new inverse method:
53
+ #
54
+ # require 'invert_hash'
55
+ #
56
+ # h.inverse
57
+ # => {2=>"kotz", 3=>["seier", "aua", "bla", "ooh gott"], 9=>["schigga", "blubb"]}
58
+ #
59
+ # h.inverse.inverse
60
+ # => {"ooh gott"=>3, "bla"=>3, "aua"=>3, "kotz"=>2, "blubb"=>9, "seier"=>3, "schigga"=>9}
61
+ #
62
+ # h.inverse.inverse == h
63
+ # => true
64
+ #
65
+ # Looks much better, doesn't it?
66
+
67
+
68
+
69
+ class Hash
70
+
71
+ def inverse
72
+ i = Hash.new
73
+ self.each_pair{ |k,v|
74
+ if (v.class == Array)
75
+ v.each{ |x|
76
+ if i.has_key?(x)
77
+ i[x] = [k,i[x]].flatten
78
+ else
79
+ i[x] = k
80
+ end
81
+ }
82
+ else
83
+ if i.has_key?(v)
84
+ i[v] = [k,i[v]].flatten
85
+ else
86
+ i[v] = k
87
+ end
88
+ end
89
+ }
90
+ return i
91
+ end
92
+
93
+ end
94
+
95
+ __END__
96
+
97
+ # if you want to permanently overload Ruby's original invert method, you may want to do this:
98
+
99
+ class Hash
100
+ alias old_invert invert
101
+
102
+ def invert
103
+ self.inverse
104
+ end
105
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: id3
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.4.0
7
+ date: 2008-08-16 00:00:00 -07:00
8
+ summary: id3-0.4.0 - ID3 tag library for Ruby http://www.unixgods.org/~tilo/Ruby/ID3
9
+ require_paths:
10
+ - lib
11
+ email: tools@unixgods.org
12
+ homepage: http://www.unixgods.org/~tilo/Ruby/ID3
13
+ rubyforge_project:
14
+ description: ID3 is a native ruby library for reading and writing ID3 tag versions 1.0, 1.1, and 2.2.x, 2,3.x, 2,4.x
15
+ autorequire: id3
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Tilo Sloboda
31
+ files:
32
+ - docs/index.html
33
+ - docs/Class_Tag2.html
34
+ - docs/ID3_comparison.html
35
+ - docs/Class_Tag1.html
36
+ - docs/ID3v2_frames_comparison.txt
37
+ - docs/ID3v2_frames_overview.txt
38
+ - docs/Module_ID3.html
39
+ - docs/ID3_comparison2.html
40
+ - docs/id3.html
41
+ - docs/Class_Frame.html
42
+ - docs/Class_AudioFile.html
43
+ - docs/ID3-Standards
44
+ - docs/ID3-Standards/id3v2.3.0.html
45
+ - docs/ID3-Standards/id3v2.4.0-frames.html
46
+ - docs/ID3-Standards/id3v2.4.0-frames.txt
47
+ - docs/ID3-Standards/id3v2-00.txt
48
+ - docs/ID3-Standards/id3v2.4.0-structure.txt
49
+ - docs/ID3-Standards/id3v2.3.0.txt
50
+ - docs/ID3-Standards/id3v2.4.0-changes.txt
51
+ - docs/ID3-Standards/id3v2.4.0-structure.html
52
+ - docs/ID3-Standards/id3v2.4.0-changes.html
53
+ - docs/ID3-Standards/id3v2-00.html
54
+ - docs/ID3v2_frames_comparison.html
55
+ - lib/hexdump.rb
56
+ - lib/id3.rb
57
+ - lib/invert_hash.rb
58
+ - LICENSE.html
59
+ - index.html
60
+ - README
61
+ test_files: []
62
+
63
+ rdoc_options:
64
+ - --title
65
+ - Builder -- Easy XML Building
66
+ extra_rdoc_files: []
67
+
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ requirements: []
73
+
74
+ dependencies: []
75
+