musicrb 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/musicrb/musicrb.so +0 -0
- data/lib/musicrb.rb +8 -1
- data/lib/play_list.rb +71 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6a1b451c196d0b2ed8ee0a747521fd8ab33e67a4a790cdc88ffc2b97b58f333
|
4
|
+
data.tar.gz: d770c267aa933d583487b27444cfdb242ba3c26d509c4d7af4e5eaa65a2152fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ceacdffbd18c92a243681d4e62d53cbbcfb155c8ec333f63351479eb3670fd31812f4cb89a58157c9219217afa31ad6c8aa5d18f03cf764cc8c0b4f7395f6d
|
7
|
+
data.tar.gz: d22b0e4ef6e4d4aeaf595a4ea3b4f9aa7607c08ef612589ce73277199ddb75fd24205a3341d0a66c48d97d430165d499be6ed79ea3c89cbcb466880b266da0f1
|
data/lib/musicrb/musicrb.so
CHANGED
Binary file
|
data/lib/musicrb.rb
CHANGED
data/lib/play_list.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Music
|
4
|
+
# Media is a class used to reference any music with any format
|
5
|
+
class Media
|
6
|
+
attr_reader :title, :artist, :album, :genre
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"#{title} | #{artist} | #{album} | #{genre}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# PlayList is a class used to create and play a list of musics
|
14
|
+
class PlayList
|
15
|
+
attr_reader :name, :list
|
16
|
+
|
17
|
+
def initialize(name)
|
18
|
+
@name = name
|
19
|
+
@list = []
|
20
|
+
@current_media = 0
|
21
|
+
@playing = false
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"Playlist: #{name}\n#{list_to_s}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def load(file_path)
|
29
|
+
@list << Media.load(file_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def play
|
33
|
+
stop_others_others_play_lists
|
34
|
+
@playing = true
|
35
|
+
|
36
|
+
@current_media = 0 if @current_media >= @list.length
|
37
|
+
media = @list[@current_media]
|
38
|
+
|
39
|
+
return if media == nil
|
40
|
+
|
41
|
+
intern_play(media)
|
42
|
+
|
43
|
+
media
|
44
|
+
end
|
45
|
+
|
46
|
+
def prev
|
47
|
+
@current_media = (@current_media - 1) % list.length
|
48
|
+
play
|
49
|
+
end
|
50
|
+
|
51
|
+
def next
|
52
|
+
@current_media = (@current_media + 1) % list.length
|
53
|
+
play
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def list_to_s
|
59
|
+
@list.map(&:to_s).each_with_index.reduce("") do |str, (media_str, idx)|
|
60
|
+
show_icon = (@playing && idx == @current_media)
|
61
|
+
track_str = "#{idx + 1} - #{media_str}\n"
|
62
|
+
|
63
|
+
str += show_icon ? "► #{track_str}" : track_str
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def stop_others_others_play_lists
|
68
|
+
ObjectSpace.each_object(Music::PlayList) { |play_list| play_list.instance_variable_set("@playing", false) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: musicrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- juneira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A player for music
|
14
14
|
email: marcelo.jr63@gmail.com
|
@@ -20,6 +20,7 @@ files:
|
|
20
20
|
- ext/musicrb/extconf.rb
|
21
21
|
- lib/musicrb.rb
|
22
22
|
- lib/musicrb/musicrb.so
|
23
|
+
- lib/play_list.rb
|
23
24
|
homepage: https://github.com/juneira/musicrb
|
24
25
|
licenses:
|
25
26
|
- MIT
|