math_expression 0.0.1 → 0.0.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.
Files changed (4) hide show
  1. data/README.rdoc +95 -0
  2. data/lib/Expression/version.rb +1 -1
  3. metadata +2 -2
  4. data/README.md +0 -36
@@ -0,0 +1,95 @@
1
+ = Expression
2
+
3
+ Mathematical expression calculator. Use this gem as a calculator.
4
+
5
+ == Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'Expression'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install Expression
18
+
19
+ == Usage
20
+
21
+ Initialize a variable:
22
+
23
+ expr = MathExpression.new
24
+
25
+ and then it is just:
26
+
27
+ expr.eval(Your_expression)
28
+
29
+ supported functions:
30
+
31
+ * Basic arithmetics
32
+ * exponentiation
33
+
34
+ expr.eval('6^3')
35
+
36
+ * factorial
37
+
38
+ expr.eval('5!')
39
+ * modulo operation:
40
+
41
+ expr.eval('9 % 5')
42
+ * floating numbers
43
+ * trigonometric identities (cos, sin, tan, cosh, sinh, tanh) and their inverses (by prefixing any of them by 'arc' e.g: arccos)
44
+ * exponential: (exp(x) return e to the power of x)
45
+
46
+ expr.eval('exp(2)')
47
+
48
+ * logarithm:
49
+
50
+ * General: you can use <tt>log{base}(number)</tt> e.g:
51
+
52
+ expr.eval('log2(12)')
53
+
54
+ returns the result of calling log of base 2 for the number 12.
55
+
56
+ expr.eval('log20(123)')
57
+
58
+ etc
59
+
60
+
61
+ * when you omit the base, the default is base 10 i.e:
62
+
63
+ expr.eval('log(23)')
64
+
65
+ is the same as
66
+
67
+
68
+ expr.eval('log10(23)')
69
+
70
+
71
+ * for base 'e' you can use natural logarithm:
72
+
73
+ expr.eval('ln(21)')
74
+
75
+
76
+ * root functions:
77
+
78
+ * square root:
79
+
80
+ expr.eval('sqrt(21)')
81
+
82
+ * for other bases use <tt>root{base}(number)</tt>:
83
+
84
+ expr.eval('root3(12)')
85
+
86
+
87
+
88
+
89
+ == Contributing
90
+
91
+ 1. Fork it
92
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
93
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
94
+ 4. Push to the branch (`git push origin my-new-feature`)
95
+ 5. Create new Pull Request
@@ -1,3 +1,3 @@
1
1
  module Expression
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math_expression
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -54,7 +54,7 @@ files:
54
54
  - Expression.gemspec
55
55
  - Gemfile
56
56
  - LICENSE.txt
57
- - README.md
57
+ - README.rdoc
58
58
  - Rakefile
59
59
  - lib/Expression.rb
60
60
  - lib/Expression/getters.rb
data/README.md DELETED
@@ -1,36 +0,0 @@
1
- # Expression
2
-
3
- Mathematical expression calculator. Use this gem as a calculator.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'Expression'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install Expression
18
-
19
- ## Usage
20
-
21
- Initialize a variable:
22
-
23
- some_var = MathExpression.new
24
-
25
- and then it is just:
26
-
27
- some_var.eval(Your_expression)
28
-
29
-
30
- ## Contributing
31
-
32
- 1. Fork it
33
- 2. Create your feature branch (`git checkout -b my-new-feature`)
34
- 3. Commit your changes (`git commit -am 'Add some feature'`)
35
- 4. Push to the branch (`git push origin my-new-feature`)
36
- 5. Create new Pull Request