I'm new to rails and I'm working on this project: I have done a ruby script which needs an input and that prints some outputs. Basically it takes the first n decimal digits of PI and then it calculates some stats. I need to use a rails web app to insert the input, which is a number, and to print the decimal digits and 10 stats rows.
This is the ruby script
require 'bigdecimal/math'
#PI decimals generator
i = 0
j = 0
a_pi = Array.new
print "Insert how many digits do you want to calculate: "
dig_n = gets.chomp.to_i
x = BigMath.PI(dig_n)
a_pi = x.to_s.split('')
begin
a_pi.shift
i += 1
end until i == 3
arr_length = a_pi.length
begin
a_pi.pop
j += 1
end until j == arr_length - dig_n
pi_dec = a_pi.join.to_i
puts pi_dec
I'm using Ruby 2.6 and Rails 6