Thursday, January 6, 2011

[Rails] Running methods on a class in gem

I have installed a gem "Rubygsm and dependencies"
I have the send sms working via the gem

The following code is from the gem core file for receiving an sms:

# call-seq:
# receive(callback_method, interval=5, join_thread=false)
#
# Starts a new thread, which polls the device every _interval_
# seconds to capture incoming SMS and call _callback_method_
# for each, and polls the device's internal storage for incoming
# SMS that we weren't notified about (some modems don't support
# that).
#
# class Receiver
# def incoming(msg)
# puts "From #{msg.from} at #{msg.sent}:", msg.text
# end
# end
#
# # create the instances,
# # and start receiving
# rcv = Receiver.new
# m = Gsm::Modem.new "/dev/ttyS0"
# m.receive rcv.method :incoming
#
# # block until ctrl+c
# while(true) { sleep 2 }
#
# Note: New messages may arrive at any time, even if this method's
# receiver thread isn't waiting to process them. They are not lost,
# but cached in @incoming until this method is called.
def receive(callback, interval=5, join_thread=false)
@polled = 0

The working code....

end # Modem
end # Gsm

Where do I setup the actions and where should I place the method calls
to the object in this class
All the hashes above are descriptions I believe on how to call the
methods but need guidance.

Can I define a class within a class, say messages? I tried this but I
dont think I can

I have run it in console in my app and get failures

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate