Class: FLACsmith::Metadata::Tag
- Inherits:
-
Object
- Object
- FLACsmith::Metadata::Tag
- Defined in:
- lib/flacsmith/metadata/tag.rb
Overview
Represents metadata tag information.
Constant Summary collapse
- KEYS =
%w[ ALBUM ARTIST CONTACT COPYRIGHT DATE DESCRIPTION GENRE ISRC LICENSE LOCATION ORGANIZATION PERFORMER TITLE TRACKNUMBER VERSION ].freeze
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, initial_value = "") ⇒ Tag
constructor
A new instance of Tag.
- #to_s ⇒ Object (also: #to_str)
- #value ⇒ Object
Constructor Details
#initialize(key, initial_value = "") ⇒ Tag
Returns a new instance of Tag.
37 38 39 40 41 |
# File 'lib/flacsmith/metadata/tag.rb', line 37 def initialize key, initial_value = "" @key = key @initial_value = String initial_value validate end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
27 28 29 |
# File 'lib/flacsmith/metadata/tag.rb', line 27 def key @key end |
Class Method Details
.defaults ⇒ Object
29 30 31 |
# File 'lib/flacsmith/metadata/tag.rb', line 29 def self.defaults KEYS.map { |key| self.for key } end |
.for(key, value = "") ⇒ Object
33 34 35 |
# File 'lib/flacsmith/metadata/tag.rb', line 33 def self.for key, value = "" new key, value end |
Instance Method Details
#to_s ⇒ Object Also known as: to_str
49 50 51 |
# File 'lib/flacsmith/metadata/tag.rb', line 49 def to_s "#{key}=#{value}" end |
#value ⇒ Object
43 44 45 46 47 |
# File 'lib/flacsmith/metadata/tag.rb', line 43 def value return initial_value if initial_value.empty? Shellwords.escape initial_value end |