# Current Temperature (#68)

**URL:** <https://www.ruby-forum.com/t/current-temperature-68/73530>\
**Category:** Ruby\
**Created:** [February 26, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/current-temperature-68/73530 "2006-02-26T18:19:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rudolfs\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@Rudolfs\_O](https://www.ruby-forum.com/u/Rudolfs_O)\
**Post date:** [February 26, 2006, 6:19pm UTC](https://www.ruby-forum.com/t/current-temperature-68/73530/1 "2006-02-26T18:19:26Z")

</div>

Hello everyone !

Here is my solution, actually it’s my first ruby program, I just  
started learning… Suggestions on how to improve my code are  
welcome 🙂

This is how it looks when executed, I couldn’t find where to turn  
these warnings off 😕

* * *

root@black /# ./weather.rb madrid  
ignored element: {[http://schemas.xmlsoap.org/wsdl/http/](http://schemas.xmlsoap.org/wsdl/http/)}binding  
ignored element: {[http://schemas.xmlsoap.org/wsdl/http/](http://schemas.xmlsoap.org/wsdl/http/)}operation  
ignored element: {[http://schemas.xmlsoap.org/wsdl/http/](http://schemas.xmlsoap.org/wsdl/http/)}urlEncoded  
ignored element: {[http://schemas.xmlsoap.org/wsdl/mime/](http://schemas.xmlsoap.org/wsdl/mime/)}mimeXml  
ignored element: {[http://schemas.xmlsoap.org/wsdl/mime/](http://schemas.xmlsoap.org/wsdl/mime/)}content  
ignored element: {[http://schemas.xmlsoap.org/wsdl/http/](http://schemas.xmlsoap.org/wsdl/http/)}address  
The temperature in Madrid / Cuatro Vientos is 3 C

* * *

#!/usr/local/bin/ruby  
require ‘soap/wsdlDriver’  
require ‘rexml/document’

URL = ‘[http://www.webservicex.net/globalweather.asmx?WSDL](http://www.webservicex.net/globalweather.asmx?WSDL)’

# process the comandline arguments

if ARGV[0] == nil  
abort(“Usage: weather.rb city”)  
else  
city = ARGV.join(’ ')  
end

soap = SOAP::WSDLDriverFactory.new(URL).create\_rpc\_driver  
begin  
weather = soap.GetWeather(:CityName =\> city, :CountryName =\> “”)

# strip the first line with \<? ?\> stuff, else REXML wont parse

xml = weather.getWeatherResult.gsub(/(\<?.\*?\>\n)/, ‘’)  
data = REXML::Document.new(xml)

# celsius degrees are in parentheses

data.elements[“//Temperature”].text[/((._))/]; temp = $1  
data.elements[“//Location”].text[/^(._),/]; loc = $1

# show the gathered data

puts "The temperature in " + loc + " is " + temp  
rescue  
puts "Could not find data for your supplied city: " + city  
end

* * *

Best regards,  
Rudolfs

---

<div class="post-metadata">

**Author:** ![Rudolfs\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@Rudolfs\_O](https://www.ruby-forum.com/u/Rudolfs_O)\
**Post date:** [February 26, 2006, 6:39pm UTC](https://www.ruby-forum.com/t/current-temperature-68/73530/2 "2006-02-26T18:39:17Z")

</div>

Rudolfs O. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Here is my solution, actually it’s my first ruby program, I just  
> started learning… Suggestions on how to improve my code are  
> welcome 🙂
> 
> This is how it looks when executed, I couldn’t find where to turn  
> these warnings off 😕

$-w = nil should work.

Actually, I tried to use this webservice too, but I got so mad at it  
and it’s freaking dumb semantics that I dropped that for health  
reasons. Looks like you did it, though. 😉

---

<div class="post-metadata">

**Author:** ![Rudolfs\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/41988e/32.png) [@Rudolfs\_O](https://www.ruby-forum.com/u/Rudolfs_O)\
**Post date:** [February 26, 2006, 7:00pm UTC](https://www.ruby-forum.com/t/current-temperature-68/73530/3 "2006-02-26T19:00:35Z")

</div>

> $-w = nil should work.
> 
> Actually, I tried to use this webservice too, but I got so mad at it  
> and it’s freaking dumb semantics that I dropped that for health  
> reasons. Looks like you did it, though. 😉
> 
> –  
> Christian N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)[http://chneukirchen.org](http://chneukirchen.org)

Yay, that works, no warnings anymore 🙂 Where can I read more about this  
magic  
$-w variable ?

Regards,  
Rudolfs
