class FLACsmith::Metadata::File
Builds metadata for a file.
Constants
- NUMBER_PATTERN
Public Class Methods
new(path)
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 13 def initialize path @path = String path end
Public Instance Methods
album(= String nodes.reverse[1])
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 19 def album = String nodes.reverse[1] def number return "" unless last_node return "" unless last_node.match? NUMBER_PATTERN String(last_node[NUMBER_PATTERN]).rjust 2, "0" end def title = String(last_node).gsub(NUMBER_PATTERN, "").gsub(/\..+$/, "").strip def name = [number, title].compress.join " " def tags [ Tag.for("TRACKNUMBER", number), Tag.for("TITLE", title), Tag.for("ALBUM", album), Tag.for("ARTIST", artist) ] end def to_s = path alias to_str to_s def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end alias to_hash to_h private attr_reader :path def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last
artist(= String nodes.reverse[2])
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 17 def artist = String nodes.reverse[2] def album = String nodes.reverse[1] def number return "" unless last_node return "" unless last_node.match? NUMBER_PATTERN String(last_node[NUMBER_PATTERN]).rjust 2, "0" end def title = String(last_node).gsub(NUMBER_PATTERN, "").gsub(/\..+$/, "").strip def name = [number, title].compress.join " " def tags [ Tag.for("TRACKNUMBER", number), Tag.for("TITLE", title), Tag.for("ALBUM", album), Tag.for("ARTIST", artist) ] end def to_s = path alias to_str to_s def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end alias to_hash to_h private attr_reader :path def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last
last_node(= nodes.last)
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 62 def last_node = nodes.last end
name(= [number, title].compress.join " ")
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 30 def name = [number, title].compress.join " " def tags [ Tag.for("TRACKNUMBER", number), Tag.for("TITLE", title), Tag.for("ALBUM", album), Tag.for("ARTIST", artist) ] end def to_s = path alias to_str to_s def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end alias to_hash to_h private attr_reader :path def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last end end
nodes(= to_s.split ::File::SEPARATOR)
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 60 def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last end end
number()
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 21 def number return "" unless last_node return "" unless last_node.match? NUMBER_PATTERN String(last_node[NUMBER_PATTERN]).rjust 2, "0" end
title(= String(last_node).gsub(NUMBER_PATTERN, "").gsub(/\..+$/, "").strip)
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 28 def title = String(last_node).gsub(NUMBER_PATTERN, "").gsub(/\..+$/, "").strip def name = [number, title].compress.join " " def tags [ Tag.for("TRACKNUMBER", number), Tag.for("TITLE", title), Tag.for("ALBUM", album), Tag.for("ARTIST", artist) ] end def to_s = path alias to_str to_s def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end alias to_hash to_h private attr_reader :path def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last end
to_h()
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 45 def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end
to_s(= path)
click to toggle source
# File lib/flacsmith/metadata/file.rb, line 41 def to_s = path alias to_str to_s def to_h { "TRACKNUMBER" => number, "TITLE" => title, "ALBUM" => album, "ARTIST" => artist } end alias to_hash to_h private attr_reader :path def nodes = to_s.split ::File::SEPARATOR def last_node = nodes.last end end end