Class: Tinyscrobbler::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/parser.rb

Overview

This class parses metadata from audio files. It currently supports only mp3 files.

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Parser

Checks if given file exists and if is supported, and calls the parser method, if not raises exception.



15
16
17
18
19
20
21
22
# File 'lib/parser.rb', line 15

def initialize(file_path)
  @path = file_path
  raise 'File not found or unreadable.' unless File.exists? @path and File.readable? @path
  @extension = File.extname(file_path).downcase
  raise 'Not a valid audio file.' unless @extension == '.mp3'
  
  @metadata = 
end

Instance Method Details

#metadataObject

Returns the metadata but updates the time param



26
27
28
29
# File 'lib/parser.rb', line 26

def 
  @metadata['time'] = Time.now.to_i.to_s
  @metadata
end