Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


learning ruby need help

  • Please log in to reply
2 replies to this topic

#1 backslash


  • Members
  • 12 posts
  • Local time:09:08 AM

Posted 28 August 2014 - 07:18 PM

so I can't figure out why this isn't printing anything to console can someone please help me and explain it to me i would be extremely greatful!


user_input = gets.chomp.downcase
def include?(s,user_input)
    if user_input.include? "s"
        user_input.gsub!(/s/, "th")
         print "holy bleep there's a 's'"
    print "#{user_input} has no 's'"

BC AdBot (Login to Remove)


#2 backslash

  • Topic Starter

  • Members
  • 12 posts
  • Local time:09:08 AM

Posted 28 August 2014 - 08:26 PM

i solved it i'd delete the post if i could find out how>.>

#3 JohnnyJammer


  • Members
  • 1,117 posts
  • Gender:Male
  • Location:QLD Australia
  • Local time:12:08 AM

Posted 29 August 2014 - 12:31 AM

i got a few examples if you want some, hooking into LDAP etc etc.

This gets the server info

require 'net/http'
system 'cls'
print "What is the server you would like to get information on:"
server = gets.chomp.to_s
    if server.include? "Http://" or "www." then
      server.gsub!("http://", "")
      server.gsub!("www.", "")
  server_inf = Net::HTTP.get_response(server, '/')
  puts "#{server} is using: #{server_inf['SERVER']}"
rescue StandardError => Error_msg
  puts Error_msg

get the computer to talk back usiogn SAPI

require 'win32ole'
system 'cls'
say = ""
while (say == "") do
    voice = WIN32OLE.new("SAPI.SpVoice")
      getvoices = voice.GetVoices
      getvoices.each { |name| puts "Availible Voices:#{name.GetDescription}"}
          voice.Volume = 100
          #voice.Rate = 0
          voice.Speak "Type something for the computer to say then press ENTER"
        sleep 0.02
          voice.Speak "Now feel the Power of RUBY"
        say = gets.chomp.to_s
            if say == "" then
              voice.Speak "Hey I said type something dude"
        sleep 0.01
          voice.Speak say
  rescue WIN32OLERuntimeError => error_msg
          voice.Speak "bleep This .  We just had an error .... Closing pogram now"
  puts error_msg
  ensure break if error_msg
        sleep 0.02
          voice.Speak "Closing Program Now .. Good Bye"
          system 'pause'

Get the pc's IP

require "win32ole"
ws = WIN32OLE.new "MSWinsock.Winsock"
# Retrieve LocalIP property
ip = ws.localIP
puts ip.sort {|a,b| a.to_s <=> b.to_s}

Edited by JohnnyJammer, 29 August 2014 - 12:34 AM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users