From d46088e5d7a18b1b4cb24fabab85451c21f96999 Mon Sep 17 00:00:00 2001 From: Christopher Rankin Date: Wed, 10 Apr 2013 16:04:02 -0500 Subject: [PATCH 1/9] Implemented EXP, INT, and MONTH functions --- Gemfile | 3 ++- spec/excel/excel_functions/exp_spec.rb | 29 +++++++++++++++++++++ spec/excel/excel_functions/int_spec.rb | 33 ++++++++++++++++++++++++ spec/excel/excel_functions/month_spec.rb | 25 ++++++++++++++++++ src/compile/ruby/map_formulae_to_ruby.rb | 3 +++ src/excel/excel_functions.rb | 6 +++++ src/excel/excel_functions/exp.rb | 11 ++++++++ src/excel/excel_functions/int.rb | 11 ++++++++ src/excel/excel_functions/month.rb | 16 ++++++++++++ 9 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 spec/excel/excel_functions/exp_spec.rb create mode 100644 spec/excel/excel_functions/int_spec.rb create mode 100644 spec/excel/excel_functions/month_spec.rb create mode 100644 src/excel/excel_functions/exp.rb create mode 100644 src/excel/excel_functions/int.rb create mode 100644 src/excel/excel_functions/month.rb diff --git a/Gemfile b/Gemfile index df33808..eabd52f 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,9 @@ source 'http://rubygems.org' gem 'nokogiri' gem 'ffi' gem 'rubypeg' +gem 'active_support' group :test do gem 'ZenTest' gem 'rspec' -end \ No newline at end of file +end diff --git a/spec/excel/excel_functions/exp_spec.rb b/spec/excel/excel_functions/exp_spec.rb new file mode 100644 index 0000000..1824741 --- /dev/null +++ b/spec/excel/excel_functions/exp_spec.rb @@ -0,0 +1,29 @@ +require_relative '../../spec_helper.rb' + +describe "ExcelFunctions: EXP" do + + it "should return the constant e when given a power of 1" do + FunctionTest.exp(1).should == Math::E + end + + it "should return the the square of constant e when given a power of 2 (7.3890560989306495)" do + FunctionTest.exp(2).should == Math::E ** 2 + end + + it "should return an error when given inappropriate arguments" do + FunctionTest.exp("Asdasddf").should == :error + end + + it "should treat nil as zero" do + FunctionTest.exp(nil).should == 0 + end + + it "should return an error if an argument is an error" do + FunctionTest.exp(:error).should == :error + end + + it "should be in the list of functions that can be mapped to ruby" do + MapFormulaeToRuby::FUNCTIONS['EXP'].should == 'exp' + end + +end diff --git a/spec/excel/excel_functions/int_spec.rb b/spec/excel/excel_functions/int_spec.rb new file mode 100644 index 0000000..e9d7f10 --- /dev/null +++ b/spec/excel/excel_functions/int_spec.rb @@ -0,0 +1,33 @@ +require_relative '../../spec_helper.rb' + +describe "ExcelFunctions: INT" do + + it "should return 1 rounded to lowest integer (1.49)" do + FunctionTest.int(1.49).should == 1 + end + + it "should return 3 rounded to lowest integer (3.0723)" do + FunctionTest.int(3).should == 3 + end + + it "should return 7 rounded to lowest integer (7.9999999999)" do + FunctionTest.int(7).should == 7 + end + + it "should return an error when given inappropriate arguments" do + FunctionTest.int("Asdasddf").should == :error + end + + it "should treat nil as zero" do + FunctionTest.int(nil).should == 0 + end + + it "should return an error if an argument is an error" do + FunctionTest.int(:error).should == :error + end + + it "should be in the list of functions that can be mapped to ruby" do + MapFormulaeToRuby::FUNCTIONS['INT'].should == 'int' + end + +end diff --git a/spec/excel/excel_functions/month_spec.rb b/spec/excel/excel_functions/month_spec.rb new file mode 100644 index 0000000..ee6038e --- /dev/null +++ b/spec/excel/excel_functions/month_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../spec_helper.rb' + +describe "ExcelFunctions: MONTH" do + + it "should return 3 when date is 03/26/2013 (serial: 41359)" do + FunctionTest.month(41359).should == 3 + end + + it "should return an error when given inappropriate arguments" do + FunctionTest.month("Asdasddf").should == :error + end + + it "should treat nil as zero" do + FunctionTest.month(nil).should == 0 + end + + it "should return an error if an argument is an error" do + FunctionTest.month(:error).should == :error + end + + it "should be in the list of functions that can be mapped to ruby" do + MapFormulaeToRuby::FUNCTIONS['MONTH'].should == 'month' + end + +end diff --git a/src/compile/ruby/map_formulae_to_ruby.rb b/src/compile/ruby/map_formulae_to_ruby.rb index 5c050fd..c6b2c49 100644 --- a/src/compile/ruby/map_formulae_to_ruby.rb +++ b/src/compile/ruby/map_formulae_to_ruby.rb @@ -23,15 +23,18 @@ class MapFormulaeToRuby < MapValuesToRuby 'COSH' => 'cosh', 'COUNT' => 'count', 'COUNTA' => 'counta', + 'EXP' => 'exp', 'FIND' => 'find', 'IF' => 'excel_if', 'IFERROR' => 'iferror', 'INDEX' => 'index', + 'INT' => 'int', 'LEFT' => 'left', 'MATCH' => 'excel_match', 'MAX' => 'max', 'MIN' => 'min', 'MOD' => 'mod', + 'MONTH' => 'month', 'PI' => 'pi', 'PMT' => 'pmt', 'ROUND' => 'round', diff --git a/src/excel/excel_functions.rb b/src/excel/excel_functions.rb index c49f8d5..ad74e41 100644 --- a/src/excel/excel_functions.rb +++ b/src/excel/excel_functions.rb @@ -82,3 +82,9 @@ module ExcelFunctions require_relative 'excel_functions/rounddown' require_relative 'excel_functions/negative' + +require_relative 'excel_functions/exp' + +require_relative 'excel_functions/int' + +require_relative 'excel_functions/month' diff --git a/src/excel/excel_functions/exp.rb b/src/excel/excel_functions/exp.rb new file mode 100644 index 0000000..56084ff --- /dev/null +++ b/src/excel/excel_functions/exp.rb @@ -0,0 +1,11 @@ +module ExcelFunctions + + def exp(a) + return 0 if a.nil? + return :error unless a.is_a? Numeric + a ||= 0 + result = Math::E ** a + return result + end + +end diff --git a/src/excel/excel_functions/int.rb b/src/excel/excel_functions/int.rb new file mode 100644 index 0000000..ccf270a --- /dev/null +++ b/src/excel/excel_functions/int.rb @@ -0,0 +1,11 @@ +module ExcelFunctions + + def int(a) + return 0 if a.nil? + return :error unless a.is_a? Numeric + a ||= 0 + result = a.to_s.split('.')[0].to_i + return result + end + +end diff --git a/src/excel/excel_functions/month.rb b/src/excel/excel_functions/month.rb new file mode 100644 index 0000000..6fc88e8 --- /dev/null +++ b/src/excel/excel_functions/month.rb @@ -0,0 +1,16 @@ +require 'date' +require 'active_support' +require 'active_support/core_ext' + +module ExcelFunctions + + def month(a) + return 0 if a.nil? + return :error unless a.is_a? Numeric + a ||= 0 + + result = (Date.civil(1899, 12, 31) + (a - 1).days).month + return result + end + +end From 653f7e590e4ed57ae94d14d7451642a2c98beb48 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Wed, 8 May 2013 15:41:56 -0500 Subject: [PATCH 2/9] or and today added ,specs not finished --- Gemfile.lock | 8 ++++++++ spec/excel/excel_functions/or_spec.rb | 25 ++++++++++++++++++++++++ spec/excel/excel_functions/today_spec.rb | 25 ++++++++++++++++++++++++ src/compile/ruby/map_formulae_to_ruby.rb | 2 ++ src/excel/excel_functions.rb | 4 ++++ src/excel/excel_functions/or.rb | 12 ++++++++++++ src/excel/excel_functions/today.rb | 7 +++++++ 7 files changed, 83 insertions(+) create mode 100644 spec/excel/excel_functions/or_spec.rb create mode 100644 spec/excel/excel_functions/today_spec.rb create mode 100644 src/excel/excel_functions/or.rb create mode 100644 src/excel/excel_functions/today.rb diff --git a/Gemfile.lock b/Gemfile.lock index 1916f71..90634d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,6 +2,9 @@ GEM remote: http://rubygems.org/ specs: ZenTest (4.6.2) + active_support (3.0.0) + activesupport (= 3.0.0) + activesupport (3.0.0) diff-lcs (1.1.3) ffi (1.0.11) nokogiri (1.5.0) @@ -13,12 +16,17 @@ GEM rspec-expectations (2.7.0) diff-lcs (~> 1.1.2) rspec-mocks (2.7.0) + rubypeg (0.0.4) + rubyscriptwriter + rubyscriptwriter (0.0.2) PLATFORMS ruby DEPENDENCIES ZenTest + active_support ffi nokogiri rspec + rubypeg diff --git a/spec/excel/excel_functions/or_spec.rb b/spec/excel/excel_functions/or_spec.rb new file mode 100644 index 0000000..5066929 --- /dev/null +++ b/spec/excel/excel_functions/or_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../spec_helper.rb' + +describe "ExcelFunctions: OR" do + + it "should return something when given appropriate arguments" do + FunctionTest.or(1).should == 1 + end + + it "should return an error when given inappropriate arguments" do + FunctionTest.or("Asdasddf").should == :value + end + + it "should treat nil as zero" do + FunctionTest.or(nil).should == 0 + end + + it "should return an error if an argument is an error" do + FunctionTest.or(:error).should == :error + end + + it "should be in the list of functions that can be mapped to ruby" do + MapFormulaeToRuby::FUNCTIONS['OR'].should == 'or' + end + +end diff --git a/spec/excel/excel_functions/today_spec.rb b/spec/excel/excel_functions/today_spec.rb new file mode 100644 index 0000000..323793b --- /dev/null +++ b/spec/excel/excel_functions/today_spec.rb @@ -0,0 +1,25 @@ +require_relative '../../spec_helper.rb' + +describe "ExcelFunctions: TODAY" do + + it "should return something when given appropriate arguments" do + FunctionTest.today(1).should == 1 + end + + it "should return an error when given inappropriate arguments" do + FunctionTest.today("Asdasddf").should == :value + end + + it "should treat nil as zero" do + FunctionTest.today(nil).should == 0 + end + + it "should return an error if an argument is an error" do + FunctionTest.today(:error).should == :error + end + + it "should be in the list of functions that can be mapped to ruby" do + MapFormulaeToRuby::FUNCTIONS['TODAY'].should == 'today' + end + +end diff --git a/src/compile/ruby/map_formulae_to_ruby.rb b/src/compile/ruby/map_formulae_to_ruby.rb index c6b2c49..24502b4 100644 --- a/src/compile/ruby/map_formulae_to_ruby.rb +++ b/src/compile/ruby/map_formulae_to_ruby.rb @@ -35,6 +35,7 @@ class MapFormulaeToRuby < MapValuesToRuby 'MIN' => 'min', 'MOD' => 'mod', 'MONTH' => 'month', + 'OR' => 'or', 'PI' => 'pi', 'PMT' => 'pmt', 'ROUND' => 'round', @@ -45,6 +46,7 @@ class MapFormulaeToRuby < MapValuesToRuby 'SUMIF' => 'sumif', 'SUMIFS' => 'sumifs', 'SUMPRODUCT' => 'sumproduct', + 'TODAY' => 'today', 'VLOOKUP' => 'vlookup', '^' => 'power' } diff --git a/src/excel/excel_functions.rb b/src/excel/excel_functions.rb index ad74e41..8dd6371 100644 --- a/src/excel/excel_functions.rb +++ b/src/excel/excel_functions.rb @@ -88,3 +88,7 @@ module ExcelFunctions require_relative 'excel_functions/int' require_relative 'excel_functions/month' + +require_relative 'excel_functions/or' + +require_relative 'excel_functions/today' diff --git a/src/excel/excel_functions/or.rb b/src/excel/excel_functions/or.rb new file mode 100644 index 0000000..a9c70f0 --- /dev/null +++ b/src/excel/excel_functions/or.rb @@ -0,0 +1,12 @@ +module ExcelFunctions + + def or(*args) + + args.each do |argument| + return true if argument + end + + return false + end + +end diff --git a/src/excel/excel_functions/today.rb b/src/excel/excel_functions/today.rb new file mode 100644 index 0000000..81f3531 --- /dev/null +++ b/src/excel/excel_functions/today.rb @@ -0,0 +1,7 @@ +module ExcelFunctions + + def today + return Time.now.strftime("%m/%d/%y") + end + +end From ceb63e00c75fc66f1577f012a6b57d42d559d0f9 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Wed, 8 May 2013 16:37:25 -0500 Subject: [PATCH 3/9] rename or ot excel_or so it doesn't suck --- src/compile/ruby/map_formulae_to_ruby.rb | 2 +- src/excel/excel_functions.rb | 2 +- src/excel/excel_functions/{or.rb => excel_or.rb} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/excel/excel_functions/{or.rb => excel_or.rb} (84%) diff --git a/src/compile/ruby/map_formulae_to_ruby.rb b/src/compile/ruby/map_formulae_to_ruby.rb index 24502b4..9f4e2b2 100644 --- a/src/compile/ruby/map_formulae_to_ruby.rb +++ b/src/compile/ruby/map_formulae_to_ruby.rb @@ -35,7 +35,7 @@ class MapFormulaeToRuby < MapValuesToRuby 'MIN' => 'min', 'MOD' => 'mod', 'MONTH' => 'month', - 'OR' => 'or', + 'OR' => 'excel_or', 'PI' => 'pi', 'PMT' => 'pmt', 'ROUND' => 'round', diff --git a/src/excel/excel_functions.rb b/src/excel/excel_functions.rb index 8dd6371..72c9d97 100644 --- a/src/excel/excel_functions.rb +++ b/src/excel/excel_functions.rb @@ -89,6 +89,6 @@ module ExcelFunctions require_relative 'excel_functions/month' -require_relative 'excel_functions/or' +require_relative 'excel_functions/excel_or' require_relative 'excel_functions/today' diff --git a/src/excel/excel_functions/or.rb b/src/excel/excel_functions/excel_or.rb similarity index 84% rename from src/excel/excel_functions/or.rb rename to src/excel/excel_functions/excel_or.rb index a9c70f0..9cdf1be 100644 --- a/src/excel/excel_functions/or.rb +++ b/src/excel/excel_functions/excel_or.rb @@ -1,6 +1,6 @@ module ExcelFunctions - def or(*args) + def excel_or(*args) args.each do |argument| return true if argument From b60ed03d8cafacbe7170ab2f807bae333a01eb16 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Thu, 9 May 2013 10:47:36 -0500 Subject: [PATCH 4/9] minor fix in excel equal so that b is to s'd bc it may not be a string --- src/excel/excel_functions/excel_equal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excel/excel_functions/excel_equal.rb b/src/excel/excel_functions/excel_equal.rb index 5ffac3a..d10ff73 100644 --- a/src/excel/excel_functions/excel_equal.rb +++ b/src/excel/excel_functions/excel_equal.rb @@ -10,7 +10,7 @@ def excel_equal?(a,b) case a when String - a.downcase == b.downcase + a.to_s.downcase == b.to_s.downcase else a == b end From fc4fe7c8197618272ba7c93b0871997921420bd0 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Thu, 9 May 2013 11:27:49 -0500 Subject: [PATCH 5/9] testing --- src/excel/excel_functions/excel_equal.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/excel/excel_functions/excel_equal.rb b/src/excel/excel_functions/excel_equal.rb index d10ff73..0d2b9fe 100644 --- a/src/excel/excel_functions/excel_equal.rb +++ b/src/excel/excel_functions/excel_equal.rb @@ -10,6 +10,7 @@ def excel_equal?(a,b) case a when String + p "-------------------------" a.to_s.downcase == b.to_s.downcase else a == b From b316033b4aea6fedde2a6a58bc7fad65e4f7766f Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Thu, 9 May 2013 11:42:23 -0500 Subject: [PATCH 6/9] i know i am right --- src/excel/excel_functions/excel_equal.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/src/excel/excel_functions/excel_equal.rb b/src/excel/excel_functions/excel_equal.rb index 0d2b9fe..d10ff73 100644 --- a/src/excel/excel_functions/excel_equal.rb +++ b/src/excel/excel_functions/excel_equal.rb @@ -10,7 +10,6 @@ def excel_equal?(a,b) case a when String - p "-------------------------" a.to_s.downcase == b.to_s.downcase else a == b From 86c9a1caa08711054b2fca6e38100a977877f190 Mon Sep 17 00:00:00 2001 From: bhgames Date: Tue, 9 Jul 2013 13:21:32 -0500 Subject: [PATCH 7/9] minor fix to equals so it converts b to a string if it isnt one before downcasing --- src/excel/excel_functions/excel_equal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excel/excel_functions/excel_equal.rb b/src/excel/excel_functions/excel_equal.rb index 5ffac3a..d10ff73 100644 --- a/src/excel/excel_functions/excel_equal.rb +++ b/src/excel/excel_functions/excel_equal.rb @@ -10,7 +10,7 @@ def excel_equal?(a,b) case a when String - a.downcase == b.downcase + a.to_s.downcase == b.to_s.downcase else a == b end From 3dd84b41a4a8eca07b0800beb0530d639405f77e Mon Sep 17 00:00:00 2001 From: bhgames Date: Tue, 9 Jul 2013 13:23:50 -0500 Subject: [PATCH 8/9] shit --- Gemfile | 3 +-- spec/excel/excel_functions/exp_spec.rb | 29 --------------------- spec/excel/excel_functions/int_spec.rb | 33 ------------------------ spec/excel/excel_functions/month_spec.rb | 25 ------------------ src/compile/ruby/map_formulae_to_ruby.rb | 5 ++-- src/excel/excel_functions.rb | 3 +++ src/excel/excel_functions/exp.rb | 11 -------- src/excel/excel_functions/int.rb | 11 -------- src/excel/excel_functions/month.rb | 16 ------------ 9 files changed, 7 insertions(+), 129 deletions(-) delete mode 100644 spec/excel/excel_functions/exp_spec.rb delete mode 100644 spec/excel/excel_functions/int_spec.rb delete mode 100644 spec/excel/excel_functions/month_spec.rb delete mode 100644 src/excel/excel_functions/exp.rb delete mode 100644 src/excel/excel_functions/int.rb delete mode 100644 src/excel/excel_functions/month.rb diff --git a/Gemfile b/Gemfile index eabd52f..df33808 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,8 @@ source 'http://rubygems.org' gem 'nokogiri' gem 'ffi' gem 'rubypeg' -gem 'active_support' group :test do gem 'ZenTest' gem 'rspec' -end +end \ No newline at end of file diff --git a/spec/excel/excel_functions/exp_spec.rb b/spec/excel/excel_functions/exp_spec.rb deleted file mode 100644 index 1824741..0000000 --- a/spec/excel/excel_functions/exp_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require_relative '../../spec_helper.rb' - -describe "ExcelFunctions: EXP" do - - it "should return the constant e when given a power of 1" do - FunctionTest.exp(1).should == Math::E - end - - it "should return the the square of constant e when given a power of 2 (7.3890560989306495)" do - FunctionTest.exp(2).should == Math::E ** 2 - end - - it "should return an error when given inappropriate arguments" do - FunctionTest.exp("Asdasddf").should == :error - end - - it "should treat nil as zero" do - FunctionTest.exp(nil).should == 0 - end - - it "should return an error if an argument is an error" do - FunctionTest.exp(:error).should == :error - end - - it "should be in the list of functions that can be mapped to ruby" do - MapFormulaeToRuby::FUNCTIONS['EXP'].should == 'exp' - end - -end diff --git a/spec/excel/excel_functions/int_spec.rb b/spec/excel/excel_functions/int_spec.rb deleted file mode 100644 index e9d7f10..0000000 --- a/spec/excel/excel_functions/int_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require_relative '../../spec_helper.rb' - -describe "ExcelFunctions: INT" do - - it "should return 1 rounded to lowest integer (1.49)" do - FunctionTest.int(1.49).should == 1 - end - - it "should return 3 rounded to lowest integer (3.0723)" do - FunctionTest.int(3).should == 3 - end - - it "should return 7 rounded to lowest integer (7.9999999999)" do - FunctionTest.int(7).should == 7 - end - - it "should return an error when given inappropriate arguments" do - FunctionTest.int("Asdasddf").should == :error - end - - it "should treat nil as zero" do - FunctionTest.int(nil).should == 0 - end - - it "should return an error if an argument is an error" do - FunctionTest.int(:error).should == :error - end - - it "should be in the list of functions that can be mapped to ruby" do - MapFormulaeToRuby::FUNCTIONS['INT'].should == 'int' - end - -end diff --git a/spec/excel/excel_functions/month_spec.rb b/spec/excel/excel_functions/month_spec.rb deleted file mode 100644 index ee6038e..0000000 --- a/spec/excel/excel_functions/month_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../spec_helper.rb' - -describe "ExcelFunctions: MONTH" do - - it "should return 3 when date is 03/26/2013 (serial: 41359)" do - FunctionTest.month(41359).should == 3 - end - - it "should return an error when given inappropriate arguments" do - FunctionTest.month("Asdasddf").should == :error - end - - it "should treat nil as zero" do - FunctionTest.month(nil).should == 0 - end - - it "should return an error if an argument is an error" do - FunctionTest.month(:error).should == :error - end - - it "should be in the list of functions that can be mapped to ruby" do - MapFormulaeToRuby::FUNCTIONS['MONTH'].should == 'month' - end - -end diff --git a/src/compile/ruby/map_formulae_to_ruby.rb b/src/compile/ruby/map_formulae_to_ruby.rb index 9f4e2b2..85fd5b4 100644 --- a/src/compile/ruby/map_formulae_to_ruby.rb +++ b/src/compile/ruby/map_formulae_to_ruby.rb @@ -23,19 +23,20 @@ class MapFormulaeToRuby < MapValuesToRuby 'COSH' => 'cosh', 'COUNT' => 'count', 'COUNTA' => 'counta', - 'EXP' => 'exp', 'FIND' => 'find', 'IF' => 'excel_if', 'IFERROR' => 'iferror', 'INDEX' => 'index', - 'INT' => 'int', 'LEFT' => 'left', 'MATCH' => 'excel_match', 'MAX' => 'max', 'MIN' => 'min', 'MOD' => 'mod', +<<<<<<< HEAD 'MONTH' => 'month', 'OR' => 'excel_or', +======= +>>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions 'PI' => 'pi', 'PMT' => 'pmt', 'ROUND' => 'round', diff --git a/src/excel/excel_functions.rb b/src/excel/excel_functions.rb index 72c9d97..1d042fe 100644 --- a/src/excel/excel_functions.rb +++ b/src/excel/excel_functions.rb @@ -82,6 +82,7 @@ module ExcelFunctions require_relative 'excel_functions/rounddown' require_relative 'excel_functions/negative' +<<<<<<< HEAD require_relative 'excel_functions/exp' @@ -92,3 +93,5 @@ module ExcelFunctions require_relative 'excel_functions/excel_or' require_relative 'excel_functions/today' +======= +>>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions diff --git a/src/excel/excel_functions/exp.rb b/src/excel/excel_functions/exp.rb deleted file mode 100644 index 56084ff..0000000 --- a/src/excel/excel_functions/exp.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ExcelFunctions - - def exp(a) - return 0 if a.nil? - return :error unless a.is_a? Numeric - a ||= 0 - result = Math::E ** a - return result - end - -end diff --git a/src/excel/excel_functions/int.rb b/src/excel/excel_functions/int.rb deleted file mode 100644 index ccf270a..0000000 --- a/src/excel/excel_functions/int.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ExcelFunctions - - def int(a) - return 0 if a.nil? - return :error unless a.is_a? Numeric - a ||= 0 - result = a.to_s.split('.')[0].to_i - return result - end - -end diff --git a/src/excel/excel_functions/month.rb b/src/excel/excel_functions/month.rb deleted file mode 100644 index 6fc88e8..0000000 --- a/src/excel/excel_functions/month.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'date' -require 'active_support' -require 'active_support/core_ext' - -module ExcelFunctions - - def month(a) - return 0 if a.nil? - return :error unless a.is_a? Numeric - a ||= 0 - - result = (Date.civil(1899, 12, 31) + (a - 1).days).month - return result - end - -end From bd5a5ff84ef9c2555cb3ec65ae46f12062ca5b4f Mon Sep 17 00:00:00 2001 From: bhgames Date: Tue, 9 Jul 2013 13:24:14 -0500 Subject: [PATCH 9/9] Revert "Implemented EXP, INT, and MONTH functions" This reverts commit d46088e5d7a18b1b4cb24fabab85451c21f96999. Conflicts: src/compile/ruby/map_formulae_to_ruby.rb src/excel/excel_functions.rb --- src/compile/ruby/map_formulae_to_ruby.rb | 3 +++ src/excel/excel_functions.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/compile/ruby/map_formulae_to_ruby.rb b/src/compile/ruby/map_formulae_to_ruby.rb index 85fd5b4..d700c48 100644 --- a/src/compile/ruby/map_formulae_to_ruby.rb +++ b/src/compile/ruby/map_formulae_to_ruby.rb @@ -32,10 +32,13 @@ class MapFormulaeToRuby < MapValuesToRuby 'MAX' => 'max', 'MIN' => 'min', 'MOD' => 'mod', +<<<<<<< HEAD <<<<<<< HEAD 'MONTH' => 'month', 'OR' => 'excel_or', ======= +>>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions +======= >>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions 'PI' => 'pi', 'PMT' => 'pmt', diff --git a/src/excel/excel_functions.rb b/src/excel/excel_functions.rb index 1d042fe..494d22b 100644 --- a/src/excel/excel_functions.rb +++ b/src/excel/excel_functions.rb @@ -83,6 +83,7 @@ module ExcelFunctions require_relative 'excel_functions/negative' <<<<<<< HEAD +<<<<<<< HEAD require_relative 'excel_functions/exp' @@ -95,3 +96,5 @@ module ExcelFunctions require_relative 'excel_functions/today' ======= >>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions +======= +>>>>>>> parent of d46088e... Implemented EXP, INT, and MONTH functions