Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How call function from other class(self created) in ruby program

Reply
Thread Tools

How call function from other class(self created) in ruby program

 
 
RAJU
Guest
Posts: n/a
 
      09-24-2009
let I have 2 diff. program code at C drive: A.rb and B.rb
! A.rb is
class A
def a
puts "Hello, I am in A"
end
end

!B.rb is

class B
def b
puts "I am in B"
end
end

Know i want to call object of Class A of code A.rb in B.rb.
So how can import Class A in B.what is syntax of importing.

 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      09-24-2009
2009/9/24 RAJU <>:
> let I have 2 diff. program =A0code at C drive: =A0A.rb and B.rb
> ! A.rb is
> class A
> =A0def a
> =A0 =A0puts "Hello, I am in A"
> =A0end
> end
>
> !B.rb is
>
> class B
> =A0def b
> =A0 =A0puts "I am in B"
> =A0end
> end
>
> Know i want to call object of Class A of code A.rb in =A0B.rb.
> So how can import Class A in B.what is syntax of importing.


require 'A'

Cheers

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to call function whose function call with arguments is in astring Options grbgooglefan C Programming 4 01-30-2008 05:12 PM
How to call function whose function call with arguments is in astring grbgooglefan C++ 2 01-30-2008 07:18 AM
Derive other function name from __FUNCTION__? And call the function. a_agaga@yahoo.com C++ 1 11-16-2006 07:36 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57