Class: Warden

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*prisoners) ⇒ Warden

Returns a new instance of Warden.



3
4
5
6
7
8
9
10
11
12
# File 'lib/warden.rb', line 3

def initialize *prisoners
	@roster = []
	@visited = {}
	prisoners.each do |p|
		@roster.push(p)
		@visited[p] = false
	end
	@done = false
	@hours_elapsed = 0
end

Instance Attribute Details

#doneObject

Returns the value of attribute done.



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

def done
  @done
end

#hours_elapsedObject

Returns the value of attribute hours_elapsed.



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

def hours_elapsed
  @hours_elapsed
end

#rosterObject

Returns the value of attribute roster.



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

def roster
  @roster
end

#visitedObject

Returns the value of attribute visited.



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

def visited
  @visited
end

Instance Method Details

#finishObject



20
21
22
23
24
25
26
27
# File 'lib/warden.rb', line 20

def finish
	if @visited.all?
		puts "You're all free to go."
	else
		puts "To the alligators with you!"
	end
	@done = true
end

#take_into_roomObject



14
15
16
17
18
# File 'lib/warden.rb', line 14

def take_into_room
	selectee = @roster.flatten.sample
	selectee.visit
	@hours_elapsed += rand(73)
end