Undefined local variable or method 'tsapi' for main.Object (NameError)

1.2k Views Asked by At

I am a nobie to Ruby and found the rubyphone code and I have attempted to get it to work with xml. Which I have gotten it to see the xml. The only part now is that it errors on : test.rb:17: undefined local variable or method `tsapi' for main:Object (NameError)

Line 17 I have tried it with tsapi.new and tsapi = tsapi.new

Any help would be great.

require "Win32API"
require "tsapi"
require 'rexml/document'
include REXML
file = File.new("tsapi.xml")
#doc = Document.new(file)
doc = REXML::Document.new('tsapi.xml')
    root=doc.root
    $server = ["section[@name='config']/server"]
    $username = ["section[@name='config']/username"]
    $password = ["section[@name='config']/password"]
    $app = ["section[@name='config']/app"]
    $tracing = ["section[@name='config']/tracing"]


 tsapi.new($extension, $server, $username, $password, $app)
  result == tsapi.open
  if result == true
    #Win32API.new("user32", "MessageBox", ['i','p','p','i'], 'i').call(0, "Calling Voice Mail.", "Calling VMail", 0) if result == true

   result = tsapi.call("12345")
  end
  tsapi.close
1

There are 1 best solutions below

0
On

It sounds like this "tsapi" is supposed to be a class. I'm not familiar with the library, but classes start with capital letters, so you'd want something like:

tsapi = Tsapi.new($extension, $server, $username, $password, $app)

or

tsapi = TSAPI.new($extension, $server, $username, $password, $app)

or something similar depending on what the class is actually called.