Class: Switchbox

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSwitchbox

Returns a new instance of Switchbox.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/switchbox.rb', line 3

def initialize
	if rand(2) == 0
		@left = :ON
	else
		@left = :OFF
	end

	if rand(2) == 0
		@right = :ON
	else
		@right = :OFF
	end
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



2
3
4
# File 'lib/switchbox.rb', line 2

def left
  @left
end

#rightObject

Returns the value of attribute right.



2
3
4
# File 'lib/switchbox.rb', line 2

def right
  @right
end

Instance Method Details

#left_flipObject



17
18
19
20
21
22
23
# File 'lib/switchbox.rb', line 17

def left_flip
	if @left == :ON
		@left = :OFF
	else
		@left = :ON
	end
end

#right_flipObject



25
26
27
28
29
30
31
# File 'lib/switchbox.rb', line 25

def right_flip
	if @right == :ON
		@right = :OFF
	else
		@right = :ON
	end
end