epimath100 1.6.2 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epimath100.rb +1 -1
- data/lib/epimath100/line.class.rb +1 -1
- data/lib/epimath100/matrix.class.rb +1 -1
- data/lib/epimath100/point.class.rb +1 -1
- data/lib/epimath100/polynomial.class.rb +1 -1
- data/lib/epimath100/vector.class.rb +1 -1
- metadata +23 -5
- data/lib/epimath100/error.class.rb +0 -118
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dced7e03f99893cc4fc175ce6450960c870df29d
|
4
|
+
data.tar.gz: 64f509eb9b8353fec2fc52112331af6a7e60653d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c277939219ffa8fbd79eb4b3ce2b78165cf1ea3c65a613185d9d075b802252d993af5a4df4b9b99ba351695f21715c5730d8540c2baa0d1eeeeb19f6d8572306
|
7
|
+
data.tar.gz: c6347cdd47677cf25fb1840b6826e8d52270859579a2514c946c3e6970b7c33ba52b2adb9baca9a4867e7c62d22b2476d44240032985a6b77d71a405c7d81970
|
data/lib/epimath100.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epimath100
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- poulet_a
|
@@ -11,13 +11,32 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-02-
|
15
|
-
dependencies:
|
14
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: myerror
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.0
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 1.0.0
|
26
|
+
type: :runtime
|
27
|
+
prerelease: false
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.0.0
|
16
36
|
description: A simple hello world gem
|
17
37
|
email:
|
18
38
|
- poulet_a@epitech.eu
|
19
39
|
- - lib/epimath100.rb
|
20
|
-
- lib/epimath100/error.class.rb
|
21
40
|
- lib/epimath100/line.class.rb
|
22
41
|
- lib/epimath100/matrix.class.rb
|
23
42
|
- lib/epimath100/point.class.rb
|
@@ -28,7 +47,6 @@ extensions: []
|
|
28
47
|
extra_rdoc_files: []
|
29
48
|
files:
|
30
49
|
- lib/epimath100.rb
|
31
|
-
- lib/epimath100/error.class.rb
|
32
50
|
- lib/epimath100/line.class.rb
|
33
51
|
- lib/epimath100/matrix.class.rb
|
34
52
|
- lib/epimath100/point.class.rb
|
@@ -1,118 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
# Error is a class to display and manage your simple errors
|
4
|
-
class Error
|
5
|
-
ERR_HIGH = "Fatal Error"
|
6
|
-
ERR_MEDIUM = "Error"
|
7
|
-
ERR_LOW = "Warning"
|
8
|
-
ERR_DEFAULT = "Default"
|
9
|
-
ERR_COLOR_RED = "0;31"
|
10
|
-
ERR_COLOR_GREEN = "0;32"
|
11
|
-
ERR_COLOR_YELLOW = "1;33"
|
12
|
-
ERR_COLOR_BLUE = "0;34"
|
13
|
-
ERR_COLOR_ORANGE = "0;33"
|
14
|
-
@@errors = 0
|
15
|
-
@@error_default = ERR_HIGH
|
16
|
-
|
17
|
-
# The function will check if the specified value can be converted to a Numerical value.
|
18
|
-
# == Parameters:
|
19
|
-
# type::
|
20
|
-
# ...
|
21
|
-
# == Returns:
|
22
|
-
# True/False
|
23
|
-
def self.isnum? string
|
24
|
-
if string.is_a?String and string != nil
|
25
|
-
if string.to_i.to_s == string or string.to_f.to_s == string
|
26
|
-
return true
|
27
|
-
elsif string.to_i.to_s == string[1..-1] or string.to_f.to_s == string[1..-1]
|
28
|
-
true
|
29
|
-
else
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
elsif string.is_a?Numeric
|
33
|
-
true
|
34
|
-
else
|
35
|
-
Error.call "'#{string}' is not a String"
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# return @@error_default
|
41
|
-
def self.default
|
42
|
-
return @@error_default
|
43
|
-
end
|
44
|
-
|
45
|
-
# set @@error_default
|
46
|
-
def self.default=(level)
|
47
|
-
if level != Error::ERR_HIGH and level != Error::ERR_MEDIUM and level != Error::ERR_LOW
|
48
|
-
self.call "Error::default= : error level invalid", Error::ERR_MEDIUM
|
49
|
-
@@error_default = Error::ERR_HIGH
|
50
|
-
else
|
51
|
-
@@error_default = level
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# "call" is a function you can acces with:
|
56
|
-
# Error.call "message", ERR_LEVEL
|
57
|
-
# == The error's levels are :
|
58
|
-
# * ERR_HIGH
|
59
|
-
# * ERR_MEDIUM
|
60
|
-
# * ERR_LOW
|
61
|
-
# * ERR_DEFAULT
|
62
|
-
# The error's level influence the color (visibility) and defined if the programm must exit.
|
63
|
-
# An ERR_HIGH is only to call exit and stop the programm. So be carrefull.
|
64
|
-
# ERR_MEDIUM and ERR_LOW will just display the message and no more.
|
65
|
-
# ERR_HIGH is the default value, you can change it if yo want by :
|
66
|
-
# Error.default = Error::ERR_X
|
67
|
-
#
|
68
|
-
# == Parameters:
|
69
|
-
# m::
|
70
|
-
# A String that will be display. You don't need to specify the prefix ("Error :") or the final "."
|
71
|
-
# level::
|
72
|
-
# A optional parameter, wich influence the degree of the error. Default is ERR_HIGH, will kill your programm
|
73
|
-
# So, be carrefull. You can change this value. It may be ERR_HIGH (Default), ERR_MEDIUM, ERR_LOW
|
74
|
-
#
|
75
|
-
# == Returns:
|
76
|
-
# nil
|
77
|
-
def self.call m, level=Error::ERR_DEFAULT
|
78
|
-
# define the default value if level is set by "Default"
|
79
|
-
if level == Error::ERR_DEFAULT
|
80
|
-
level = @@error_default
|
81
|
-
end
|
82
|
-
|
83
|
-
if level != Error::ERR_HIGH and level != Error::ERR_MEDIUM and level != Error::ERR_LOW
|
84
|
-
self.call "Error::call : error level invalid", Error::ERR_MEDIUM
|
85
|
-
end
|
86
|
-
|
87
|
-
#message color
|
88
|
-
if level == Error::ERR_HIGH
|
89
|
-
color = Error::ERR_COLOR_RED
|
90
|
-
elsif level == Error::ERR_MEDIUM
|
91
|
-
color = Error::ERR_COLOR_ORANGE
|
92
|
-
elsif level == Error::ERR_LOW
|
93
|
-
color = Error::ERR_COLOR_YELLOW
|
94
|
-
end
|
95
|
-
|
96
|
-
#message display
|
97
|
-
if level == Error::ERR_HIGH
|
98
|
-
puts "\033[#{color}m#{level} : #{m}.\033[00m"
|
99
|
-
exit
|
100
|
-
elsif level == Error::ERR_MEDIUM
|
101
|
-
puts "\033[#{color}m#{level} : #{m}.\033[00m"
|
102
|
-
elsif level == Error::ERR_LOW
|
103
|
-
puts "\033[#{color}m#{level} : #{m}.\033[00m"
|
104
|
-
end
|
105
|
-
|
106
|
-
@@errors += 1
|
107
|
-
return self
|
108
|
-
end
|
109
|
-
|
110
|
-
# == Parameters:
|
111
|
-
# nothing::
|
112
|
-
#
|
113
|
-
# == Returns:
|
114
|
-
# Integer which contains the numbr of errors called
|
115
|
-
def self.errors
|
116
|
-
@@errors
|
117
|
-
end
|
118
|
-
end
|