# How to find whether a ring contains a matching item

**URL:** <https://in-thread.sonic-pi.net/t/how-to-find-whether-a-ring-contains-a-matching-item/8906>\
**Category:** Support, Help & Resources\
**Created:** [May 31, 2024, 10:46am UTC](https://in-thread.sonic-pi.net/t/how-to-find-whether-a-ring-contains-a-matching-item/8906 "2024-05-31T10:46:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [May 31, 2024, 10:46am UTC](https://in-thread.sonic-pi.net/t/how-to-find-whether-a-ring-contains-a-matching-item/8906/1 "2024-05-31T10:46:30Z")

</div>

Is there a built-in way to test whether a ring contains a particular item? Something like the array’s .contains? method (which does not work for rings)?  
I suppose I could brute force roll my own, but I don’t want to reinvent the wheel.  
Still hoping for a list of all methods for the VectorRing class – is there somewhere I could look at the ruby sourcecode for sonic pi?  
Thanks!

---

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [May 31, 2024, 11:07am UTC](https://in-thread.sonic-pi.net/t/how-to-find-whether-a-ring-contains-a-matching-item/8906/2 "2024-05-31T11:07:10Z")

</div>

Ok, I figured some stuff out.  
First of all, you can ask any ruby object what its methods are. So:  
puts SonicPi::Core::RingVector.instance\_methods  
gives a list of methods.  
One method I found particularly valuable is “vec”, which turns a ring into a standard ruby array, which you can then search easily.  
So I can find an element in a ring like so:

```ruby
myring = (ring 1, 2, 3, 4, 5, 6)
puts myring.vec.include? 3
puts myring.vec.include? 7

```

---

<div class="post-metadata">

**Author:** ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)\
**Post date:** [May 31, 2024, 11:24am UTC](https://in-thread.sonic-pi.net/t/how-to-find-whether-a-ring-contains-a-matching-item/8906/3 "2024-05-31T11:24:31Z")

</div>

I’ll list all methods in the thread discussing ring methods.
