Class: Tinyscrobbler::Parser
- Inherits:
-
Object
- Object
- Tinyscrobbler::Parser
- Defined in:
- lib/parser.rb
Overview
This class parses metadata from audio files. It currently supports only mp3 files.
Instance Method Summary collapse
-
#initialize(file_path) ⇒ Parser
constructor
Checks if given file exists and if is supported, and calls the parser method, if not raises exception.
-
#metadata ⇒ Object
Returns the metadata but updates the time param.
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
#metadata ⇒ Object
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 |