maths 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.
data/bin/maths CHANGED
@@ -30,7 +30,14 @@ while command = Readline.readline(prompt, true)
30
30
  puts
31
31
  else
32
32
  begin
33
- puts "= #{parser.parse(command)}"
33
+ result = parser.parse(command)
34
+
35
+ if result.frac == 0
36
+ output = result.to_i.to_s
37
+ else
38
+ output = result.to_s("F")
39
+ end
40
+ puts "= #{output}"
34
41
  rescue ParseError
35
42
  puts $!
36
43
  end
data/lib/maths/brain.rb CHANGED
@@ -12,7 +12,7 @@ module Maths
12
12
 
13
13
  # Public: Looks up data
14
14
  def self.lookup(variable)
15
- read[variable]
15
+ BigDecimal.new(read[variable])
16
16
  end
17
17
 
18
18
  # Public: The file we're using to store our memories
data/lib/maths/calc.y CHANGED
@@ -41,9 +41,9 @@ module Maths
41
41
  when /\A[A-Za-z]+[0-9]*/
42
42
  @q.push [:VARIABLE, $&]
43
43
  when /\A\d+\.\d+/
44
- @q.push [:FLOAT, $&.to_f]
44
+ @q.push [:FLOAT, BigDecimal.new($&)]
45
45
  when /\A\d+/
46
- @q.push [:NUMBER, $&.to_i]
46
+ @q.push [:NUMBER, BigDecimal.new($&)]
47
47
  when /\A.|\n/o
48
48
  s = $&
49
49
  @q.push [s, s]
@@ -57,11 +57,6 @@ module Maths
57
57
  def next_token
58
58
  @q.shift
59
59
  end
60
-
61
- def assign(val)
62
- puts "Assigning: #{val}"
63
- val
64
- end
65
60
 
66
61
  ---- footer
67
62
  end
data/lib/maths/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Maths
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/maths.rb CHANGED
@@ -2,7 +2,8 @@ $:.unshift(File.dirname(__FILE__))
2
2
 
3
3
  require "readline"
4
4
  require "json"
5
+ require "bigdecimal"
5
6
 
6
7
  require "maths/version"
7
8
  require "maths/calc"
8
- require "maths/brain"
9
+ require "maths/brain"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maths
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: