写一个 Ruby 解决方案:给出一个分类的整数数组和一个目标值,如果目标被发现,返回索引.如果没有,返回索引,如果它被插入顺序.你必须写一个算法与O(log n) 运行时间复杂性.
Here's a Ruby solution for the problem:

```
def search_insert(nums, target)
  low, high = 0, nums.length - 1
  
  while low <= high
    mid = (low + high) / 2
    if nums[mid] == target
      return mid
    elsif nums[mid] < target
      low = mid + 1
    else
      high = mid - 1
    end
  end
  
  return low
end
```