Skip to content

Commit

Permalink
simplify some methods relying on implicit functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Jarvis committed Apr 24, 2011
1 parent 3167209 commit 9f354b9
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/pry/pry_instance.rb
Expand Up @@ -54,12 +54,7 @@ def nesting=(v)
# @return [Pry] The parent of the current Pry session.
def parent
idx = Pry.sessions.index(self)

if idx > 0
Pry.sessions[idx - 1]
else
nil
end
Pry.sessions[idx - 1] if idx > 0
end

# Execute the hook `hook_name`, if it is defined.
Expand Down Expand Up @@ -125,12 +120,7 @@ def repl(target=TOPLEVEL_BINDING)
end

return_value = repl_epilogue(target, nesting_level, break_data)

# if one was provided, return the return value
return return_value if return_value

# otherwise return the target_self
target_self
return_value || target_self
end

# Perform a read-eval-print.
Expand Down Expand Up @@ -356,10 +346,9 @@ def valid_expression?(code)
# valid_expression?("class Hello; end") #=> true
def valid_expression?(code)
RubyParser.new.parse(code)
true
rescue Racc::ParseError, SyntaxError
false
else
true
end
end
end

1 comment on commit 9f354b9

@epitron
Copy link
Member

Choose a reason for hiding this comment

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

Nice. :)

Please sign in to comment.