1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

simplify some methods relying on implicit functionality

This commit is contained in:
Lee Jarvis 2011-04-24 19:29:01 +01:00
parent 316720974c
commit 9f354b9385

View file

@ -54,12 +54,7 @@ class Pry
# @return [Pry] The parent of the current Pry session. # @return [Pry] The parent of the current Pry session.
def parent def parent
idx = Pry.sessions.index(self) idx = Pry.sessions.index(self)
Pry.sessions[idx - 1] if idx > 0
if idx > 0
Pry.sessions[idx - 1]
else
nil
end
end end
# Execute the hook `hook_name`, if it is defined. # Execute the hook `hook_name`, if it is defined.
@ -125,12 +120,7 @@ class Pry
end end
return_value = repl_epilogue(target, nesting_level, break_data) return_value = repl_epilogue(target, nesting_level, break_data)
return_value || target_self
# if one was provided, return the return value
return return_value if return_value
# otherwise return the target_self
target_self
end end
# Perform a read-eval-print. # Perform a read-eval-print.
@ -356,10 +346,9 @@ class Pry
# valid_expression?("class Hello; end") #=> true # valid_expression?("class Hello; end") #=> true
def valid_expression?(code) def valid_expression?(code)
RubyParser.new.parse(code) RubyParser.new.parse(code)
true
rescue Racc::ParseError, SyntaxError rescue Racc::ParseError, SyntaxError
false false
else
true
end end
end end
end end