Class: ASE::Color::Gray

Inherits:
Object
  • Object
show all
Defined in:
lib/ase/color_modes/gray.rb

Direct Known Subclasses

Grey

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = 0) ⇒ Gray

Returns a new instance of Gray.



8
9
10
# File 'lib/ase/color_modes/gray.rb', line 8

def initialize(value=0)
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/ase/color_modes/gray.rb', line 6

def value
  @value
end

Instance Method Details

#read!(file) ⇒ Object



12
13
14
# File 'lib/ase/color_modes/gray.rb', line 12

def read!(file)
  @value = file.read(4).unpack('g')[0].round(4)
end

#to_aObject



25
26
27
# File 'lib/ase/color_modes/gray.rb', line 25

def to_a
  [@value]
end

#to_rgbObject



21
22
23
# File 'lib/ase/color_modes/gray.rb', line 21

def to_rgb
  RGB.new(*([rgb_value] * 3))
end

#write!(file) ⇒ Object



16
17
18
19
# File 'lib/ase/color_modes/gray.rb', line 16

def write!(file)
  file.write('Gray')
  to_a.each { |c| file.write [c].pack('g') }
end