repo.or.cz
/
mpdhero.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
history
|
raw
|
HEAD
added README
[mpdhero.git]
/
classes.rb
blob
302ad5f58b6c56a972aaed7d7ad8059ce45f7bc0
1
class Array
2
def shuffle!
3
size.downto(1) { |n| push delete_at(rand(n)) }
4
self
5
end
6
def swap!(a, b)
7
self[a], self[b] = self[b], self[a]
8
end
9
def random()
10
at rand size
11
end
12
def time()
13
inject(0) do |sum, track|
14
sum += track.time.to_i
15
end
16
end
17
end
18
19
class MPD
20
def move_pairs(*map)
21
command_list_begin
22
for x in map
23
unless x.first == x.last
24
command("moveid #{x.first} #{x.last}")
25
end
26
end
27
command_list_end
28
end
29
public :connect
30
end
31