Sha256: 9630e4456f70a5203bc56f37728eab5db7986f7f70d1037726e516244f042aff

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

# coding:utf-8
# License:: Ruby
# Author:: Guillaume Pierronnet (mailto:moumar_AT__rubyforge_DOT_org)
# Website:: http://ruby-mp3info.rubyforge.org/

class Mp3Info 
  module HashKeys #:nodoc:
    ### lets you specify hash["key"] as hash.key
    ### this came from CodingInRuby on RubyGarden
    ### http://www.rubygarden.org/ruby?CodingInRuby
    def method_missing(meth,*args)
      m = meth.id2name
      if /=$/ =~ m
	self[m.chop] = (args.length<2 ? args[0] : args)
      else
	self[m]
      end
    end
  end  
  
  class ::String
    if RUBY_VERSION < "1.9.0"
      alias getbyte []
    else
      def getbyte(i)
        self[i].ord unless self[i].nil?
      end
    end
  end

  module Mp3FileMethods #:nodoc: 
    if RUBY_VERSION < "1.9.0"
      def getbyte
        getc
      end
    end
                        
    def get32bits
      (getbyte << 24) + (getbyte << 16) + (getbyte << 8) + getbyte
    end

    def get_syncsafe
      (getbyte << 21) + (getbyte << 14) + (getbyte << 7) + getbyte
    end                 
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-mp3info-0.6.16 lib/mp3info/extension_modules.rb
ruby-mp3info-0.6.15 lib/mp3info/extension_modules.rb
ruby-mp3info-0.6.14 lib/mp3info/extension_modules.rb