Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #6874
| From | DON Who is a ghost <therocketforever@me.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Re: require_relative in ruby 1.9.3 error |
| Date | 2013-09-22 10:10 -0400 |
| Organization | therocketforever |
| Message-ID | <l1mtp6$ar8$1@speranza.aioe.org> (permalink) |
| References | <b543c601-e55c-41f4-a162-cb0f5515ac32@googlegroups.com> |
Maybe to simple and obvious, but have you tried `require_relative
"cart"` (no .rb extension) I think require_relative expects just the
basename of the file with out an exstension.
On 2013-09-01 15:33:02 +0000, maasgultekin@gmail.com said:
> I have ruby 1.9.3 with rvm and i have simple program about shop.
> I write require_relative and i take error:
> https://gist.github.com/maasdesigner/6405171
>
>
> init.rb
>
> require_relative "cart.rb"
> require_relative "item.rb"
>
> item.rb
>
> class Item
> def initialize(options)
> @price = options[:price]
> @weight = options[:weight]
> end
>
> attr_reader :price, :weight
> attr_writer :price, :weight
> end
> puts Item.new({:price => 30}).price
>
>
>
> cart.rb
>
> class Cart
>
> attr_reader :items
>
> def initialize
>
> @items = Array.new
>
> end
>
> def add_item(item)
>
> @item.push item
>
> end
>
> def remove_item
>
> @item.pop
>
> end
--
---
#
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar
require_relative in ruby 1.9.3 error maasgultekin@gmail.com - 2013-09-01 08:33 -0700 Re: require_relative in ruby 1.9.3 error DON Who is a ghost <therocketforever@me.com> - 2013-09-22 10:10 -0400
csiph-web