Applying limit and offset to an array I'm refactoring an old gateway and came across the following method:

def apply_limit_and_offset(options)
  limit  = options[:limit]
  offset = options[:offset]

  @result = if offset
    @result.drop offset
  else
    @result
  end

  @result = if limit
    @result.first limit
  else
    @result
  end

  @result
end


@result is an Array of objects.

Any suggestions on how to refactor this?  It works just fine, but multiple if statements make me feel gross.
Some notes:


Be consistent with the use of parens.
Use ternary expressions (?) to reduce short conditionals.
If you are using Ruby >= 2.0, check named keywords.
The resulting expression of an assignment is its value, so you can remove the last @result
What looks gross to me are those in-place updates of @result, but this goes beyond the scope of the question.


With Ruby >= 2.0, I'd write:

def apply_limit_and_offset(limit: nil, offset: nil)
  @result = offset ? @result.drop(offset) : @result
  @result = limit ? @result.first(limit) : @result
end