class Subconv::Scc::Color
Color
constants as immutable value objects with some convenience functions (e.g. conversion to string or symbol) All available colors are registered as constants in this class, e.g. Color::WHITE, Color::RED and so on The instances of this class are all frozen and can never be changed. Instances can be retrieved only by the constants or with ::for_value
Constants
- COLORS
rubocop:disable MutableConstant
- TO_SYMBOL_MAP
Public Class Methods
for_value(value)
click to toggle source
Get the Color
instance corresponding to a CEA608 color code
# File lib/subconv/scc/reader.rb, line 123 def self.for_value(value) color = COLORS[value] fail "Color value #{value} is unknown" if color.nil? color end
register_color(name, value)
click to toggle source
rubocop:enable MutableConstant
# File lib/subconv/scc/reader.rb, line 94 def self.register_color(name, value) # Make sure the new color is immutable new_color = Color.new(value).freeze # Register in lookup tables COLORS[value] = new_color TO_SYMBOL_MAP[value] = name # Register as class constant const_set(name.to_s.upcase, new_color) end
Private Class Methods
new(color)
click to toggle source
# File lib/subconv/scc/reader.rb, line 73 def initialize(color) @color = color end
Public Instance Methods
to_s()
click to toggle source
Lower-case CEA-608 name of the color
# File lib/subconv/scc/reader.rb, line 84 def to_s to_symbol.to_s end
Also aliased as: inspect
to_symbol()
click to toggle source
Lower-case CEA608 name of the color as symbol
# File lib/subconv/scc/reader.rb, line 118 def to_symbol TO_SYMBOL_MAP[@color] end
value()
click to toggle source
CEA-608 color code
# File lib/subconv/scc/reader.rb, line 78 def value @color end
Also aliased as: to_i