Class: Block

Inherits:
Object
  • Object
show all
Defined in:
lib/block.rb

Overview

A simple block to be used in the figures and the glass

Copyright © 2011 Nikolay Nemshilov

Constant Summary collapse

SIZE =

block size in pixels

20
FILE =
File.join(File.dirname(__FILE__), '..', 'media', 'block.png')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, color) ⇒ Block

Returns a new instance of Block.



12
13
14
15
# File 'lib/block.rb', line 12

def initialize(window, color)
  @@img ||= Image.new(window, FILE, true)
  @color = color
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



7
8
9
# File 'lib/block.rb', line 7

def color
  @color
end

#sizeObject

Returns the value of attribute size.



7
8
9
# File 'lib/block.rb', line 7

def size
  @size
end

Instance Method Details

#draw(x, y) ⇒ Object



17
18
19
# File 'lib/block.rb', line 17

def draw(x, y)
  @@img.draw(x * SIZE, y * SIZE, 0, 1.0, 1.0, @color)
end