billboard_hot_100_CLI 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 901700f808d1eb35b739c4702cbb4ad2d83bb4d2d246a614e2b584cfa697b64e
4
- data.tar.gz: 7bdb21f1f4e523920c8c51368d5e580e938d12bab9e6f67b72abc6ee044ac67d
3
+ metadata.gz: af48475772c793ff5de2aab60f2636f022e84a6ed19cd496fce93470c4b4a75a
4
+ data.tar.gz: 5e5c8a207604f7a288c5656acd5e241615b020939e9ef7e05081b353644e27fd
5
5
  SHA512:
6
- metadata.gz: f0af41eaa04ca2d91551f843ad1b31f623add316fcfb6617fb4ee99c8c052aba59b56a3d496ce4ecf4fb943858d0ffb685a1472ca6ebc9eecff5e7a2bcf57d3a
7
- data.tar.gz: 0c89ea87c961c13e5ec4ff9a0e4427297c7724eb0f2dbd06bb560f4d8398088e63dec6a3a47c73c7ae5359ceaaa0dcee49938372de2b1daeb9f545c1087a275f
6
+ metadata.gz: 28f8dafa86532aae4aba103e2d720ec6f0a81d5f2049bc14449fa5b922e106f3041df5b1d1c65ed6a109967a53805f6b4f0ece23df98e7dbfe38986f58d986a8
7
+ data.tar.gz: 365649ae1175076083b943e08fc32d0717986f9dc41da11e0e86c0026f41935688851a8a5025d3df41beb9b94d4399b2cc1aab733c95ad714258b39725d5b49e
@@ -3,93 +3,117 @@ class BillboardHot100::CommandLineInteface
3
3
  def run
4
4
  BillboardHot100::Scraper.scrape_songs
5
5
  welcome
6
- list_ranges
7
- more_info
8
- goodbye
9
6
  end
10
7
 
11
8
  def welcome
12
9
  puts "\nWelcome to the this weeks Billboard Hot 100!\n"
10
+ ranges
13
11
  end
14
12
 
15
- def list_ranges
16
- puts "\nPlease enter the rankings you wish to see...\n"
17
- puts "\nEnter 1-10, 11-20, 21-30, 31-40, 41-50, 51-60, 61-70, 71-80, 81-90 or 91-100\n"
18
- input = gets.strip.to_i
19
- display_songs(input)
13
+ def ranges
14
+ puts "\nPlease enter the rankings you wish to see...\n\n"
15
+
16
+ total = BillboardHot100::Song.all.size
17
+ increment = 10
18
+ ranges = total/increment
19
+ ranking = 1
20
+ ranges_s = ""
21
+
22
+ ranges.times do
23
+ ranges_s << "#{ranking}-#{ranking+increment-1}, "
24
+ ranking += increment
25
+ end
26
+ puts ranges_s[0...-2]
27
+
28
+ quantize_input(increment, total)
20
29
  end
21
30
 
22
- def display_songs(input)
23
- case input
24
- when 1..100
25
- increment = 10
26
- quantize(input, increment)
31
+ def quantize_input(increment, total)
32
+ input = gets.strip
33
+ case
34
+ when input.to_i.between?(1,total)
35
+ low_num = ((input.to_i-1)/increment).floor*increment
36
+ display_songs(increment, input, low_num)
37
+ when input.downcase == "exit"
38
+ exit
27
39
  else
28
40
  invalid_choice
41
+ ranges
29
42
  end
30
43
  end
31
44
 
32
- def quantize(input, increment)
33
- low_num = ((input-1)/increment).floor*increment
34
- display_ten_songs(low_num)
35
- end
36
-
37
- def display_ten_songs(low_num)
38
- puts "\nDisplaying songs #{low_num+1} through #{low_num+10}\n\n"
39
- BillboardHot100::Song.all[low_num,10].each do |song|
45
+ def display_songs(increment, input, low_num)
46
+ puts "\nDisplaying songs #{low_num+1} through #{low_num+increment}\n\n"
47
+ BillboardHot100::Song.all[low_num,increment].each do |song|
40
48
  puts "#{song.rank}. #{song.title} by #{song.artist}"
41
49
  end
50
+
51
+ more_info(increment, input, low_num)
42
52
  end
43
53
 
