entertainmentOperations 0.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 +7 -0
- data/lib/entertainment_operations.rb +85 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d5165f62493a2b2c1a2b65f724515da70bfd00d5
|
4
|
+
data.tar.gz: 7b96e6a75709230c921bb96e28719875063d3f7b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '08eac8a89a5e5c26621e22ee266a981a2d12dfb594b6b3d1429b84c01123b16bc367f391e353cdcc0d1ab15e1e78e822d008e7d1823a0a4c26958da579d79dcc'
|
7
|
+
data.tar.gz: abd40e1433008e9c62a619e99ad61e6481220f15b84e20ae73775853dc904bdb3dee3c24f675abad0a69abf623aa8434f03e5eade7cd10d336ff1d8dfcb35f1f
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class EntertainmentOperations
|
2
|
+
|
3
|
+
# Rating operations - objects must have Rating
|
4
|
+
|
5
|
+
def self.sortByRating(objectArray)
|
6
|
+
# sorts in ascending order of rating:
|
7
|
+
unless defined?(objectArray[0].rating)
|
8
|
+
puts "Object does not have rating."
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
objectArray.sort_by {|m| m.rating}
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.getHighestRated(objectArray)
|
16
|
+
objectArray = sortByRating(objectArray)
|
17
|
+
puts objectArray.last
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.getLowestRated(objectArray)
|
21
|
+
objectArray = sortByRating(objectArray)
|
22
|
+
puts objectArray.first
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.cutLowestRatedHalf(objectArray)
|
26
|
+
objectArray = sortByRating(objectArray).reverse
|
27
|
+
objectArray.drop(objectArray.length/2)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.printSortedListByRating(objectArray)
|
31
|
+
objectArray = sortByRating(objectArray)
|
32
|
+
objectArray.each {|obj| puts obj}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Title operations - objects must have title
|
36
|
+
|
37
|
+
def self.sortByTitle(objectArray)
|
38
|
+
# sorts by name alphabetically
|
39
|
+
unless defined?(objectArray[0].title)
|
40
|
+
puts "Object does not have title."
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
objectArray.sort_by {|m| m.title.downcase}
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.printSortedListByTitle(objectArray)
|
48
|
+
objectArray = sortByTitle(objectArray)
|
49
|
+
objectArray.each {|obj| puts obj}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Genre operations - objects must have genre
|
53
|
+
|
54
|
+
def self.sortByGenre(objectArray)
|
55
|
+
# sorts by genre alphabetically
|
56
|
+
unless defined?(objectArray[0].genre)
|
57
|
+
puts "Object does not have genre."
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
objectArray.sort_by {|m| m.genre.downcase}
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.printSortedListByGenre(objectArray)
|
65
|
+
objectArray = sortByGenre(objectArray)
|
66
|
+
objectArray.each {|obj| puts obj}
|
67
|
+
end
|
68
|
+
|
69
|
+
# Category operations - objects must have category array
|
70
|
+
|
71
|
+
def self.sortByCategory(objectArray, categoryNumber)
|
72
|
+
# sorts by category alphabetically
|
73
|
+
unless defined?(objectArray[categoryNumber].category.first)
|
74
|
+
puts "Object must have category array."
|
75
|
+
return
|
76
|
+
end
|
77
|
+
|
78
|
+
objectArray.sort_by {|m| m.category.first.downcase}
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.printSortedListByCategory(objectArray, categoryNumber)
|
82
|
+
objectArray = sortByCategory(objectArray, categoryNumber)
|
83
|
+
objectArray.each {|obj| puts obj}
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: entertainmentOperations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Umai Balendra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem designed to perform different operations of a few forms of entertainment
|
14
|
+
by a variety of topics, such as ratings or title
|
15
|
+
email: umai.balendra@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/entertainment_operations.rb
|
21
|
+
homepage:
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.6.14
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Entertainment Operations
|
45
|
+
test_files: []
|