class FLACsmith::Metadata::Tag

Represents metadata tag information.

Constants

KEYS

Attributes

initial_value[R]
key[R]

Public Class Methods

defaults() click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 29
def self.defaults
  KEYS.map { |key| self.for key }
end
for(key, value = "") click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 33
def self.for key, value = ""
  new key, value
end
new(key, initial_value = "") click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 37
def initialize key, initial_value = ""
  @key = key
  @initial_value = String initial_value
  validate
end

Public Instance Methods

to_s() click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 49
def to_s
  "#{key}=#{value}"
end
Also aliased as: to_str
to_str()
Alias for: to_s
value() click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 43
def value
  return initial_value if initial_value.empty?

  Shellwords.escape initial_value
end

Private Instance Methods

validate() click to toggle source
# File lib/flacsmith/metadata/tag.rb, line 59
def validate
  invalid_keys = [key] - KEYS
  return true if invalid_keys.empty?

  fail Errors::InvalidMetadataKey, invalid_keys
end