Created
April 30, 2016 10:01
-
-
Save r7kamura/434cd43fc950edc2e2bcccfb9fdaf2d2 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
class Community < ActiveRecord::Base | |
# @note https://www.w3.org/TR/AERT#color-contrast | |
# @return [false, true] | |
def has_dark_header_background_color? | |
red, green, blue = header_background_color_hex.scan(/../).map { |hex| hex.to_i(16) } | |
(red * 299 + green * 587 + blue * 114) < 125_000 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment