Class: ASE::Color::Gray
- Inherits:
-
Object
- Object
- ASE::Color::Gray
- Defined in:
- lib/ase/color_modes/gray.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value = 0) ⇒ Gray
constructor
A new instance of Gray.
- #read!(file) ⇒ Object
- #to_a ⇒ Object
- #to_rgb ⇒ Object
- #write!(file) ⇒ Object
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
#value ⇒ Object
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_a ⇒ Object
25 26 27 |
# File 'lib/ase/color_modes/gray.rb', line 25 def to_a [@value] end |
#to_rgb ⇒ Object
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 |