Skip to content

Commit

Permalink
[ruby/prism] Rescue LoadError for ruby_parser as well
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed May 13, 2024
1 parent 5931f85 commit b5e53e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/prism/translation/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

begin
require "parser"
rescue LoadError => e
warn 'Error: Unable to load parser. Add `gem "parser"` to your Gemfile.'
exit!
rescue LoadError
warn(%q{Error: Unable to load parser. Add `gem "parser"` to your Gemfile.})
exit(1)
end

module Prism
Expand Down
7 changes: 6 additions & 1 deletion lib/prism/translation/ruby_parser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# frozen_string_literal: true

require "ruby_parser"
begin
require "ruby_parser"
rescue LoadError
warn(%q{Error: Unable to load ruby_parser. Add `gem "ruby_parser"` to your Gemfile.})
exit(1)
end

module Prism
module Translation
Expand Down

1 comment on commit b5e53e2

@rfbrbfrhnceijcwfhfwf
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def numero_intermedio(num1, num2)

Ordenar los números de menor a mayor

menor = [num1, num2].min
mayor = [num1, num2].max

Calcular el número intermedio

intermedio = menor + (mayor - menor) / 2.0

return intermedio
end

Solicitar al usuario que ingrese los números

print "Ingresa el primer número: "
num1 = gets.chomp.to_f

print "Ingresa el segundo número: "
num2 = gets.chomp.to_f

Please sign in to comment.