calculator7 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/calculator7.rb +28 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 597d714970164868c27ee146da78188dafd0f43c
|
4
|
+
data.tar.gz: c4df2253ed578c29c52f5f08ef481229532ab36f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1fc2193282bbef7f920c4b25d7f594f5e36018600416fd584441557d39e1d3b0dda725af872c6fa0d228d51c621d2f49856da10f3d8405e971e6512c29f0d53
|
7
|
+
data.tar.gz: 47ed9f7ba6edc6e35080afc2c31c7a62fce732ade77f457452e3dfccc484f27de6898a29f18d8223af45e87181b3a04093418e26d9a923e6ce173120c5bfd25e
|
data/lib/calculator7.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
class Calculator7
|
2
|
+
def self.hi
|
3
|
+
puts "Hello world!"
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.execute(str)
|
7
|
+
enable = true
|
8
|
+
str.chars.each do |c|
|
9
|
+
if !"+-*/0123456789 ".include?(c)
|
10
|
+
enable = false
|
11
|
+
break
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
ret = nil
|
16
|
+
if enable
|
17
|
+
begin
|
18
|
+
ret = '=' + eval(str).to_s
|
19
|
+
rescue SyntaxError
|
20
|
+
# do nothing
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
return ret
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: calculator7
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jianfeng
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-22 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple calculator
|
14
|
+
email: tujf.cn@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/calculator7.rb
|
20
|
+
homepage: http://rubygems.org/gems/calculator7
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.1.11
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Calculator7
|
44
|
+
test_files: []
|