discrete_math 0.0.1
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/discrete_math.rb +46 -0
- data/lib/helpers/math/math_helpers.rb +5 -0
- data/lib/modules/discrete_math_topics.rb +40 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 547523107244276837980865ea0aa6f4d9917c4a
|
4
|
+
data.tar.gz: acb1f186f0c89c32c1f2890a21a14e723ecdad49
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 318e91ef8c4c907c7fc3d290ade57a5356d0f0896adb14e690ce64e3726655a6cc381442a029c34821b4194e3e84fce1adac85b2d8801d9a225f60b30357b24b
|
7
|
+
data.tar.gz: 97eb4a8fb0a2c1aaa752ee1f623824eafccab1aba942076f72e89e2011317f55f9a70d2a62d96c4f95c28ddfe70c1570fa8402c240b447a79914907fed123301
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative './modules/discrete_math_topics'
|
2
|
+
|
3
|
+
module DiscreteMath
|
4
|
+
include DiscreteMathTopics::PreliminaryMath # AbsoluteValuesDemo
|
5
|
+
include DiscreteMathTopics::PreliminaryMath::AbsoluteValuesDemo::LocationConfig # @@location_coordinates
|
6
|
+
|
7
|
+
def self.demo_power_of
|
8
|
+
location_first = AbsoluteValuesDemo::Location.new(@@location_coordinates[:sydney])
|
9
|
+
location_second = AbsoluteValuesDemo::Location.new(@@location_coordinates[:melbourne])
|
10
|
+
route_first = AbsoluteValuesDemo::Route.new(location_first, location_second)
|
11
|
+
puts "=====> Demo Power Of: route first distance is: #{route_first.distance}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Menu
|
16
|
+
include DiscreteMathTopics::PreliminaryMath::AbsoluteValuesDemo::LocationConfig # @@location_coordinates
|
17
|
+
|
18
|
+
USER_OPTIONS = {
|
19
|
+
"1": :demo_power_of
|
20
|
+
}
|
21
|
+
|
22
|
+
def self.request_user_choice_demo
|
23
|
+
user_choice = ""
|
24
|
+
while not USER_OPTIONS.keys.include? user_choice.to_i
|
25
|
+
system('clear')
|
26
|
+
if user_choice == "invalid"
|
27
|
+
puts "== Invalid option chosen. Try again ==\n"
|
28
|
+
end
|
29
|
+
puts """
|
30
|
+
Select demo number to run or 'q' to quit:\n
|
31
|
+
1) Demo power of
|
32
|
+
"""
|
33
|
+
user_choice = gets.chomp
|
34
|
+
if user_choice == "1"
|
35
|
+
DiscreteMath.demo_power_of
|
36
|
+
break
|
37
|
+
elsif user_choice == "q"
|
38
|
+
break
|
39
|
+
else
|
40
|
+
user_choice = "invalid"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Menu.request_user_choice_demo
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../helpers/math/math_helpers'
|
2
|
+
|
3
|
+
# DiscreteMath::Preliminary
|
4
|
+
module DiscreteMathTopics
|
5
|
+
module PreliminaryMath
|
6
|
+
module AbsoluteValuesDemo
|
7
|
+
|
8
|
+
module LocationConfig
|
9
|
+
@@location_coordinates = {
|
10
|
+
sydney: { x: -100, y: -100 },
|
11
|
+
brisbane: { x: 100, y: 100 },
|
12
|
+
melbourne: { x: 200, y: 200 }
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
class Location
|
17
|
+
attr_accessor :coordinates
|
18
|
+
|
19
|
+
def initialize(coordinates)
|
20
|
+
@coordinates = coordinates
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Route
|
25
|
+
attr_accessor :distance
|
26
|
+
|
27
|
+
def initialize(start_location, finish_location)
|
28
|
+
@start_location = start_location
|
29
|
+
@finish_location = finish_location
|
30
|
+
end
|
31
|
+
|
32
|
+
def distance
|
33
|
+
dist_x = @start_location.coordinates[:x] - @finish_location.coordinates[:x]
|
34
|
+
dist_y = @start_location.coordinates[:y] - @finish_location.coordinates[:y]
|
35
|
+
dist_total = MathHelpers.pythagoras_theorem(dist_x, dist_y)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: discrete_math
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke Schoen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A discrete math gem
|
14
|
+
email: luke.schoen@coderacademy.edu.au
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/discrete_math.rb
|
20
|
+
- lib/helpers/math/math_helpers.rb
|
21
|
+
- lib/modules/discrete_math_topics.rb
|
22
|
+
homepage: http://rubygems.org/gems/discrete_math
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.6.13
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Discrete Math
|
46
|
+
test_files: []
|