Class: LanguageColors::LanguageColors
- Inherits:
-
Object
- Object
- LanguageColors::LanguageColors
- 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
-
#color(lang) ⇒ Object
Returns the hex color string (e.g. "#f34b7d") for
lang, or nil if the language is unknown. -
#initialize ⇒ LanguageColors
constructor
A new instance of LanguageColors.
Constructor Details
#initialize ⇒ LanguageColors
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 |