class Spectra::ColorView

Attributes

color[RW]
formatters[RW]

Public Class Methods

new(color, formatters) click to toggle source
# File lib/spectra/views/view.rb, line 74
def initialize(color, formatters)
  self.color = color 
  self.formatters = formatters
end

Public Instance Methods

format(type, value) click to toggle source
# File lib/spectra/views/view.rb, line 107
def format(type, value)
  self.formatters[type].call(value)
end
grayscale?() click to toggle source
# File lib/spectra/views/view.rb, line 99
def grayscale?
  self.color.components[:white] 
end
hex() click to toggle source
# File lib/spectra/views/view.rb, line 103
def hex
  self.format(:value, Components.hexify(self.color.components))
end
method_missing(name, *args) click to toggle source
Calls superclass method
# File lib/spectra/views/view.rb, line 83
def method_missing(name, *args)
  if Components.valid?(name)
    self.format(:value, self.color.send(name, *args))
  else
    super
  end
end
name() click to toggle source

Accessors

# File lib/spectra/views/view.rb, line 95
def name
  self.format(:name, self.color)
end
respond_to?(name) click to toggle source
Calls superclass method
# File lib/spectra/views/view.rb, line 79
def respond_to?(name)
  super || self.color.respond_to?(name)
end
to_s() click to toggle source

Debugging

# File lib/spectra/views/view.rb, line 115
def to_s
  "<view => #{self.color}>"
end