Class: MusicMetadataScore::Contributor

Inherits:
Object
  • Object
show all
Defined in:
lib/music_metadata_score/contributor.rb

Class Method Summary collapse

Class Method Details

.are_proper_format?(contributors) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
# File 'lib/music_metadata_score/contributor.rb', line 4

def self.are_proper_format?(contributors)
	if contributors && contributors != []
		MusicMetadataScore::Contributor.loop_contributors(contributors)
	else
		false
	end
end

.has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
# File 'lib/music_metadata_score/contributor.rb', line 39

def self.has_role?(role)
	if role && role != ""
		true
	else
		false
	end
end

.is_human_name?(contributor) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/music_metadata_score/contributor.rb', line 31

def self.is_human_name?(contributor)
	if contributor.downcase.include?('the ') || contributor.split(' ').count < 2
		false
	else
		true
	end
end

.is_proper_format?(contributor) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'lib/music_metadata_score/contributor.rb', line 23

def self.is_proper_format?(contributor)
	if MusicMetadataScore::Contributor.is_human_name?(contributor[:name]) && MusicMetadataScore::Contributor.has_role?(contributor[:role]) && !MusicMetadataScore::Artist.is_compound_artist?(contributor[:name], false) && MusicMetadataScore.is_title_case?(contributor[:name])
		true
	else
		false
	end
end

.loop_contributors(contributors) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/music_metadata_score/contributor.rb', line 12

def self.loop_contributors(contributors)
	value = true
	contributors.each do |c|
		if !MusicMetadataScore::Contributor.is_proper_format?(c)
			value = false
			break
		end
	end
	value
end