Class: Musictree::Track
- Inherits:
-
Object
- Object
- Musictree::Track
- Defined in:
- lib/musictree/track.rb
Overview
A track holds the meta information for one music file
Instance Attribute Summary collapse
-
#album ⇒ Object
readonly
Returns the value of attribute album.
-
#artist ⇒ Object
readonly
Returns the value of attribute artist.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#track ⇒ Object
readonly
Returns the value of attribute track.
Class Method Summary collapse
-
.scan(path) ⇒ Object
Scan a music file for metadata (The method name is consistent to the other classes but a bit shit).
Instance Method Summary collapse
-
#initialize(path) ⇒ Track
constructor
A new instance of Track.
- #inspect ⇒ Object
- #parse_file ⇒ Object
Constructor Details
#initialize(path) ⇒ Track
Returns a new instance of Track.
19 20 21 22 23 |
# File 'lib/musictree/track.rb', line 19 def initialize(path) @path = path @title = File.basename(@path) # Let's set a preliminary name parse_file end |
Instance Attribute Details
#album ⇒ Object (readonly)
Returns the value of attribute album.
9 10 11 |
# File 'lib/musictree/track.rb', line 9 def album @album end |
#artist ⇒ Object (readonly)
Returns the value of attribute artist.
9 10 11 |
# File 'lib/musictree/track.rb', line 9 def artist @artist end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/musictree/track.rb', line 9 def path @path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/musictree/track.rb', line 9 def title @title end |
#track ⇒ Object (readonly)
Returns the value of attribute track.
9 10 11 |
# File 'lib/musictree/track.rb', line 9 def track @track end |
Class Method Details
.scan(path) ⇒ Object
Scan a music file for metadata (The method name is consistent to the other classes but a bit shit)
13 14 15 16 17 |
# File 'lib/musictree/track.rb', line 13 def self.scan(path) moi = new(path) moi.parse_file moi end |
Instance Method Details
#inspect ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/musictree/track.rb', line 25 def inspect { path: @path, title: @title, artist: @artist, track: @track_no, album: @album }.inspect end |
#parse_file ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/musictree/track.rb', line 35 def parse_file tag = WahWah.open(@path) @title = tag.title @artist = tag.artist @track = tag.track @album = tag.album end |