Class: WmaInfo
- Inherits:
-
Object
- Object
- WmaInfo
- Defined in:
- lib/wmainfo.rb
Instance Attribute Summary collapse
-
#ext_info ⇒ Object
readonly
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays.
-
#header_object ⇒ Object
readonly
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays.
-
#info ⇒ Object
readonly
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays.
-
#stream ⇒ Object
readonly
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays.
-
#tags ⇒ Object
readonly
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays.
Instance Method Summary collapse
-
#hasdrm? ⇒ Boolean
returns true if the file has DRM ie: if a “*Content_Encryption_Object” is found.
-
#hasinfo?(field) ⇒ Boolean
returns true if info has a value.
-
#hastag?(tag) ⇒ Boolean
returns true if tags has a value.
-
#initialize(file, opts = {}) ⇒ WmaInfo
constructor
A new instance of WmaInfo.
-
#inspect ⇒ Object
– This cleans up the output when using WmaInfo in irb.
-
#print_info ⇒ Object
prettyprint WmaInfo.info hash.
-
#print_objects ⇒ Object
for ASF_Header_Object prints: “name: GUID size num_objects” for others, prints: “name: GUID size offset”.
-
#print_stream ⇒ Object
prettyprint WmaInfo.stream hash.
-
#print_tags ⇒ Object
prettyprint WmaInfo.tags hash.
-
#to_s ⇒ Object
- returns: “filename.wma
- Size: N bytes
- Bitrate: N kbps
-
Duration: N seconds“ this is useless.
Constructor Details
#initialize(file, opts = {}) ⇒ WmaInfo
Returns a new instance of WmaInfo.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wmainfo.rb', line 33 def initialize(file, opts = {}) @drm = nil @tags = {} @header_object = {} @info = {} @ext_info = {} @stream = {} @file = file @debug = opts[:debug] @encoding = opts[:encoding] || "ASCII" @ic = Iconv.new(@encoding, "UTF-16LE") if RUBY_VERSION.to_f < 1.9 parse_wma_header end |
Instance Attribute Details
#ext_info ⇒ Object (readonly)
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays
32 33 34 |
# File 'lib/wmainfo.rb', line 32 def ext_info @ext_info end |
#header_object ⇒ Object (readonly)
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays
32 33 34 |
# File 'lib/wmainfo.rb', line 32 def header_object @header_object end |
#info ⇒ Object (readonly)
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays
32 33 34 |
# File 'lib/wmainfo.rb', line 32 def info @info end |
#stream ⇒ Object (readonly)
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays
32 33 34 |
# File 'lib/wmainfo.rb', line 32 def stream @stream end |
#tags ⇒ Object (readonly)
WmaInfo.tags and WmaInfo.info are hashes of NAME=VALUE pairs WmaInfo.header_object is a hash of arrays
32 33 34 |
# File 'lib/wmainfo.rb', line 32 def @tags end |
Instance Method Details
#hasdrm? ⇒ Boolean
returns true if the file has DRM ie: if a “*Content_Encryption_Object” is found
57 58 59 |
# File 'lib/wmainfo.rb', line 57 def hasdrm? @drm ? true : false end |
#hasinfo?(field) ⇒ Boolean
returns true if info has a value
72 73 74 |
# File 'lib/wmainfo.rb', line 72 def hasinfo?(field) @info[field] ? true : false end |
#hastag?(tag) ⇒ Boolean
returns true if tags has a value
62 63 64 |
# File 'lib/wmainfo.rb', line 62 def hastag?(tag) @tags[tag] ? true : false end |
#inspect ⇒ Object
–
This cleans up the output when using WmaInfo in irb
94 95 96 97 98 99 100 |
# File 'lib/wmainfo.rb', line 94 def inspect #:nodoc: s = "#<#{self.class}:0x#{(self.object_id*2).to_s(16)} " @header_object.each_pair do |k,v| s += "(#{k.upcase} size=#{v[1]} offset=#{v[2]}) " unless k == "ASF_Header_Object" end s += "\b>" end |
#print_info ⇒ Object
prettyprint WmaInfo.info hash
77 78 79 |
# File 'lib/wmainfo.rb', line 77 def print_info @info.each_pair { |key,val| puts "#{key}: #{val}" } end |
#print_objects ⇒ Object
for ASF_Header_Object prints: “name: GUID size num_objects” for others, prints: “name: GUID size offset”
49 50 51 52 53 |
# File 'lib/wmainfo.rb', line 49 def print_objects @header_object.each_pair do |key,val| puts "#{key}: #{val[0]} #{val[1]} #{val[2]}" end end |
#print_stream ⇒ Object
prettyprint WmaInfo.stream hash
82 83 84 |
# File 'lib/wmainfo.rb', line 82 def print_stream @stream.each_pair { |key,val| puts "#{key}: #{val}" } end |
#print_tags ⇒ Object
prettyprint WmaInfo.tags hash
67 68 69 |
# File 'lib/wmainfo.rb', line 67 def @tags.each_pair { |key,val| puts "#{key}: #{val}" } end |
#to_s ⇒ Object
- returns: “filename.wma
- Size: N bytes
- Bitrate: N kbps
-
Duration: N seconds“
this is useless
88 89 90 |
# File 'lib/wmainfo.rb', line 88 def to_s "#{File.basename(@file)} :: Size: #{@size} bytes :: Bitrate: #{@info['bitrate']} kbps :: Duration: #{@info['playtime_seconds']} seconds" end |