Class: BLF::Block
- Inherits:
-
Object
- Object
- BLF::Block
- Defined in:
- lib/blf/block.rb
Instance Attribute Summary collapse
-
#end_x ⇒ Object
Returns the value of attribute end_x.
-
#end_y ⇒ Object
Returns the value of attribute end_y.
-
#height ⇒ Object
Returns the value of attribute height.
-
#start_x ⇒ Object
Returns the value of attribute start_x.
-
#start_y ⇒ Object
Returns the value of attribute start_y.
-
#width ⇒ Object
Returns the value of attribute width.
-
#world ⇒ Object
Returns the value of attribute world.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(args) ⇒ Block
constructor
A new instance of Block.
- #random ⇒ Object
Constructor Details
#initialize(args) ⇒ Block
Returns a new instance of Block.
8 9 10 11 12 13 14 |
# File 'lib/blf/block.rb', line 8 def initialize(args) @start_x = args[:start_x] || 0 @start_y = args[:start_y] || 0 @width = args[:width] || 0 @height = args[:height] || 0 @world = args[:world] end |
Instance Attribute Details
#end_x ⇒ Object
Returns the value of attribute end_x.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def end_x @end_x end |
#end_y ⇒ Object
Returns the value of attribute end_y.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def end_y @end_y end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def height @height end |
#start_x ⇒ Object
Returns the value of attribute start_x.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def start_x @start_x end |
#start_y ⇒ Object
Returns the value of attribute start_y.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def start_y @start_y end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def width @width end |
#world ⇒ Object
Returns the value of attribute world.
6 7 8 |
# File 'lib/blf/block.rb', line 6 def world @world end |
Instance Method Details
#draw ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/blf/block.rb', line 24 def draw dr = Draw.new dr.stroke = "#ccddff" dr.fill = "rgb(#{random*255}, #{random*255}, #{random*255})" dr.stroke_width 1 dr.rectangle @start_x, @start_y, end_x, end_y dr.draw @world.image end |
#random ⇒ Object
33 34 35 |
# File 'lib/blf/block.rb', line 33 def random Random.new(Random.new_seed).rand end |