Class: Pics

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyplot/backend/mouse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePics

Returns a new instance of Pics


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubyplot/backend/mouse.rb', line 6

def initialize
  @window = Gtk::Window.new
  @window.signal_connect('destroy') { Gtk.main_quit }
  pic1 = 'a.png'
  pic2 = 'b.png'
  pic3 = 'c.png'
  @pile = [pic1, pic2, pic3]
  @picindex = 0
  get_image
  @box = Gtk::EventBox.new.add(@image)
end

Instance Attribute Details

#atBatObject

Returns the value of attribute atBat


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def atBat
  @atBat
end

#boxObject

Returns the value of attribute box


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def box
  @box
end

#imageObject

Returns the value of attribute image


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def image
  @image
end

#picindexObject

Returns the value of attribute picindex


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def picindex
  @picindex
end

#pileObject

Returns the value of attribute pile


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def pile
  @pile
end

#windowObject

Returns the value of attribute window


4
5
6
# File 'lib/rubyplot/backend/mouse.rb', line 4

def window
  @window
end

Instance Method Details

#batter_upObject


18
19
20
21
22
23
24
25
# File 'lib/rubyplot/backend/mouse.rb', line 18

def batter_up
  @box.remove(@image)
  @picindex += 1
  @picindex = 0 if @picindex == @pile.length
  get_image
  @box.add(@image)
  @box.show
end

#get_imageObject


27
28
29
30
31
32
# File 'lib/rubyplot/backend/mouse.rb', line 27

def get_image
  @atBat = @pile[@picindex]
  img = GdkPixbuf::Pixbuf.new(@atBat, 200, 200)
  @image = Gtk::Image.new(pixbuf: img)
  @image.show
end