44
- def more_info
45
- puts "\nPlease enter the song you want more information on.\n"
46
- input = gets.strip
47
-
48
- song = BillboardHot100::Song.all[input.to_i-1]
49
-
50
- display_song(song)
54
+ def more_info(increment, input, low_num)
55
+ puts "\nPlease enter the song you want more information on, or type LIST to select a new range of songs.\n"
56
+ input = gets.strip
57
+
58
+ case
59
+ when input.to_i.between?(low_num+1,low_num+increment)
60
+ song = BillboardHot100::Song.all[input.to_i-1]
61
+ display_song(song)
62
+ when input.downcase == "list"
63
+ ranges
64
+ when input.downcase == "exit"
65
+ exit
66
+ else
67
+ puts "\nPlease enter a number between #{low_num+1} and #{low_num+increment}, or type LIST to select a new range of songs.\n".colorize(:red)
68
+ display_songs(increment, input, low_num)
69
+ end
70
+ continue
71
+ end
51
72
 
52
- puts "\nWould you like information on another song? Enter Y or N\n"
73
+ def continue
74
+ puts "\nWould you like information on another song? Enter Y or N\n"
53
75
 
54
- input = gets.strip.downcase
55
- if input == "y"
56
- run
57
- elsif input == "n"
58
- goodbye
76
+ input = gets.strip.downcase
77
+ case input
78
+ when "y"
79
+ ranges
80
+ when "n", "exit"
81
+ exit
59
82
  else
60
83
  invalid_choice
61
- end
84
+ continue
85
+ end
62
86
  end
63
87
 
64
88
  def display_song(song)
65
89
  puts "\n#{song.rank}. #{song.title} by #{song.artist}"
66
- if song.last_week.length > 0 && !song.last_week.include?("-")
67
- puts "Last Week: #{song.last_week}"
68
- else
69
- puts "New To Chart!".colorize(:red)
70
- end
71
- if song.peak_position.length > 0
72
- puts "Peak Position: #{song.peak_position}"
73
- end
74
- if song.weeks_on_chart.length > 0
75
- puts "Weeks On Chart: #{song.weeks_on_chart}"
76
- end
77
- if song.lyrics.length > 0
78
- puts "Lyrics: #{song.lyrics}"
79
- end
80
- if song.award.length > 0
81
- puts "Award: #{song.award}".colorize(:red)
82
- end
83
- end
84
-
85
- def goodbye
86
- puts "\nCheck back next week for the latest Billboard Hot 100!"
87
- exit
90
+
91
+ if song.last_week.length > 0 && !song.last_week.include?("-")
92
+ puts "Last Week: #{song.last_week}"
93
+ else
94
+ puts "New To Chart!".colorize(:blue)
95
+ end
96
+ if song.peak_position.length > 0
97
+ puts "Peak Position: #{song.peak_position}"
98
+ end
99
+ if song.weeks_on_chart.length > 0
100
+ puts "Weeks On Chart: #{song.weeks_on_chart}"
101
+ end
102
+ if song.lyrics.length > 0
103
+ puts "Lyrics: #{song.lyrics}"
104
+ end
105
+ if song.award.length > 0
106
+ puts "Award: #{song.award}".colorize(:blue)
107
+ end
88
108
  end
89
109
 
90
110
  def invalid_choice
91
- puts "\nInvalid Choice!"
92
- run
111
+ puts "\nInvalid Choice, Please Try Again!".colorize(:red)
112
+ end
113
+
114
+ def exit
115
+ puts "\nCheck back next week for the latest Billboard Hot 100!"
116
+ exit!
93
117
  end
94
118
 
95
- end
119
+ end
@@ -1,3 +1,3 @@
1
1
  module BillboardHot100
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billboard_hot_100_CLI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Olson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-10 00:00:00.000000000 Z
11
+ date: 2019-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,10 +90,8 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - CONTRIBUTING.md
92
92
  - Gemfile
93
- - Gemfile.lock
94
93
  - LICENSE.md
95
94
  - README.md
96
- - billboard_hot_100_CLI-0.1.0.gem
97
95
  - billboard_hot_100_CLI.gemspec
98
96
  - bin/billboard_hot_100
99
97
  - bin/console
data/Gemfile.lock DELETED
@@ -1,11 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
-
5
- PLATFORMS
6
- ruby
7
-
8
- DEPENDENCIES
9
-
10
- BUNDLED WITH
11
- 1.17.3
Binary file