Created
May 1, 2015 07:55
-
-
Save wezm/6348f1fcb8c228e75452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/core_ext/array' | |
items = ["African", "Ambient", "Asian", "Avant-garde", "Blues", "Breakbeat", "Caribbean", "Comedy", "Country", "Disco", "Downtempo", "Drum & Bass", "Easy listening", "Electro", "Electronic", "Folk", "Hardcore", "Hardstyle", "Hip hop", "House", "Industrial", "Jazz", "Jungle", "Latin", "Pop", "R&B", "Rock", "Soul", "Techno", "Trance"] | |
letters = ('a'..'z') | |
puts letters.to_a.map(&:upcase).join(' ') | |
last_letter = '`' # ` is the char before 'a' | |
items.in_groups_of(2).each do |group| | |
next_letter = group.compact.map { |item| item[0].downcase }.last | |
if next_letter != last_letter | |
(last_letter.succ..next_letter).each do |letter| | |
puts %{<a name="#{letter}">} | |
end | |
end | |
last_letter = next_letter | |
puts group.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment