# Product Class

**URL:** <https://www.ruby-forum.com/t/product-class/170722>\
**Category:** Ruby\
**Created:** [June 21, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/product-class/170722 "2009-06-21T23:37:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zorigami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee7513/32.png) [@Zorigami](https://www.ruby-forum.com/u/Zorigami)\
**Post date:** [June 21, 2009, 11:37pm UTC](https://www.ruby-forum.com/t/product-class/170722/1 "2009-06-21T23:37:03Z")

</div>

Does anyone out there have a good “Product” Class?(With defs such as  
“setprice”, “name”, and “id”…)  
If so than could you send it to me?  
I’ve been trying to make one and Ideas would help.  
Thanks,

---

<div class="post-metadata">

**Author:** ![Zorigami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee7513/32.png) [@Zorigami](https://www.ruby-forum.com/u/Zorigami)\
**Post date:** [June 22, 2009, 12:54am UTC](https://www.ruby-forum.com/t/product-class/170722/2 "2009-06-22T00:54:50Z")

</div>

Thanks.  
What would be the syntax for making a new “Product”, say… called “Dog  
Collar”.

---

<div class="post-metadata">

**Author:** ![Zorigami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee7513/32.png) [@Zorigami](https://www.ruby-forum.com/u/Zorigami)\
**Post date:** [June 22, 2009, 12:37am UTC](https://www.ruby-forum.com/t/product-class/170722/3 "2009-06-22T00:37:53Z")

</div>

On Jun 21, 2009, at 14:35, Zorigami [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Does anyone out there have a good “Product” Class?(With defs such as  
> “setprice”, “name”, and “id”…)  
> If so than could you send it to me?  
> I’ve been trying to make one and Ideas would help.  
> Thanks,

class Product \< Struct.new(:id, :name, :price)

# custom behavior, if you need it

end

---

<div class="post-metadata">

**Author:** ![Zorigami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/ee7513/32.png) [@Zorigami](https://www.ruby-forum.com/u/Zorigami)\
**Post date:** [June 22, 2009, 2:27am UTC](https://www.ruby-forum.com/t/product-class/170722/4 "2009-06-22T02:27:14Z")

</div>

On Jun 21, 2009, at 15:54, Zorigami [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Does anyone out there have a good “Product” Class?(With defs such as
> > 
> > > “setprice”, “name”, and “id”…)  
> > > If so than could you send it to me?  
> > > I’ve been trying to make one and Ideas would help.  
> > > Thanks,
> > 
> > class Product \< Struct.new(:id, :name, :price)
> > 
> > # custom behavior, if you need it
> > 
> > end

Do your own homework: ri Struct
