Class: LanguageColors::LanguageColors

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

Overview

Looks up the GitHub/Linguist color for a language name.

Constant Summary collapse

COLORS_FILE =
File.join(__dir__, 'colors.json')

Instance Method Summary collapse

Constructor Details

#initializeLanguageColors

Returns a new instance of LanguageColors.



14
15
16
# File 'lib/language_colors.rb', line 14

def initialize
  @hash = JSON.parse(File.read(COLORS_FILE))
end

Instance Method Details

#color(lang) ⇒ Object

Returns the hex color string (e.g. "#f34b7d") for lang, or nil if the language is unknown.



20
21
22
# File 'lib/language_colors.rb', line 20

def color(lang)
  @hash[lang]
end