易截截图软件、单文件、免安装、纯绿色、仅160KB

Ruby声音


转 Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Perhaps a humorous sound to accompany an error message .
The win32-sound library makes using sounds really simple.
If you installed Ruby with the One-Click Ruby Installer, then you probably already have the win32-sound library installed, along with other win32 utilities. Otherwise, you can install it in seconds via gem. Open up a console window and enter..
gem install win32-sound
To use the win32-sound library, add these require and include statements to the top of your script...
require 'win32/sound'
include Win32
Then, to play a sound file on the PC, call the Sound.play method, passing it the name of the file...
Sound.play('chimes.wav')
Sound.play('c:\sounds\hal9000.wav')
In the example above, you don't have to include the path to the file 'chimes.wav', because 'chimes.wav' is usually installed in the Windows folder. But in most cases, you'll want to include the full path to the sound file.
To generate a simple beep, call the Sound.beep method, passing it the tone frequency (in Hertz, between 37 and 32767) and the duration in milliseconds. For example, to play a low tone for half a second...
Sound.beep(100, 500)
...or to play an annoyingly high-pitched tone for 3 full seconds...
Sound.beep(5000, 3000)
The complete docs for this library can be found here.
Distributing your sound files with your application is also simple. You can embed your sound files in an executable created with RubyScript2Exe, or include them in an install package produced with Inno Setup.
Be careful not to overdo it, though, if your program is to be used by others besides yourself. It's a fine line between clever and annoying.
注:
win-32声音库文件夹位置为
C:\WINDOWS\Media
Sound.pl


相关文档:

Ruby学习笔记二——数组

#一、数组引用
arr=[3,4,5,6,7,8,9]
puts arr[0] #3
puts arr.first #3
puts arr[arr.length-1] #9
puts arr[arr.size-1] #9
puts arr.last #9
puts arr[-1] #9
puts arr[-2] #8
print arr[1..3] ,"\n" #456
print arr[-3,4] ,"\n" #789,从-3开始 ,打印4个元素,这里只有三个
#Ruby的数组大小是动态的,你能够 ......

学ruby有感(by 王瀚)

    学了一个学期的C语言,看了一个星期的ruby,我才发现为什么老师说C是最基础的,假如没有一个学期的C基础,那ruby我也不用看了。
        Ruby和C语言有许多的相同点和不同点,在学习ruby时,有时可以用C里面的思维来理解,就像ruby里面的方法其实就跟C的函数如出一 ......

六种用ruby调用执行shell命令的方法

六种用ruby调用执行shell命令的方法
碰到需要调用操作系统shell命令的时候,Ruby为我们提供了六种完成任务的方法:
1.Exec方法:
    Kernel#exec方法通过调用指定的命令取代当前进程:
  例子:
      $ irb
      >> exec 'echo " ......

ruby命令行解析

   可用库:getoptlong.rs, optionparser
   对应类:GetoptLong,  OptionParser
   前者已过时,建议使用后者,且后者比前者易用。
后者特点:
1. 参数描述和代码处理写在一起
2. 输出参数说明,不需单独维护
3. 可选参数和命令参数描述简洁
4. 参数可自动转换为特定的类
5. ......

windows 下ruby的安装

1,安装ruby
下载地址: http://rubyinstaller.org/download.html
2,安装rails
使用命令下载:在命令行运行gem install rails --remote
2,初步了解ruby的文章
http://www.bcbbs.net/html/29671.html
http://www.bcbbs.net/dev/List64.aspx ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号