Skip to content

Instantly share code, notes, and snippets.

@blake41
Created July 31, 2015 15:00
Show Gist options
  • Save blake41/ad2be9eb6e730b3e19ba to your computer and use it in GitHub Desktop.
Save blake41/ad2be9eb6e730b3e19ba to your computer and use it in GitHub Desktop.
def reformat_languages(languages)
result = {}
languages.each_pair do |style, values|
# style like :oo
# values like {
# :javascript => {
# :type => "interpreted"
# }
values.each_pair do |language, attributes|
# language is like :javascript
# attribute is like {
# :type => "interpreted"
# }
# case 1, i've never seen this language before
result[language] ||= {}
result[language][:type] = attributes[:type]
result[language][:style] ||= []
result[language][:style] << style
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment