Class: MusicBox::Catalog::Format

Inherits:
Object
  • Object
show all
Defined in:
lib/musicbox/catalog/format.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#descriptionsObject

Returns the value of attribute descriptions.



7
8
9
# File 'lib/musicbox/catalog/format.rb', line 7

def descriptions
  @descriptions
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/musicbox/catalog/format.rb', line 8

def name
  @name
end

#qtyObject

Returns the value of attribute qty.



9
10
11
# File 'lib/musicbox/catalog/format.rb', line 9

def qty
  @qty
end

#textObject

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

Returns:

  • (Boolean)


40
41
42
# File 'lib/musicbox/catalog/format.rb', line 40

def cd?
  @name == 'CD'
end

#descriptions_to_sObject



32
33
34
# File 'lib/musicbox/catalog/format.rb', line 32

def descriptions_to_s
  @descriptions ? " (#{@descriptions.join(', ')})" : ''
end

#qty_to_sObject



36
37
38
# File 'lib/musicbox/catalog/format.rb', line 36

def qty_to_s
  (@qty && @qty > 1) ? " [#{@qty}]" : ''
end

#short_to_sObject



28
29
30
# File 'lib/musicbox/catalog/format.rb', line 28

def short_to_s
  @name + qty_to_s
end

#to_sObject



24
25
26
# File 'lib/musicbox/catalog/format.rb', line 24

def to_s
  @name + descriptions_to_s + qty_to_s
end

#vinyl?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/musicbox/catalog/format.rb', line 44

def vinyl?
  @name == 'Vinyl'
end