Sha256: 6d4bb80d7bcfb3c0fb0746d724f759d4c7baa42726415fcf57735fcdcec16aaf

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

class String
    def is_mbid
        if self.length==36
            l=self.split("-")
            if l[0].length==8 &&
                    l[1].length==4 &&
                    l[2].length==4 &&
                    l[3].length==4 &&
                    l[4].length==12
                return true
            else
                return false
            end
        else
            return false
        end
    end

    def titleize_proper
        excluded_from_title=["a","an","the","and", "but", "or", "so",
                             "after", "before", "when", "while", "since",
                             "until", "although", "even if", "because",
                             "both", "either", "neither", "nor","as",
                             "at", "by", "for", "from", "in", "into",
                             "of", "off", "on", "onto", "than", "to",
                             "via", "with", "anti", "betwixt", "circa",
                             "per", "qua", "sans", "unto", "versus",
                             "vis-a-vis","ago", "hence",  "through",
                             "withal"]

        string_array=self.split(' ')
        title=Array.new
        string_array.each_with_index do |word,i|

            if i==0
                title<<word.capitalize
            elsif excluded_from_title.include?(word)
                title<<word
            else
                title<<word.capitalize
            end

        end
        title.join(' ')
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
musicbrainz_ruby-0.1.3 lib/generators/music_brainz/install/templates/config/initializers/musicbrainz.rb.erb