⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.2.htm.bak

📁 RUBY的参考手册~~ RUBY的参考手册~~RUBY的参考手册
💻 BAK
📖 第 1 页 / 共 4 页
字号:
              Introduction</TD></TR></TBODY></TABLE>
            <HR SIZE=1>
            <BR>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD vAlign=top><A name=ruby-CHP-1-SECT-2></A>
                  <H3 class=docSection1Title>1.2 Ruby in Action</H3>
                  <P class=docText>Like Python or Perl, Ruby is a scripting 
                  language. Scripting languages offer some great advantages over 
                  other languages, such as C++ and Java. They allow programmers 
                  to show off a lot of programming concepts and principles in a 
                  relatively small amount of space. Ruby does this, while 
                  maintaining code readability. </P><PRE># the "Hello World."
print "Hello World.\n"

# output file contents in reverse order
print File::readlines(path).reverse

# print lines that contains the word "Ruby".
while line = gets(  )
  if /Ruby/ =~ line
    print line
  end
end


# class and methods
class Animal
  def legs
    puts 4
  end
end

class Dog&lt;Animal
  def bark
    puts "bow!"
  end
end

fred = Dog::new
fred.legs                # prints 4
fred.bark                # prints bow!

# exception handling
begin
  printf "size of %s is %d\n", path, File::size(path)
rescue
  printf "error! probably %s does not exist\n", path
end

# rename all files to lowercase names
ARGV.each {|path| File::rename(path, path.downcase)}

# network access
require 'socket'
print TCPSocket::open("localhost", "daytime").read

# Ruby/Tk
require 'tk'
TkButton.new(nil, 'text'=&gt;'hello', 'command'=&gt;'exit').pack
Tk.mainloop</PRE><A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?xmlid=0-59600-214-9/1061532"><IMG 
                  height=1 src="1.2.files/pixel.htm" width=1 border=0></A>
                  <UL></UL></TD></TR></TBODY></TABLE>
            <HR SIZE=1>

            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD height=15>&nbsp;</TD></TR>
              <TR>
                <TD class=v2 vAlign=top><A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=print&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1" 
                  target=_new><IMG height=12 src="1.2.files/img_print.gif" 
                  width=14 align=textTop border=0></A> &nbsp;<A class=v2 
                  title="Printer-friendly version of this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=print&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1" 
                  target=_new>Print</A> &nbsp;<A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=email&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=9 hspace=3 src="1.2.files/img_email.gif" width=15 
                  align=absMiddle border=0></A> &nbsp;<A class=v2 
                  title="E-Mail this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=email&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1">E-Mail</A> 
                  &nbsp;<A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=bookmark&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=14 hspace=3 src="1.2.files/img_bookmarks.gif" width=6 
                  align=absMiddle border=0></A> &nbsp;<A class=v2 
                  title="Add a bookmark about this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=bookmark&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1">Add 
                  Bookmark</A></TD>
                <TD class=v2 vAlign=top align=right>&nbsp; <A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-1&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=16 src="1.2.files/btn_prev.gif" width=56 
                  align=absMiddle border=0></A> &nbsp; <A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=16 src="1.2.files/btn_next.gif" width=41 
                  align=absMiddle border=0></A></TD></TR></TBODY></TABLE>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD vAlign=top align=right><A class=v1 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1#toppage">Top</A></TD></TR></TBODY></TABLE>
            <P>[<A class=v2 
            href="http://proquest.safaribooksonline.com/0596002149/ruby-CHP-1-SECT-2">http://proquest.safaribooksonline.com/0596002149/ruby-CHP-1-SECT-2</A>] 
            </P></TD></TR></TBODY></TABLE></TD>
    <TD align=middle>&nbsp;</TD></TR>
  <TR>
    <TD vAlign=bottom align=middle colSpan=3><BR>
      <TABLE>
        <TBODY>
        <TR>
          <TD class=v2 vAlign=center align=middle colSpan=4 
            height=25>&nbsp;&nbsp; <A class=v1 
            title="Information About Safari Tech Books Online" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=About">About 
            Safari</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tech Books Online terms of service" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Terms">Terms 
            of Service</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tech Books Online privacy policy" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Privacy">Privacy 
            Policy</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Contacting Safari Tech Books Online" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Contact">Contact 
            Us</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tech Books Online help" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Help">Help</A> 
            &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Submit a defect or enhancement request" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Submit">Submit 
            a Problem</A></TD></TR>
        <TR>
          <TD class=v2 vAlign=center align=middle height=20>Copyright &copy; 2002 
            Safari Tech Books Online. All rights reserved.</TD></TR>
        <TR vAlign=center>
          <TD class=v2 vAlign=center align=middle colSpan=4 height=20>75 
            Arlington Street, Floor 3<BR>Boston, MA 02116<BR>800-775-7330</TD></TR>
        <TR vAlign=center>
          <TD class=v2 vAlign=center align=middle colSpan=4 
        height=5>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--
(guidin)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(guidout)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(ip)147.8.179.17
(host)proquest.safaribooksonline.com
(portal)proquest
(ref)
(base)?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-1-SECT-2&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1
(mode)section
(xmlid)0-59600-214-9/ruby-CHP-1-SECT-2
(key)7E6FA7863F875E5D371807B896A9188D02D5BE6122A762B263800A09E833AC01645EC3A55C82E53D
(user)29536/82393

(xsl)0ms
(lib)469ms
(xml)187ms
(xsl)203ms
(ent)0ms
(buf)0ms

(tot)1141ms
--></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -