Class: MusicBox::Catalog::Format
- Inherits:
-
Object
- Object
- MusicBox::Catalog::Format
- Defined in:
- lib/musicbox/catalog/format.rb
Instance Attribute Summary collapse
-
#descriptions ⇒ Object
Returns the value of attribute descriptions.
-
#name ⇒ Object
Returns the value of attribute name.
-
#qty ⇒ Object
Returns the value of attribute qty.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #cd? ⇒ Boolean
- #descriptions_to_s ⇒ Object
-
#initialize(params = {}) ⇒ Format
constructor
A new instance of Format.
- #qty_to_s ⇒ Object
- #short_to_s ⇒ Object
- #to_s ⇒ Object
- #vinyl? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Format
Returns a new instance of Format.
16 17 18 |
# File 'lib/musicbox/catalog/format.rb', line 16 def initialize(params={}) params.each { |k, v| send("#{k}=", v) } end |
Instance Attribute Details
#descriptions ⇒ Object
Returns the value of attribute descriptions.
7 8 9 |
# File 'lib/musicbox/catalog/format.rb', line 7 def descriptions @descriptions end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/musicbox/catalog/format.rb', line 8 def name @name end |
#qty ⇒ Object
Returns the value of attribute qty.
9 10 11 |
# File 'lib/musicbox/catalog/format.rb', line 9 def qty @qty end |
#text ⇒ Object
Returns the value of attribute text.
10 11 12 |
# File 'lib/musicbox/catalog/format.rb', line 10 def text @text end |
Class Method Details
.to_s(formats) ⇒ Object
12 13 14 |
# File 'lib/musicbox/catalog/format.rb', line 12 def self.to_s(formats) formats.map(&:short_to_s).join(', ') end |
Instance Method Details
#cd? ⇒ Boolean
40 41 42 |
# File 'lib/musicbox/catalog/format.rb', line 40 def cd? @name == 'CD' end |
#descriptions_to_s ⇒ Object
32 33 34 |
# File 'lib/musicbox/catalog/format.rb', line 32 def descriptions_to_s @descriptions ? " (#{@descriptions.join(', ')})" : '' end |
#qty_to_s ⇒ Object
36 37 38 |
# File 'lib/musicbox/catalog/format.rb', line 36 def qty_to_s (@qty && @qty > 1) ? " [#{@qty}]" : '' end |
#short_to_s ⇒ Object
28 29 30 |
# File 'lib/musicbox/catalog/format.rb', line 28 def short_to_s @name + qty_to_s end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/musicbox/catalog/format.rb', line 24 def to_s @name + descriptions_to_s + qty_to_s end |
#vinyl? ⇒ Boolean
44 45 46 |
# File 'lib/musicbox/catalog/format.rb', line 44 def vinyl? @name == 'Vinyl' end |