Class: Axon::Solid

Inherits:
Object
  • Object
show all
Includes:
Image, Enumerable
Defined in:
lib/axon/solid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Image

#crop, #fit, #scale_bilinear, #scale_nearest_neighbor, #to_jpeg, #to_png, #write_jpeg, #write_png

Constructor Details

#initialize(width, height, color = nil, color_model = nil) ⇒ Solid

Returns a new instance of Solid.



7
8
9
10
11
12
# File 'lib/axon/solid.rb', line 7

def initialize(width, height, color=nil, color_model=nil)
  @width, @height = width, height
  @color = color || "\x00\x00\x00"
  @color_model = color_model || :RGB
  @components = @color.size
end

Instance Attribute Details

#color_modelObject (readonly)

Returns the value of attribute color_model.



5
6
7
# File 'lib/axon/solid.rb', line 5

def color_model
  @color_model
end

#componentsObject (readonly)

Returns the value of attribute components.



5
6
7
# File 'lib/axon/solid.rb', line 5

def components
  @components
end

#heightObject (readonly)

Returns the value of attribute height.



5
6
7
# File 'lib/axon/solid.rb', line 5

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/axon/solid.rb', line 5

def width
  @width
end

Instance Method Details

#eachObject



14
15
16
17
# File 'lib/axon/solid.rb', line 14

def each
  sl = @color * width
  height.times { yield sl }
end