Class: Chaussettes::Info
- Inherits:
-
Object
- Object
- Chaussettes::Info
- Defined in:
- lib/chaussettes/info.rb
Overview
encapsulates info about an audio file
Instance Method Summary collapse
- #_parse(output) ⇒ Object
- #bit_rate ⇒ Object
- #bits ⇒ Object
- #channels ⇒ Object
- #duration ⇒ Object
- #filename ⇒ Object
-
#initialize(filename) ⇒ Info
constructor
A new instance of Info.
- #rate ⇒ Object
- #size ⇒ Object
Constructor Details
Instance Method Details
#_parse(output) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/chaussettes/info.rb', line 13 def _parse(output) output.lines.each.with_object({}) do |line, hash| next if line.strip.empty? key, value = line.split(/:/, 2) hash[key.strip] = value.strip end end |
#bit_rate ⇒ Object
52 53 54 |
# File 'lib/chaussettes/info.rb', line 52 def bit_rate @_bit_rate ||= @data['Bit Rate'] end |
#bits ⇒ Object
33 34 35 |
# File 'lib/chaussettes/info.rb', line 33 def bits @_bits ||= @data['Precision'].to_i end |
#channels ⇒ Object
25 26 27 |
# File 'lib/chaussettes/info.rb', line 25 def channels @_channels ||= @data['Channels'].to_i end |
#duration ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/chaussettes/info.rb', line 37 def duration @_duration ||= begin timespec = @data['Duration'].split(/ /).first h, m, s = timespec.split(/:/) h.to_i * 3600 + m.to_i * 60 + s.to_f end end |
#filename ⇒ Object
21 22 23 |
# File 'lib/chaussettes/info.rb', line 21 def filename @_filename ||= @data['Input File'] end |
#rate ⇒ Object
29 30 31 |
# File 'lib/chaussettes/info.rb', line 29 def rate @_rate ||= @data['Sample Rate'].to_i end |
#size ⇒ Object
48 49 50 |
# File 'lib/chaussettes/info.rb', line 48 def size @_size ||= @data['File Size'] end |