module GitlabAwesomeRelease::ArrayWithinExt

Public Instance Methods

within(from_value, to_value) click to toggle source
# File lib/gitlab_awesome_release/array_within_ext.rb, line 4
def within(from_value, to_value)
  from_index = find_index(from_value)
  to_index   = find_index(to_value)

  raise ArgumentError, "#{from_value} is not included in #{inspect}" unless from_index
  raise ArgumentError, "#{to_value} is not included in #{inspect}"   unless to_index

  self[from_index..to_index]
end