logix_toolkit 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07aad560c5874d323a5fdc38883c0d7ca5070676
4
+ data.tar.gz: e7358d2a08c4e2108202853f407b4744cea2a417
5
+ SHA512:
6
+ metadata.gz: fce706a744fc34e69d5ba9dbb66a5ca1f214d97e505282c9e75713c95a4fc35ef0e14673b193a7740a1f994733bc91a0f612f7a0e167b3a65e32746014e5a720
7
+ data.tar.gz: 1aa1478bfeca7eee94a728055fa0a91a7f134678595b0f19fc9ade499b721c7444936d4450ab9c552d0fbf05d76784c23c1f4822280fd0748559be0ed2aff58f
@@ -0,0 +1,22 @@
1
+ require 'logix-toolkit/core/errors'
2
+ require 'logix-toolkit/core/boolean_verifier'
3
+ require 'logix-toolkit/core/messages'
4
+
5
+ #The main library class
6
+ class LogixToolkit
7
+ #the class used as a namespace seperator for operations
8
+ class Operations
9
+ end
10
+
11
+ #Displays introduction and a tutorial on how to use the library
12
+ def self.help
13
+ Messages.intro
14
+ end
15
+ end
16
+
17
+ require 'logix-toolkit/operations/or'
18
+ require 'logix-toolkit/operations/and'
19
+ require 'logix-toolkit/operations/implication'
20
+
21
+ puts "The gem was successfully required use \"LogixToolkit.help\" to see an intoduction
22
+ and a tutorial about how you should use the library"
@@ -0,0 +1,22 @@
1
+ require 'logix-toolkit/core/errors'
2
+
3
+ #The Boolean verifier class, it's task is to make sure that user input is a boolean
4
+ #otherwise it throws an error
5
+ class BooleanVerifier
6
+ #verifies the validity of a boolean
7
+ def self.verify? object, *more_args
8
+ if object == true or object == false
9
+ more_args.each do |i|
10
+ if i == true or i == false
11
+ #Do nothing continue the check unless an invalid argument was found
12
+ else
13
+ ErrorsAndExceptions.object_not_boolean i
14
+ end
15
+ end
16
+ #finally return true
17
+ return true
18
+ else
19
+ ErrorsAndExceptions.object_not_boolean object
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ #This class stores the Errors and exceptions messages
2
+ class ErrorsAndExceptions
3
+ #throws an error if the object from user input is not a boolean
4
+ def self.object_not_boolean object
5
+ puts "ERROR: Object \"#{object}\" was not recognized as a boolean no logical operations could be performed"
6
+ end
7
+ #throws an error if the logical functions couldn't be performed for any reason
8
+ def self.couldnt_be_performed
9
+ puts "ERROR: Operation could not be performed"
10
+ end
11
+ #throws an error if function is currently unavailable
12
+ def self.operation_unavailable_atm
13
+ puts "Sorry, the current operation is unavailable at the moment"
14
+ end
15
+ end
@@ -0,0 +1,57 @@
1
+ #This class stores functions that display long messages such as
2
+ #introductions tutorials and such
3
+ class Messages
4
+ #Displays an introductory message
5
+ def self.intro
6
+ puts "
7
+ ==============================================================
8
+ Hello there, logix toolkit user! and thank you for using the
9
+ logix-toolkit library here is an introduction to the
10
+ library and how you should use it
11
+ ==============================================================
12
+ ABOUT:
13
+ This library is a small project that its target is to add
14
+ and integrate a lot of boolean algebra operations to the Ruby
15
+ programming language
16
+ it's meant to be used by anyone from mathematicians and
17
+ students that want an easy tool to make boolean algebra
18
+ calculations much more complicated than the core
19
+ AND, OR operations that most programming languages support
20
+ to game developers that are willing to integrate logic into
21
+ their games and focus on their game without having to mess
22
+ with logic code
23
+ or just by anyone interested in logic and boolean
24
+ algebra.
25
+
26
+ USAGE:
27
+ now the usage of the library is fairly simple
28
+ all the logic functions at the moment are simple
29
+ almost every command you will use here will be .check?
30
+ but here is the catch everything is used here with a
31
+ namespace seperator (this thing: \"::\")
32
+ meaning that if you want to access the AND operation
33
+ you will type in the following code:
34
+ LogixToolkit::Operations::And.check? true, false
35
+ and it will return the value of the operation
36
+ (in this example: false)
37
+ same goes for any other operation Or, Implication,
38
+ Logic gates and so on...
39
+ but then what if you need to do calculations
40
+ for multiple booleans say I want to check the
41
+ OR value for 4 booleans?
42
+ it's simple just use the check[NUMBER]? function
43
+ Example:
44
+ LogixToolkit::Operations::Or.check4? true, true, false, true
45
+ simple enough right?
46
+ NOTE: I still haven't found a way to make the function accept
47
+ an (X) amount of variables so now the check method supports
48
+ only up to check5?
49
+
50
+ That's it you're good to go, now go and explore the
51
+ magnificent world of boolean algebra
52
+
53
+ whenever you need to see this message again type
54
+ LogixToolkit.help
55
+ "
56
+ end
57
+ end
@@ -0,0 +1,54 @@
1
+ require 'logix-toolkit/core/errors'
2
+ require 'logix-toolkit/core/boolean_verifier'
3
+ require 'logix-toolkit'
4
+
5
+ #The "and" class used to define and operations (e.g A ∧ B)
6
+ class LogixToolkit::Operations::And
7
+ def self.check? arg0, arg1
8
+ if BooleanVerifier.verify? arg0, arg1
9
+ if arg0 and arg1
10
+ return true
11
+ else
12
+ return false
13
+ end
14
+ else
15
+ ErrorsAndExceptions.couldnt_be_performed
16
+ end
17
+ end
18
+
19
+ def self.check3? arg0, arg1, arg2
20
+ if BooleanVerifier.verify? arg0, arg1, arg2
21
+ if arg0 and arg1 and arg2
22
+ return true
23
+ else
24
+ return false
25
+ end
26
+ else
27
+ ErrorsAndExceptions.couldnt_be_performed
28
+ end
29
+ end
30
+
31
+ def self.check4? arg0, arg1, arg2, arg3
32
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3
33
+ if arg0 and arg1 and arg2 and arg3
34
+ return true
35
+ else
36
+ return false
37
+ end
38
+ else
39
+ ErrorsAndExceptions.couldnt_be_performed
40
+ end
41
+ end
42
+
43
+ def self.check5? arg0, arg1, arg2, arg3, arg4
44
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3, arg4
45
+ if arg0 and arg1 and arg2 and arg3 and arg4
46
+ return true
47
+ else
48
+ return false
49
+ end
50
+ else
51
+ ErrorsAndExceptions.couldnt_be_performed
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,42 @@
1
+ require 'logix-toolkit/core/errors'
2
+ require 'logix-toolkit/core/boolean_verifier'
3
+ require 'logix-toolkit'
4
+
5
+ #The "implication" class used to define implication operations (e.g A → B)
6
+ class LogixToolkit::Operations::Implication
7
+ def self.check? arg0, arg1
8
+ if BooleanVerifier.verify? arg0, arg1
9
+ if !arg0 or arg1
10
+ return true
11
+ else
12
+ return false
13
+ end
14
+ else
15
+ ErrorsAndExceptions.couldnt_be_performed
16
+ end
17
+ end
18
+
19
+ def self.check3? arg0, arg1, arg2
20
+ if BooleanVerifier.verify? arg0, arg1, arg2
21
+ ErrorsAndExceptions.operation_unavailable_atm
22
+ else
23
+ ErrorsAndExceptions.couldnt_be_performed
24
+ end
25
+ end
26
+
27
+ def self.check4? arg0, arg1, arg2, arg3
28
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3
29
+ ErrorsAndExceptions.operation_unavailable_atm
30
+ else
31
+ ErrorsAndExceptions.couldnt_be_performed
32
+ end
33
+ end
34
+
35
+ def self.check5? arg0, arg1, arg2, arg3
36
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3
37
+ ErrorsAndExceptions.operation_unavailable_atm
38
+ else
39
+ ErrorsAndExceptions.couldnt_be_performed
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,55 @@
1
+ require 'logix-toolkit/core/errors'
2
+ require 'logix-toolkit/core/boolean_verifier'
3
+ require 'logix-toolkit'
4
+
5
+ #The "or" class used to define or operations (e.g A ∨ B)
6
+ class LogixToolkit::Operations::Or
7
+ #checks the value of A ∨ B
8
+ def self.check? arg0, arg1
9
+ if BooleanVerifier.verify? arg0,arg1
10
+ if arg0 or arg1
11
+ return true
12
+ else
13
+ return false
14
+ end
15
+ else
16
+ ErrorsAndExceptions.couldnt_be_performed
17
+ end
18
+ end
19
+
20
+ def self.check3? arg0, arg1, arg2
21
+ if BooleanVerifier.verify? arg0, arg1, arg2
22
+ if arg0 or arg1 or arg2
23
+ return true
24
+ else
25
+ return false
26
+ end
27
+ else
28
+ ErrorsAndExceptions.couldnt_be_performed
29
+ end
30
+ end
31
+
32
+ def self.check4? arg0, arg1, arg2, arg3
33
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3
34
+ if arg0 or arg1 or arg2 or arg3
35
+ return true
36
+ else
37
+ return false
38
+ end
39
+ else
40
+ ErrorsAndExceptions.couldnt_be_performed
41
+ end
42
+ end
43
+
44
+ def self.check5? arg0, arg1, arg2, arg3, arg4
45
+ if BooleanVerifier.verify? arg0, arg1, arg2, arg3, arg4
46
+ if arg0 or arg1 or arg2 or arg3 or arg4
47
+ return true
48
+ else
49
+ return false
50
+ end
51
+ else
52
+ ErrorsAndExceptions.couldnt_be_performed
53
+ end
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logix_toolkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elian(Shadi) Kamal
8
+ - Matan Haller
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-08-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: "A boolean algebra tools library for ruby that adds logic functions and
15
+ operations \n(currently limited to AND, OR, CONDITIONAL operations with multiple
16
+ parameters)\nmore functionality will be added later.\ninstall via \"gem install
17
+ logix-toolkit\"\nrequire using \"require 'logix-toolkit'\"\nsee usage via the documentation
18
+ or via typing \"LogixToolkit.help\" in the console\nafter requiring the library"
19
+ email: shady3300@outlook.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - lib/logix-toolkit.rb
25
+ - lib/logix-toolkit/core/boolean_verifier.rb
26
+ - lib/logix-toolkit/core/errors.rb
27
+ - lib/logix-toolkit/core/messages.rb
28
+ - lib/logix-toolkit/operations/and.rb
29
+ - lib/logix-toolkit/operations/implication.rb
30
+ - lib/logix-toolkit/operations/or.rb
31
+ homepage: http://rubygems.org/gems/logixtoolkit
32
+ licenses:
33
+ - MIT
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.9.2
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 2.4.8
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: A logic tools library for ruby
55
+ test_files: []
56
+ has_rdoc: