From e9d6c7f949df32300bc052e6136d26308ec6e70e Mon Sep 17 00:00:00 2001 From: Goudarz Date: Fri, 31 May 2019 15:17:11 +0430 Subject: [PATCH 01/10] Added Persian translation --- .github/CODEOWNERS | 2 + _config.yml | 111 ++++ _includes/languages.html | 1 + _layouts/default.html | 8 +- fa/about/index.md | 240 ++++++++ fa/about/license.txt | 56 ++ fa/about/logo/index.md | 22 + fa/about/website/index.md | 60 ++ fa/community/conferences/index.md | 92 +++ fa/community/index.md | 59 ++ fa/community/mailing-lists/index.md | 49 ++ .../manual-instructions/index.md | 63 ++ .../ruby-talk-guidelines/index.md | 82 +++ fa/community/podcasts/index.md | 18 + fa/community/ruby-core/index.md | 166 ++++++ .../ruby-core/writing-patches/index.md | 52 ++ fa/community/user-groups/index.md | 44 ++ fa/community/weblogs/index.md | 48 ++ fa/conduct/index.md | 22 + fa/documentation/faq/1/index.md | 344 +++++++++++ fa/documentation/faq/10/index.md | 145 +++++ fa/documentation/faq/11/index.md | 192 +++++++ fa/documentation/faq/2/index.md | 102 ++++ fa/documentation/faq/3/index.md | 212 +++++++ fa/documentation/faq/4/index.md | 428 ++++++++++++++ fa/documentation/faq/5/index.md | 237 ++++++++ fa/documentation/faq/6/index.md | 293 ++++++++++ fa/documentation/faq/7/index.md | 442 ++++++++++++++ fa/documentation/faq/8/index.md | 378 ++++++++++++ fa/documentation/faq/9/index.md | 372 ++++++++++++ fa/documentation/faq/index.md | 62 ++ fa/documentation/index.md | 175 ++++++ fa/documentation/installation/index.md | 355 ++++++++++++ fa/documentation/quickstart/2/index.md | 126 ++++ fa/documentation/quickstart/3/index.md | 230 ++++++++ fa/documentation/quickstart/4/index.md | 156 +++++ fa/documentation/quickstart/index.md | 144 +++++ .../ruby-from-other-languages/index.md | 426 ++++++++++++++ .../to-ruby-from-c-and-cpp/index.md | 149 +++++ .../to-ruby-from-java/index.md | 60 ++ .../to-ruby-from-perl/index.md | 68 +++ .../to-ruby-from-php/index.md | 51 ++ .../to-ruby-from-python/index.md | 83 +++ fa/documentation/success-stories/index.md | 88 +++ fa/downloads/branches/index.md | 43 ++ fa/downloads/index.md | 80 +++ fa/downloads/mirrors/index.md | 67 +++ fa/downloads/releases/index.md | 38 ++ fa/examples/cities.md | 21 + fa/examples/greeter.md | 22 + fa/examples/hello_world.md | 17 + fa/examples/i_love_ruby.md | 17 + fa/feeds/news.rss | 4 + fa/index.html | 38 ++ fa/libraries/index.md | 135 +++++ ...2001-01-18-stable-snapshot-is-available.md | 13 + .../2001-04-19-ruby-pocket-reference.md | 13 + fa/news/_posts/2001-06-20-ruby-garden.md | 12 + ...-07-10-removed-language-comparison-page.md | 15 + ...01-07-13-ruby-introduction-presentation.md | 13 + .../2002-01-06-ruby-cvs-repository-guide.md | 39 ++ .../2002-02-01-report-security-issues.md | 11 + fa/news/_posts/2002-03-01-167-is-released.md | 12 + ...18-dutch-translation-of-wwwruby-langorg.md | 13 + fa/news/_posts/2002-10-24-raa-replaced.md | 44 ++ ...2-11-01-my20021101-ruby-conference-2002.md | 22 + ...by-installer-for-windows-at-sourceforge.md | 28 + ...002-12-05-matzs-slides-at-4-conferences.md | 30 + fa/news/_posts/2002-12-07-raa-2-1-0.md | 50 ++ ...02-12-09-raa-xml-interfaces-are-updated.md | 33 ++ .../_posts/2002-12-11-ruby-hacking-guide.md | 539 ++++++++++++++++++ ...y-langorg-renewal-trial-website-offered.md | 36 ++ ...2-12-18-color-scheme-of-wwwruby-langorg.md | 19 + ...02-12-24-ruby-1-6-8-and-1-8-0-preview-1.md | 24 + ...2003-01-07-ruby-in-2002-contents-wanted.md | 24 + fa/news/_posts/2003-01-31-raa-2-3-0.md | 21 + ...03-02-21-first-europeen-ruby-conference.md | 21 + .../_posts/2003-02-24-happy-birthday-ruby.md | 20 + .../_posts/2003-08-04-ruby-180-released.md | 32 ++ .../_posts/2003-10-01-ruby-conference-2003.md | 21 + .../_posts/2003-10-30-ruby-181-preview2.md | 17 + ...-23-ruby-standard-library-documentation.md | 11 + .../_posts/2003-12-05-ruby-181-preview3.md | 14 + ...-19-new-ruby-change-request-rcr-process.md | 24 + .../2003-12-20-oreilly-onlamp-ruby-article.md | 20 + fa/news/_posts/2003-12-25-ruby-181-is-out.md | 24 + .../2004-01-07-matz-on-craftsmanship.md | 15 + fa/news/_posts/2004-01-17-rss-feed-started.md | 10 + .../_posts/2004-01-29-how-to-write-an-rcr.md | 15 + ...ruby-talk-mailing-posting-policy-change.md | 14 + ...004-02-16-ruby-article-in-linux-journal.md | 16 + ...04-12-ruby-track-and-tutorials-at-oscon.md | 17 + ...-rubyconf-2004-pre-registration-is-open.md | 17 + ...04-05-29-heliumruby-langorg-was-cracked.md | 27 + ...by-langorg-mailing-list-service-restart.md | 35 ++ .../2004-06-15-wwwftp-service-restart.md | 15 + ...004-06-22-anonymous-cvs-service-restart.md | 26 + .../2004-06-24-cvsweb-service-restart.md | 13 + ...s-added-to-the-anonymous-cvs-repository.md | 19 + ...oap4rlibcsvmodruby-old-to-anonymous-cvs.md | 11 + ...06-suspended-libsoap4r-and-libcsv-again.md | 18 + .../2004-07-21-ruby-182-preview1-released.md | 18 + ...-of-the-intrusion-on-heliumruby-langorg.md | 428 ++++++++++++++ .../2004-07-30-ruby-182-preview2-released.md | 18 + ...-31-rubyconf-2004-registration-now-open.md | 18 + ...08-08-brad-cox-to-keynote-rubyconf-2004.md | 17 + ...8-korean-translation-of-wwwruby-langorg.md | 13 + fa/news/_posts/2004-09-22-ruby-forum.md | 17 + .../2004-09-29-rsync-service-restart.md | 10 + .../2004-11-08-182-preview3-released.md | 19 + ...t-program-announced-by-ruby-central-inc.md | 18 + ...okshelf-planning-a-series-of-ruby-books.md | 20 + .../2004-12-22-182-preview4-released.md | 19 + ...-chinese-translation-of-wwwruby-langorg.md | 13 + .../_posts/2004-12-26-ruby-182-released.md | 22 + fa/news/_posts/2005-02-20-ruby-weekly-news.md | 19 + ...1-rubycentral-codefest-grants-announced.md | 17 + ...-rubyconf-2005-preregistration-now-open.md | 16 + .../_posts/2005-04-14-server-maintenance.md | 10 + ...005-04-19-anonymous-cvs-service-stopped.md | 13 + ...005-04-27-anonymous-cvs-service-restart.md | 9 + ...005-06-22-upgrade-to-debian-gnulinux-31.md | 11 + ...05-07-01-xmlrpcipimethods-vulnerability.md | 37 ++ .../_posts/2005-07-02-securityruby-langorg.md | 12 + ...-20-rubyconf-2005-registration-tops-100.md | 14 + ...f-2005-registration-time-is-running-out.md | 17 + ...ation-for-rubyconf-2005-is-closing-soon.md | 18 + .../_posts/2005-09-21-ruby-183-released.md | 13 + ...ulnerability-in-the-safe-level-settings.md | 61 ++ fa/news/_posts/2005-10-10-euruko-2005.md | 18 + ...5-10-11-new-ruby-web-magazine-goes-live.md | 27 + .../2005-12-14-ruby-184-preview-2-released.md | 13 + .../_posts/2005-12-24-ruby-184-released.md | 14 + .../2006-02-09-conference-season-is-here.md | 31 + ...006-04-19-ruby-in-google-summer-of-code.md | 17 + .../_posts/2006-06-20-the-future-of-ruby.md | 23 + .../_posts/2006-08-29-ruby-1-8-5-released.md | 19 + .../2006-08-30-server-maintenance-20060830.md | 11 + .../_posts/2006-09-12-site-launch-at-last.md | 57 ++ ...2006-10-18-rubyconf-2006-almost-upon-us.md | 33 ++ .../_posts/2006-10-26-rubyconf-2006-recap.md | 53 ++ fa/news/_posts/2006-11-03-CVE-2006-5467.md | 49 ++ ...nother-dos-vulnerability-in-cgi-library.md | 51 ++ ...12-20-ruby-on-rails-bootcamp-in-germany.md | 15 + .../2006-12-22-cvs-repository-moved-to-svn.md | 21 + ...12-27-ruby-on-rails-bootcamp-in-georgia.md | 15 + ...est-rubyconf-2007-registration-now-open.md | 18 + ...-01-26-mountainwest-speaker-list-posted.md | 16 + .../_posts/2007-02-21-ip-address-change.md | 13 + ...ervices-will-be-permanently-unavailable.md | 13 + .../_posts/2007-03-12-ruby-1-8-6-released.md | 42 ++ ...ccepted-for-rubyconf-2007-presentations.md | 20 + .../_posts/2007-09-01-ruby-logo-contest.md | 13 + ...-06-rubyconf-2007-registration-now-open.md | 15 + ...uruko-2007-the-european-ruby-conference.md | 19 + .../2007-10-04-net-https-vulnerability.md | 72 +++ .../_posts/2007-12-25-ruby-1-9-0-released.md | 28 + .../_posts/2008-01-09-ruby-logo-available.md | 14 + .../2008-01-24-ruby-fools-conference.md | 15 + .../2008-02-04-mountainwest-rubyconf-2008.md | 19 + ...25-european-ruby-conference-2008-euruko.md | 15 + .../2008-02-27-scotland-on-rails-2008.md | 29 + ...03-03-webrick-file-access-vulnerability.md | 83 +++ .../_posts/2008-04-11-tulsa-ruby-workshop.md | 32 ++ .../2008-05-22-server-maintenance-20080523.md | 10 + ...2008-05-31-ruby-1-8-7-has-been-released.md | 53 ++ fa/news/_posts/2008-06-16-rubynation-2008.md | 15 + ...rbitrary-code-execution-vulnerabilities.md | 78 +++ ...yconf-2008-proposals-now-being-accepted.md | 17 + ...-08-08-multiple-vulnerabilities-in-ruby.md | 173 ++++++ ...-ruby-1-8-7-p72-and-1-8-6-p287-released.md | 63 ++ .../2008-08-23-dos-vulnerability-in-rexml.md | 103 ++++ .../2008-09-09-voices-that-matter-2008.md | 16 + .../2008-10-02-rubyconf-2008-is-sold-out.md | 16 + ...008-10-28-ruby-1-9-1-preview-1-released.md | 43 ++ ...ountainwest-rubyconf-2009-dates-and-cfp.md | 24 + .../2008-11-10-scotland-on-rails-2009.md | 29 + .../2008-11-27-rubyconf-2008-summary-video.md | 16 + ...conf-2009-proposal-deadline-approaching.md | 20 + .../2009-01-28-20090131-server-maintenance.md | 8 + .../_posts/2009-01-30-ruby-1-9-1-released.md | 61 ++ ...09-02-25-mountainwest-rubyconf-schedule.md | 21 + ...ruby-1-8-7-p160-and-1-8-6-p368-released.md | 71 +++ .../2009-05-12-ruby-1-9-1-p129-released.md | 13 + ...-1-8-6-maintenance-moved-to-engine-yard.md | 24 + ...9-06-09-dos-vulnerability-in-bigdecimal.md | 52 ++ .../2009-07-20-ruby-1-9-1-p243-released.md | 52 ++ ...009-07-20-ruby-1-9-2-preview-1-released.md | 60 ++ ...03-call-for-proposals-for-rubyconf-2009.md | 20 + .../_posts/2009-09-04-rubyworld-conference.md | 20 + .../2009-12-03-mountainwest-rubyconf-2010.md | 23 + .../2009-12-07-heap-overflow-in-string.md | 39 ++ .../2009-12-07-ruby-1-9-1-p376-is-released.md | 73 +++ .../2009-12-25-ruby-1-8-7-p248-released.md | 37 ++ ...01-10-webrick-escape-sequence-injection.md | 84 +++ fa/news/_posts/2010-03-06-rubynation-2010.md | 17 + .../2010-03-17-red-dirt-rubyconf-2010.md | 115 ++++ .../2010-03-26-ruby-summer-of-code-2010.md | 32 ++ .../2010-06-23-ruby-1-8-7-p299-released.md | 33 ++ .../2010-07-02-ruby-1-9-1-p429-is-released.md | 55 ++ .../2010-07-02-ruby-1-9-2-rc1-is-released.md | 61 ++ .../2010-07-11-ruby-1-9-2-rc2-is-released.md | 62 ++ .../2010-08-16-ruby-1-8-7-p302-is-released.md | 55 ++ .../2010-08-16-ruby-1-9-1-p430-is-released.md | 50 ++ ...2010-08-16-xss-in-webrick-cve-2010-0541.md | 79 +++ .../_posts/2010-08-18-ruby-1-9-2-released.md | 106 ++++ ...matz-in-san-francisco-or-silicon-valley.md | 23 + .../2010-11-17-fukuoka-ruby-award-2011.md | 23 + .../2010-12-25-ruby-1-8-7-p330-released.md | 42 ++ .../2010-12-25-ruby-1-9-2-p136-is-released.md | 48 ++ ...02-18-exception-methods-can-bypass-safe.md | 59 ++ ...s-is-vulnerable-to-symlink-race-attacks.md | 66 +++ ...ed-maintenance-of-redmine-ruby-lang-org.md | 17 + .../2011-07-02-ruby-1-8-7-p352-released.md | 36 ++ .../2011-07-15-ruby-1-9-2-p290-is-released.md | 52 ++ ...1-ruby-1-9-3-preview1-has-been-released.md | 61 ++ ...confoo-2012-call-for-papers-is-now-open.md | 33 ++ ...-09-24-ruby-1-9-3-rc1-has-been-released.md | 37 ++ fa/news/_posts/2011-10-06-plans-for-1-8-7.md | 38 ++ ...0-12-programming-competitions-with-matz.md | 51 ++ .../2011-10-31-ruby-1-9-3-p0-is-released.md | 36 ++ ...-for-rubys-hash-algorithm-cve-2011-4815.md | 89 +++ .../2012-02-16-ruby-1-9-3-p125-is-released.md | 55 ++ ...16-security-fix-for-ruby-openssl-module.md | 50 ++ ...earns-the-fsfs-2011-free-software-award.md | 21 + fa/news/_posts/2012-04-10-rubyteach-2012.md | 22 + .../2012-04-20-ruby-1-9-3-p194-is-released.md | 76 +++ .../2012-04-21-ruby-1-9-2-p320-is-released.md | 76 +++ .../2012-05-30-server-maintenance-20120606.md | 8 + fa/news/_posts/2012-06-02-a-facebook-group.md | 21 + .../2012-06-29-ruby-1-8-7-p370-released.md | 39 ++ ...-confoo-2013call-for-papers-is-now-open.md | 34 ++ .../2012-10-12-cve-2012-4464-cve-2012-4466.md | 50 ++ ...2-10-12-poisoned-NUL-byte-vulnerability.md | 46 ++ .../2012-10-12-ruby-1-9-3-p286-is-released.md | 45 ++ .../2012-10-22-rupy-2012-coming-very-soon.md | 18 + .../2012-11-09-ruby-1-9-3-p327-is-released.md | 41 ++ ...2012-11-09-ruby19-hashdos-cve-2012-5371.md | 61 ++ .../2012-11-10-fukuoka-ruby-award-2013.md | 58 ++ .../2012-12-25-ruby-1-9-3-p362-is-released.md | 52 ++ .../2013-01-17-ruby-1-9-3-p374-is-released.md | 53 ++ ...2013-01-23-confoo-with-ruby-in-montreal.md | 30 + .../2013-02-06-rdoc-xss-cve-2013-0256.md | 88 +++ .../2013-02-06-ruby-1-9-3-p385-is-released.md | 54 ++ .../2013-02-08-ruby-2-0-0-rc2-is-released.md | 120 ++++ .../2013-02-15-the-2013-ruby-hero-awards.md | 25 + ...ruby-conference-call-for-papers-is-open.md | 29 + .../2013-02-22-json-dos-cve-2013-0269.md | 104 ++++ .../_posts/2013-02-22-rexml-dos-2013-02-22.md | 108 ++++ .../2013-02-22-ruby-1-9-3-p392-is-released.md | 58 ++ .../2013-02-24-ruby-2-0-0-p0-is-released.md | 191 +++++++ .../2013-05-14-ruby-1-9-3-p429-is-released.md | 47 ++ .../2013-05-14-ruby-2-0-0-p195-is-released.md | 109 ++++ ...14-taint-bypass-dl-fiddle-cve-2013-2065.md | 109 ++++ .../2013-06-12-new-ruby-lang-org-released.md | 33 ++ ...ability-in-openssl-client-cve-2013-4073.md | 62 ++ .../2013-06-27-ruby-1-8-7-p374-is-released.md | 42 ++ .../2013-06-27-ruby-1-9-3-p448-is-released.md | 44 ++ .../2013-06-27-ruby-2-0-0-p247-is-released.md | 82 +++ fa/news/_posts/2013-06-30-we-retire-1-8-7.md | 45 ++ fa/news/_posts/2013-08-06-status-issue.md | 69 +++ fa/news/_posts/2013-08-08-rip-raa.md | 26 + fa/news/_posts/2013-08-29-confoo-cfp.md | 35 ++ .../2013-09-03-vietnamese-translation.md | 27 + .../_posts/2013-09-07-we-use-fastly-cdn.md | 18 + ...3-09-23-ruby-2-1-0-preview1-is-released.md | 69 +++ fa/news/_posts/2013-09-28-design-contest.md | 23 + fa/news/_posts/2013-10-04-rubyconf-au-2014.md | 31 + .../2013-11-21-fukuoka-ruby-award-2014.md | 71 +++ ...in-floating-point-parsing-cve-2013-4164.md | 64 +++ .../2013-11-22-ruby-1-9-3-p484-is-released.md | 43 ++ .../2013-11-22-ruby-2-0-0-p353-is-released.md | 46 ++ ...3-11-22-ruby-2-1-0-preview2-is-released.md | 73 +++ .../_posts/2013-11-30-russian-translation.md | 28 + .../_posts/2013-12-09-rubyconf-tw-2014-cfp.md | 31 + .../_posts/2013-12-14-rubyconf-india-2014.md | 26 + ...13-12-17-maintenance-of-1-8-7-and-1-9-2.md | 75 +++ .../2013-12-20-ruby-2-1-0-rc1-is-released.md | 68 +++ ...-ruby-version-policy-changes-with-2-1-0.md | 64 +++ .../2013-12-25-ruby-2-1-0-is-released.md | 52 ++ .../2014-01-10-ruby-1-9-3-will-end-on-2015.md | 18 + .../_posts/2014-01-20-abril-pro-ruby-2014.md | 24 + .../2014-02-12-the-2014-ruby-hero-awards.md | 20 + .../2014-02-24-ruby-1-9-3-p545-is-released.md | 51 ++ .../2014-02-24-ruby-2-0-0-p451-is-released.md | 41 ++ .../2014-02-24-ruby-2-1-1-is-released.md | 40 ++ ...regression-of-hash-reject-in-ruby-2-1-1.md | 45 ++ .../_posts/2014-03-14-rubyconf-taiwan-2014.md | 16 + fa/news/_posts/2014-03-15-eurucamp-2014.md | 42 ++ ...n-yaml-uri-escape-parsing-cve-2014-2525.md | 65 +++ ...2014-04-10-severe-openssl-vulnerability.md | 76 +++ ...-dispute-of-vulnerability-cve-2014-2734.md | 107 ++++ .../2014-05-09-ruby-2-0-0-p481-is-released.md | 45 ++ .../2014-05-09-ruby-2-1-2-is-released.md | 45 ++ .../2014-05-16-ruby-1-9-3-p547-released.md | 54 ++ ...-05-31-stopped-mailing-list-temporarily.md | 30 + ...ubyworld-conference-2014-speaker-invite.md | 17 + .../2014-07-01-eol-for-1-8-7-and-1-9-2.md | 34 ++ ...7-26-rubykaigi-2014-registration-online.md | 63 ++ .../2014-08-19-ruby-1-9-2-p330-released.md | 55 ++ fa/news/_posts/2014-09-10-confoo-cfp.md | 29 + ...2014-09-18-ruby-2-2-0-preview1-released.md | 80 +++ .../2014-09-19-ruby-2-0-0-p576-is-released.md | 55 ++ .../2014-09-19-ruby-2-1-3-is-released.md | 54 ++ ...hanging-default-settings-of-ext-openssl.md | 126 ++++ .../2014-10-27-rexml-dos-cve-2014-8080.md | 109 ++++ .../2014-10-27-ruby-1-9-3-p550-is-released.md | 65 +++ .../2014-10-27-ruby-2-0-0-p594-is-released.md | 58 ++ .../_posts/2014-10-27-ruby-2-1-4-released.md | 71 +++ .../_posts/2014-11-03-tropicalrb-2015-cfp.md | 20 + .../2014-11-13-rexml-dos-cve-2014-8090.md | 74 +++ .../2014-11-13-ruby-1-9-3-p551-is-released.md | 63 ++ .../2014-11-13-ruby-2-0-0-p598-is-released.md | 59 ++ .../2014-11-13-ruby-2-1-5-is-released.md | 58 ++ ...2014-11-28-ruby-2-2-0-preview2-released.md | 94 +++ .../2014-12-18-ruby-2-2-0-rc1-released.md | 91 +++ .../_posts/2014-12-25-ruby-2-2-0-released.md | 101 ++++ ...-02-23-support-for-ruby-1-9-3-has-ended.md | 15 + .../2015-02-25-ruby-2-0-0-p643-is-released.md | 57 ++ .../_posts/2015-03-03-ruby-2-2-1-released.md | 52 ++ .../2015-03-06-google-summer-of-code-2015.md | 33 ++ .../2015-04-13-ruby-2-0-0-p645-released.md | 57 ++ .../_posts/2015-04-13-ruby-2-1-6-released.md | 56 ++ .../_posts/2015-04-13-ruby-2-2-2-released.md | 54 ++ ...openssl-hostname-matching-vulnerability.md | 53 ++ fa/news/_posts/2015-06-30-ruby-prize-2015.md | 25 + ...7-14-rubyconftw-2015-call-for-proposals.md | 23 + ...04-rubyconf-taiwan-registration-is-open.md | 16 + .../2015-08-18-ruby-2-0-0-p647-released.md | 57 ++ .../_posts/2015-08-18-ruby-2-1-7-released.md | 56 ++ .../_posts/2015-08-18-ruby-2-2-3-released.md | 54 ++ fa/news/_posts/2015-08-31-confoo-cfp.md | 19 + .../2015-10-13-fukuoka-ruby-award-2016.md | 61 ++ ...2015-11-11-ruby-2-3-0-preview1-released.md | 81 +++ ...2015-12-11-ruby-2-3-0-preview2-released.md | 91 +++ .../2015-12-16-ruby-2-0-0-p648-released.md | 53 ++ .../_posts/2015-12-16-ruby-2-1-8-released.md | 55 ++ .../_posts/2015-12-16-ruby-2-2-4-released.md | 53 ++ ...ng-usage-in-fiddle-and-dl-cve-2015-7551.md | 82 +++ .../_posts/2015-12-25-ruby-2-3-0-released.md | 83 +++ ...2-24-support-plan-of-ruby-2-0-0-and-2-1.md | 42 ++ .../_posts/2016-03-30-ruby-2-1-9-released.md | 58 ++ .../_posts/2016-04-01-ruby-2-1-10-released.md | 49 ++ .../_posts/2016-04-26-ruby-2-2-5-released.md | 56 ++ .../_posts/2016-04-26-ruby-2-3-1-released.md | 51 ++ fa/news/_posts/2016-05-16-confoo-cfp.md | 19 + ...2016-06-20-ruby-2-4-0-preview1-released.md | 115 ++++ fa/news/_posts/2016-07-25-ruby-prize-2016.md | 31 + fa/news/_posts/2016-08-26-confoo-cfp.md | 20 + ...2016-09-08-ruby-2-4-0-preview2-released.md | 121 ++++ .../2016-10-20-fukuoka-ruby-award-2017.md | 66 +++ ...2016-11-09-ruby-2-4-0-preview3-released.md | 136 +++++ .../_posts/2016-11-15-ruby-2-2-6-released.md | 53 ++ .../_posts/2016-11-15-ruby-2-3-2-released.md | 54 ++ .../_posts/2016-11-21-ruby-2-3-3-released.md | 55 ++ .../2016-12-12-ruby-2-4-0-rc1-released.md | 135 +++++ .../_posts/2016-12-25-ruby-2-4-0-released.md | 125 ++++ .../_posts/2017-03-22-ruby-2-4-1-released.md | 50 ++ .../_posts/2017-03-28-ruby-2-2-7-released.md | 61 ++ .../_posts/2017-03-30-ruby-2-3-4-released.md | 66 +++ ...017-04-01-support-of-ruby-2-1-has-ended.md | 43 ++ fa/news/_posts/2017-07-21-ruby-prize-2017.md | 29 + ...29-multiple-vulnerabilities-in-rubygems.md | 59 ++ ...09-14-json-heap-exposure-cve-2017-14064.md | 39 ++ ...ssl-asn1-buffer-underrun-cve-2017-14033.md | 40 ++ .../_posts/2017-09-14-ruby-2-2-8-released.md | 57 ++ .../_posts/2017-09-14-ruby-2-3-5-released.md | 68 +++ .../_posts/2017-09-14-ruby-2-4-2-released.md | 67 +++ ...4-sprintf-buffer-underrun-cve-2017-0898.md | 34 ++ ...scape-sequence-injection-cve-2017-10784.md | 36 ++ ...2017-10-10-ruby-2-5-0-preview1-released.md | 79 +++ ...et-ftp-command-injection-cve-2017-17405.md | 40 ++ .../_posts/2017-12-14-ruby-2-2-9-released.md | 53 ++ .../_posts/2017-12-14-ruby-2-3-6-released.md | 54 ++ .../_posts/2017-12-14-ruby-2-4-3-released.md | 53 ++ .../2017-12-14-ruby-2-5-0-rc1-released.md | 90 +++ .../_posts/2017-12-25-ruby-2-5-0-released.md | 130 +++++ .../2017-12-27-fukuoka-ruby-award-2018.md | 75 +++ ...17-multiple-vulnerabilities-in-rubygems.md | 61 ++ ...2018-02-24-ruby-2-6-0-preview1-released.md | 106 ++++ ...-buffer-under-read-unpack-cve-2018-8778.md | 37 ++ ...nse-splitting-in-webrick-cve-2017-17742.md | 35 ++ ...ge-request-dos-in-webrick-cve-2018-8777.md | 35 ++ ...-28-poisoned-nul-byte-dir-cve-2018-8780.md | 37 ++ ...soned-nul-byte-unixsocket-cve-2018-8779.md | 40 ++ .../_posts/2018-03-28-ruby-2-2-10-released.md | 60 ++ .../_posts/2018-03-28-ruby-2-3-7-released.md | 67 +++ .../_posts/2018-03-28-ruby-2-4-4-released.md | 60 ++ .../_posts/2018-03-28-ruby-2-5-1-released.md | 60 ++ ...-with-directory-traversal-cve-2018-6914.md | 38 ++ ...2018-05-31-ruby-2-6-0-preview2-released.md | 127 +++++ ...018-06-20-support-of-ruby-2-2-has-ended.md | 43 ++ ...-in-some-formats-of-pack-cve-2018-16396.md | 45 ++ ...-does-not-work-correctly-cve-2018-16395.md | 60 ++ .../_posts/2018-10-17-ruby-2-3-8-released.md | 58 ++ .../_posts/2018-10-17-ruby-2-4-5-released.md | 57 ++ .../_posts/2018-10-17-ruby-2-5-2-released.md | 55 ++ .../_posts/2018-10-18-ruby-2-5-3-released.md | 55 ++ ...2018-11-06-ruby-2-6-0-preview3-released.md | 130 +++++ fa/news/_posts/2018-11-08-snap.md | 63 ++ .../2018-11-29-fukuoka-ruby-award-2019.md | 63 ++ .../2018-12-06-ruby-2-6-0-rc1-released.md | 140 +++++ .../2018-12-15-ruby-2-6-0-rc2-released.md | 144 +++++ .../_posts/2018-12-25-ruby-2-6-0-released.md | 150 +++++ .../_posts/2019-01-30-ruby-2-6-1-released.md | 51 ++ ...05-multiple-vulnerabilities-in-rubygems.md | 57 ++ .../_posts/2019-03-13-ruby-2-5-4-released.md | 49 ++ .../_posts/2019-03-13-ruby-2-6-2-released.md | 49 ++ .../_posts/2019-03-15-ruby-2-5-5-released.md | 48 ++ fa/security/index.md | 122 ++++ stylesheets/fonts/LICENSE | 51 ++ stylesheets/fonts/Vazir-Black.eot | Bin 0 -> 93214 bytes stylesheets/fonts/Vazir-Black.ttf | Bin 0 -> 93044 bytes stylesheets/fonts/Vazir-Black.woff | Bin 0 -> 53616 bytes stylesheets/fonts/Vazir-Black.woff2 | Bin 0 -> 42408 bytes stylesheets/fonts/Vazir-Bold.eot | Bin 0 -> 91930 bytes stylesheets/fonts/Vazir-Bold.ttf | Bin 0 -> 91764 bytes stylesheets/fonts/Vazir-Bold.woff | Bin 0 -> 52808 bytes stylesheets/fonts/Vazir-Bold.woff2 | Bin 0 -> 42076 bytes stylesheets/fonts/Vazir-Light.eot | Bin 0 -> 101214 bytes stylesheets/fonts/Vazir-Light.ttf | Bin 0 -> 101044 bytes stylesheets/fonts/Vazir-Light.woff | Bin 0 -> 60076 bytes stylesheets/fonts/Vazir-Light.woff2 | Bin 0 -> 48616 bytes stylesheets/fonts/Vazir-Medium.eot | Bin 0 -> 107958 bytes stylesheets/fonts/Vazir-Medium.ttf | Bin 0 -> 107784 bytes stylesheets/fonts/Vazir-Medium.woff | Bin 0 -> 63400 bytes stylesheets/fonts/Vazir-Medium.woff2 | Bin 0 -> 51436 bytes stylesheets/fonts/Vazir-Thin.eot | Bin 0 -> 90746 bytes stylesheets/fonts/Vazir-Thin.ttf | Bin 0 -> 90580 bytes stylesheets/fonts/Vazir-Thin.woff | Bin 0 -> 52052 bytes stylesheets/fonts/Vazir-Thin.woff2 | Bin 0 -> 41580 bytes stylesheets/fonts/Vazir.eot | Bin 0 -> 85414 bytes stylesheets/fonts/Vazir.ttf | Bin 0 -> 85252 bytes stylesheets/fonts/Vazir.woff | Bin 0 -> 47988 bytes stylesheets/fonts/Vazir.woff2 | Bin 0 -> 38020 bytes stylesheets/rtl.css | 109 ++++ 436 files changed, 24243 insertions(+), 2 deletions(-) create mode 100644 fa/about/index.md create mode 100644 fa/about/license.txt create mode 100644 fa/about/logo/index.md create mode 100644 fa/about/website/index.md create mode 100644 fa/community/conferences/index.md create mode 100644 fa/community/index.md create mode 100644 fa/community/mailing-lists/index.md create mode 100644 fa/community/mailing-lists/manual-instructions/index.md create mode 100644 fa/community/mailing-lists/ruby-talk-guidelines/index.md create mode 100644 fa/community/podcasts/index.md create mode 100644 fa/community/ruby-core/index.md create mode 100644 fa/community/ruby-core/writing-patches/index.md create mode 100644 fa/community/user-groups/index.md create mode 100644 fa/community/weblogs/index.md create mode 100644 fa/conduct/index.md create mode 100644 fa/documentation/faq/1/index.md create mode 100644 fa/documentation/faq/10/index.md create mode 100644 fa/documentation/faq/11/index.md create mode 100644 fa/documentation/faq/2/index.md create mode 100644 fa/documentation/faq/3/index.md create mode 100644 fa/documentation/faq/4/index.md create mode 100644 fa/documentation/faq/5/index.md create mode 100644 fa/documentation/faq/6/index.md create mode 100644 fa/documentation/faq/7/index.md create mode 100644 fa/documentation/faq/8/index.md create mode 100644 fa/documentation/faq/9/index.md create mode 100644 fa/documentation/faq/index.md create mode 100644 fa/documentation/index.md create mode 100644 fa/documentation/installation/index.md create mode 100644 fa/documentation/quickstart/2/index.md create mode 100644 fa/documentation/quickstart/3/index.md create mode 100644 fa/documentation/quickstart/4/index.md create mode 100644 fa/documentation/quickstart/index.md create mode 100644 fa/documentation/ruby-from-other-languages/index.md create mode 100644 fa/documentation/ruby-from-other-languages/to-ruby-from-c-and-cpp/index.md create mode 100644 fa/documentation/ruby-from-other-languages/to-ruby-from-java/index.md create mode 100644 fa/documentation/ruby-from-other-languages/to-ruby-from-perl/index.md create mode 100644 fa/documentation/ruby-from-other-languages/to-ruby-from-php/index.md create mode 100644 fa/documentation/ruby-from-other-languages/to-ruby-from-python/index.md create mode 100644 fa/documentation/success-stories/index.md create mode 100644 fa/downloads/branches/index.md create mode 100644 fa/downloads/index.md create mode 100644 fa/downloads/mirrors/index.md create mode 100644 fa/downloads/releases/index.md create mode 100644 fa/examples/cities.md create mode 100644 fa/examples/greeter.md create mode 100644 fa/examples/hello_world.md create mode 100644 fa/examples/i_love_ruby.md create mode 100644 fa/feeds/news.rss create mode 100644 fa/index.html create mode 100644 fa/libraries/index.md create mode 100644 fa/news/_posts/2001-01-18-stable-snapshot-is-available.md create mode 100644 fa/news/_posts/2001-04-19-ruby-pocket-reference.md create mode 100644 fa/news/_posts/2001-06-20-ruby-garden.md create mode 100644 fa/news/_posts/2001-07-10-removed-language-comparison-page.md create mode 100644 fa/news/_posts/2001-07-13-ruby-introduction-presentation.md create mode 100644 fa/news/_posts/2002-01-06-ruby-cvs-repository-guide.md create mode 100644 fa/news/_posts/2002-02-01-report-security-issues.md create mode 100644 fa/news/_posts/2002-03-01-167-is-released.md create mode 100644 fa/news/_posts/2002-09-18-dutch-translation-of-wwwruby-langorg.md create mode 100644 fa/news/_posts/2002-10-24-raa-replaced.md create mode 100644 fa/news/_posts/2002-11-01-my20021101-ruby-conference-2002.md create mode 100644 fa/news/_posts/2002-11-25-ruby-installer-for-windows-at-sourceforge.md create mode 100644 fa/news/_posts/2002-12-05-matzs-slides-at-4-conferences.md create mode 100644 fa/news/_posts/2002-12-07-raa-2-1-0.md create mode 100644 fa/news/_posts/2002-12-09-raa-xml-interfaces-are-updated.md create mode 100644 fa/news/_posts/2002-12-11-ruby-hacking-guide.md create mode 100644 fa/news/_posts/2002-12-16-toward-ruby-langorg-renewal-trial-website-offered.md create mode 100644 fa/news/_posts/2002-12-18-color-scheme-of-wwwruby-langorg.md create mode 100644 fa/news/_posts/2002-12-24-ruby-1-6-8-and-1-8-0-preview-1.md create mode 100644 fa/news/_posts/2003-01-07-ruby-in-2002-contents-wanted.md create mode 100644 fa/news/_posts/2003-01-31-raa-2-3-0.md create mode 100644 fa/news/_posts/2003-02-21-first-europeen-ruby-conference.md create mode 100644 fa/news/_posts/2003-02-24-happy-birthday-ruby.md create mode 100644 fa/news/_posts/2003-08-04-ruby-180-released.md create mode 100644 fa/news/_posts/2003-10-01-ruby-conference-2003.md create mode 100644 fa/news/_posts/2003-10-30-ruby-181-preview2.md create mode 100644 fa/news/_posts/2003-11-23-ruby-standard-library-documentation.md create mode 100644 fa/news/_posts/2003-12-05-ruby-181-preview3.md create mode 100644 fa/news/_posts/2003-12-19-new-ruby-change-request-rcr-process.md create mode 100644 fa/news/_posts/2003-12-20-oreilly-onlamp-ruby-article.md create mode 100644 fa/news/_posts/2003-12-25-ruby-181-is-out.md create mode 100644 fa/news/_posts/2004-01-07-matz-on-craftsmanship.md create mode 100644 fa/news/_posts/2004-01-17-rss-feed-started.md create mode 100644 fa/news/_posts/2004-01-29-how-to-write-an-rcr.md create mode 100644 fa/news/_posts/2004-02-15-ruby-talk-mailing-posting-policy-change.md create mode 100644 fa/news/_posts/2004-02-16-ruby-article-in-linux-journal.md create mode 100644 fa/news/_posts/2004-04-12-ruby-track-and-tutorials-at-oscon.md create mode 100644 fa/news/_posts/2004-05-23-rubyconf-2004-pre-registration-is-open.md create mode 100644 fa/news/_posts/2004-05-29-heliumruby-langorg-was-cracked.md create mode 100644 fa/news/_posts/2004-06-01-notice-on-ruby-langorg-mailing-list-service-restart.md create mode 100644 fa/news/_posts/2004-06-15-wwwftp-service-restart.md create mode 100644 fa/news/_posts/2004-06-22-anonymous-cvs-service-restart.md create mode 100644 fa/news/_posts/2004-06-24-cvsweb-service-restart.md create mode 100644 fa/news/_posts/2004-06-29-modules-added-to-the-anonymous-cvs-repository.md create mode 100644 fa/news/_posts/2004-07-05-added-libsoap4rlibcsvmodruby-old-to-anonymous-cvs.md create mode 100644 fa/news/_posts/2004-07-06-suspended-libsoap4r-and-libcsv-again.md create mode 100644 fa/news/_posts/2004-07-21-ruby-182-preview1-released.md create mode 100644 fa/news/_posts/2004-07-22-incident-analysis-of-the-intrusion-on-heliumruby-langorg.md create mode 100644 fa/news/_posts/2004-07-30-ruby-182-preview2-released.md create mode 100644 fa/news/_posts/2004-07-31-rubyconf-2004-registration-now-open.md create mode 100644 fa/news/_posts/2004-08-08-brad-cox-to-keynote-rubyconf-2004.md create mode 100644 fa/news/_posts/2004-09-18-korean-translation-of-wwwruby-langorg.md create mode 100644 fa/news/_posts/2004-09-22-ruby-forum.md create mode 100644 fa/news/_posts/2004-09-29-rsync-service-restart.md create mode 100644 fa/news/_posts/2004-11-08-182-preview3-released.md create mode 100644 fa/news/_posts/2004-12-02-ruby-codefest-grant-program-announced-by-ruby-central-inc.md create mode 100644 fa/news/_posts/2004-12-19-pragmatic-bookshelf-planning-a-series-of-ruby-books.md create mode 100644 fa/news/_posts/2004-12-22-182-preview4-released.md create mode 100644 fa/news/_posts/2004-12-25-chinese-translation-of-wwwruby-langorg.md create mode 100644 fa/news/_posts/2004-12-26-ruby-182-released.md create mode 100644 fa/news/_posts/2005-02-20-ruby-weekly-news.md create mode 100644 fa/news/_posts/2005-03-11-rubycentral-codefest-grants-announced.md create mode 100644 fa/news/_posts/2005-03-23-rubyconf-2005-preregistration-now-open.md create mode 100644 fa/news/_posts/2005-04-14-server-maintenance.md create mode 100644 fa/news/_posts/2005-04-19-anonymous-cvs-service-stopped.md create mode 100644 fa/news/_posts/2005-04-27-anonymous-cvs-service-restart.md create mode 100644 fa/news/_posts/2005-06-22-upgrade-to-debian-gnulinux-31.md create mode 100644 fa/news/_posts/2005-07-01-xmlrpcipimethods-vulnerability.md create mode 100644 fa/news/_posts/2005-07-02-securityruby-langorg.md create mode 100644 fa/news/_posts/2005-08-20-rubyconf-2005-registration-tops-100.md create mode 100644 fa/news/_posts/2005-08-31-rubyconf-2005-registration-time-is-running-out.md create mode 100644 fa/news/_posts/2005-09-07-registration-for-rubyconf-2005-is-closing-soon.md create mode 100644 fa/news/_posts/2005-09-21-ruby-183-released.md create mode 100644 fa/news/_posts/2005-10-03-ruby-vulnerability-in-the-safe-level-settings.md create mode 100644 fa/news/_posts/2005-10-10-euruko-2005.md create mode 100644 fa/news/_posts/2005-10-11-new-ruby-web-magazine-goes-live.md create mode 100644 fa/news/_posts/2005-12-14-ruby-184-preview-2-released.md create mode 100644 fa/news/_posts/2005-12-24-ruby-184-released.md create mode 100644 fa/news/_posts/2006-02-09-conference-season-is-here.md create mode 100644 fa/news/_posts/2006-04-19-ruby-in-google-summer-of-code.md create mode 100644 fa/news/_posts/2006-06-20-the-future-of-ruby.md create mode 100644 fa/news/_posts/2006-08-29-ruby-1-8-5-released.md create mode 100644 fa/news/_posts/2006-08-30-server-maintenance-20060830.md create mode 100644 fa/news/_posts/2006-09-12-site-launch-at-last.md create mode 100644 fa/news/_posts/2006-10-18-rubyconf-2006-almost-upon-us.md create mode 100644 fa/news/_posts/2006-10-26-rubyconf-2006-recap.md create mode 100644 fa/news/_posts/2006-11-03-CVE-2006-5467.md create mode 100644 fa/news/_posts/2006-12-04-another-dos-vulnerability-in-cgi-library.md create mode 100644 fa/news/_posts/2006-12-20-ruby-on-rails-bootcamp-in-germany.md create mode 100644 fa/news/_posts/2006-12-22-cvs-repository-moved-to-svn.md create mode 100644 fa/news/_posts/2006-12-27-ruby-on-rails-bootcamp-in-georgia.md create mode 100644 fa/news/_posts/2007-01-24-mountainwest-rubyconf-2007-registration-now-open.md create mode 100644 fa/news/_posts/2007-01-26-mountainwest-speaker-list-posted.md create mode 100644 fa/news/_posts/2007-02-21-ip-address-change.md create mode 100644 fa/news/_posts/2007-03-01-cvs-services-will-be-permanently-unavailable.md create mode 100644 fa/news/_posts/2007-03-12-ruby-1-8-6-released.md create mode 100644 fa/news/_posts/2007-07-27-proposals-now-being-accepted-for-rubyconf-2007-presentations.md create mode 100644 fa/news/_posts/2007-09-01-ruby-logo-contest.md create mode 100644 fa/news/_posts/2007-09-06-rubyconf-2007-registration-now-open.md create mode 100644 fa/news/_posts/2007-09-18-euruko-2007-the-european-ruby-conference.md create mode 100644 fa/news/_posts/2007-10-04-net-https-vulnerability.md create mode 100644 fa/news/_posts/2007-12-25-ruby-1-9-0-released.md create mode 100644 fa/news/_posts/2008-01-09-ruby-logo-available.md create mode 100644 fa/news/_posts/2008-01-24-ruby-fools-conference.md create mode 100644 fa/news/_posts/2008-02-04-mountainwest-rubyconf-2008.md create mode 100644 fa/news/_posts/2008-02-25-european-ruby-conference-2008-euruko.md create mode 100644 fa/news/_posts/2008-02-27-scotland-on-rails-2008.md create mode 100644 fa/news/_posts/2008-03-03-webrick-file-access-vulnerability.md create mode 100644 fa/news/_posts/2008-04-11-tulsa-ruby-workshop.md create mode 100644 fa/news/_posts/2008-05-22-server-maintenance-20080523.md create mode 100644 fa/news/_posts/2008-05-31-ruby-1-8-7-has-been-released.md create mode 100644 fa/news/_posts/2008-06-16-rubynation-2008.md create mode 100644 fa/news/_posts/2008-06-20-arbitrary-code-execution-vulnerabilities.md create mode 100644 fa/news/_posts/2008-08-04-rubyconf-2008-proposals-now-being-accepted.md create mode 100644 fa/news/_posts/2008-08-08-multiple-vulnerabilities-in-ruby.md create mode 100644 fa/news/_posts/2008-08-11-ruby-1-8-7-p72-and-1-8-6-p287-released.md create mode 100644 fa/news/_posts/2008-08-23-dos-vulnerability-in-rexml.md create mode 100644 fa/news/_posts/2008-09-09-voices-that-matter-2008.md create mode 100644 fa/news/_posts/2008-10-02-rubyconf-2008-is-sold-out.md create mode 100644 fa/news/_posts/2008-10-28-ruby-1-9-1-preview-1-released.md create mode 100644 fa/news/_posts/2008-11-08-mountainwest-rubyconf-2009-dates-and-cfp.md create mode 100644 fa/news/_posts/2008-11-10-scotland-on-rails-2009.md create mode 100644 fa/news/_posts/2008-11-27-rubyconf-2008-summary-video.md create mode 100644 fa/news/_posts/2008-12-23-mountainwest-rubyconf-2009-proposal-deadline-approaching.md create mode 100644 fa/news/_posts/2009-01-28-20090131-server-maintenance.md create mode 100644 fa/news/_posts/2009-01-30-ruby-1-9-1-released.md create mode 100644 fa/news/_posts/2009-02-25-mountainwest-rubyconf-schedule.md create mode 100644 fa/news/_posts/2009-04-18-ruby-1-8-7-p160-and-1-8-6-p368-released.md create mode 100644 fa/news/_posts/2009-05-12-ruby-1-9-1-p129-released.md create mode 100644 fa/news/_posts/2009-05-23-ruby-1-8-6-maintenance-moved-to-engine-yard.md create mode 100644 fa/news/_posts/2009-06-09-dos-vulnerability-in-bigdecimal.md create mode 100644 fa/news/_posts/2009-07-20-ruby-1-9-1-p243-released.md create mode 100644 fa/news/_posts/2009-07-20-ruby-1-9-2-preview-1-released.md create mode 100644 fa/news/_posts/2009-08-03-call-for-proposals-for-rubyconf-2009.md create mode 100644 fa/news/_posts/2009-09-04-rubyworld-conference.md create mode 100644 fa/news/_posts/2009-12-03-mountainwest-rubyconf-2010.md create mode 100644 fa/news/_posts/2009-12-07-heap-overflow-in-string.md create mode 100644 fa/news/_posts/2009-12-07-ruby-1-9-1-p376-is-released.md create mode 100644 fa/news/_posts/2009-12-25-ruby-1-8-7-p248-released.md create mode 100644 fa/news/_posts/2010-01-10-webrick-escape-sequence-injection.md create mode 100644 fa/news/_posts/2010-03-06-rubynation-2010.md create mode 100644 fa/news/_posts/2010-03-17-red-dirt-rubyconf-2010.md create mode 100644 fa/news/_posts/2010-03-26-ruby-summer-of-code-2010.md create mode 100644 fa/news/_posts/2010-06-23-ruby-1-8-7-p299-released.md create mode 100644 fa/news/_posts/2010-07-02-ruby-1-9-1-p429-is-released.md create mode 100644 fa/news/_posts/2010-07-02-ruby-1-9-2-rc1-is-released.md create mode 100644 fa/news/_posts/2010-07-11-ruby-1-9-2-rc2-is-released.md create mode 100644 fa/news/_posts/2010-08-16-ruby-1-8-7-p302-is-released.md create mode 100644 fa/news/_posts/2010-08-16-ruby-1-9-1-p430-is-released.md create mode 100644 fa/news/_posts/2010-08-16-xss-in-webrick-cve-2010-0541.md create mode 100644 fa/news/_posts/2010-08-18-ruby-1-9-2-released.md create mode 100644 fa/news/_posts/2010-10-01-see-matz-in-san-francisco-or-silicon-valley.md create mode 100644 fa/news/_posts/2010-11-17-fukuoka-ruby-award-2011.md create mode 100644 fa/news/_posts/2010-12-25-ruby-1-8-7-p330-released.md create mode 100644 fa/news/_posts/2010-12-25-ruby-1-9-2-p136-is-released.md create mode 100644 fa/news/_posts/2011-02-18-exception-methods-can-bypass-safe.md create mode 100644 fa/news/_posts/2011-02-18-fileutils-is-vulnerable-to-symlink-race-attacks.md create mode 100644 fa/news/_posts/2011-02-22-planned-maintenance-of-redmine-ruby-lang-org.md create mode 100644 fa/news/_posts/2011-07-02-ruby-1-8-7-p352-released.md create mode 100644 fa/news/_posts/2011-07-15-ruby-1-9-2-p290-is-released.md create mode 100644 fa/news/_posts/2011-08-01-ruby-1-9-3-preview1-has-been-released.md create mode 100644 fa/news/_posts/2011-08-11-confoo-2012-call-for-papers-is-now-open.md create mode 100644 fa/news/_posts/2011-09-24-ruby-1-9-3-rc1-has-been-released.md create mode 100644 fa/news/_posts/2011-10-06-plans-for-1-8-7.md create mode 100644 fa/news/_posts/2011-10-12-programming-competitions-with-matz.md create mode 100644 fa/news/_posts/2011-10-31-ruby-1-9-3-p0-is-released.md create mode 100644 fa/news/_posts/2011-12-28-denial-of-service-attack-was-found-for-rubys-hash-algorithm-cve-2011-4815.md create mode 100644 fa/news/_posts/2012-02-16-ruby-1-9-3-p125-is-released.md create mode 100644 fa/news/_posts/2012-02-16-security-fix-for-ruby-openssl-module.md create mode 100644 fa/news/_posts/2012-03-29-matz-earns-the-fsfs-2011-free-software-award.md create mode 100644 fa/news/_posts/2012-04-10-rubyteach-2012.md create mode 100644 fa/news/_posts/2012-04-20-ruby-1-9-3-p194-is-released.md create mode 100644 fa/news/_posts/2012-04-21-ruby-1-9-2-p320-is-released.md create mode 100644 fa/news/_posts/2012-05-30-server-maintenance-20120606.md create mode 100644 fa/news/_posts/2012-06-02-a-facebook-group.md create mode 100644 fa/news/_posts/2012-06-29-ruby-1-8-7-p370-released.md create mode 100644 fa/news/_posts/2012-09-07-confoo-2013call-for-papers-is-now-open.md create mode 100644 fa/news/_posts/2012-10-12-cve-2012-4464-cve-2012-4466.md create mode 100644 fa/news/_posts/2012-10-12-poisoned-NUL-byte-vulnerability.md create mode 100644 fa/news/_posts/2012-10-12-ruby-1-9-3-p286-is-released.md create mode 100644 fa/news/_posts/2012-10-22-rupy-2012-coming-very-soon.md create mode 100644 fa/news/_posts/2012-11-09-ruby-1-9-3-p327-is-released.md create mode 100644 fa/news/_posts/2012-11-09-ruby19-hashdos-cve-2012-5371.md create mode 100644 fa/news/_posts/2012-11-10-fukuoka-ruby-award-2013.md create mode 100644 fa/news/_posts/2012-12-25-ruby-1-9-3-p362-is-released.md create mode 100644 fa/news/_posts/2013-01-17-ruby-1-9-3-p374-is-released.md create mode 100644 fa/news/_posts/2013-01-23-confoo-with-ruby-in-montreal.md create mode 100644 fa/news/_posts/2013-02-06-rdoc-xss-cve-2013-0256.md create mode 100644 fa/news/_posts/2013-02-06-ruby-1-9-3-p385-is-released.md create mode 100644 fa/news/_posts/2013-02-08-ruby-2-0-0-rc2-is-released.md create mode 100644 fa/news/_posts/2013-02-15-the-2013-ruby-hero-awards.md create mode 100644 fa/news/_posts/2013-02-16-the-barcelona-ruby-conference-call-for-papers-is-open.md create mode 100644 fa/news/_posts/2013-02-22-json-dos-cve-2013-0269.md create mode 100644 fa/news/_posts/2013-02-22-rexml-dos-2013-02-22.md create mode 100644 fa/news/_posts/2013-02-22-ruby-1-9-3-p392-is-released.md create mode 100644 fa/news/_posts/2013-02-24-ruby-2-0-0-p0-is-released.md create mode 100644 fa/news/_posts/2013-05-14-ruby-1-9-3-p429-is-released.md create mode 100644 fa/news/_posts/2013-05-14-ruby-2-0-0-p195-is-released.md create mode 100644 fa/news/_posts/2013-05-14-taint-bypass-dl-fiddle-cve-2013-2065.md create mode 100644 fa/news/_posts/2013-06-12-new-ruby-lang-org-released.md create mode 100644 fa/news/_posts/2013-06-27-hostname-check-bypassing-vulnerability-in-openssl-client-cve-2013-4073.md create mode 100644 fa/news/_posts/2013-06-27-ruby-1-8-7-p374-is-released.md create mode 100644 fa/news/_posts/2013-06-27-ruby-1-9-3-p448-is-released.md create mode 100644 fa/news/_posts/2013-06-27-ruby-2-0-0-p247-is-released.md create mode 100644 fa/news/_posts/2013-06-30-we-retire-1-8-7.md create mode 100644 fa/news/_posts/2013-08-06-status-issue.md create mode 100644 fa/news/_posts/2013-08-08-rip-raa.md create mode 100644 fa/news/_posts/2013-08-29-confoo-cfp.md create mode 100644 fa/news/_posts/2013-09-03-vietnamese-translation.md create mode 100644 fa/news/_posts/2013-09-07-we-use-fastly-cdn.md create mode 100644 fa/news/_posts/2013-09-23-ruby-2-1-0-preview1-is-released.md create mode 100644 fa/news/_posts/2013-09-28-design-contest.md create mode 100644 fa/news/_posts/2013-10-04-rubyconf-au-2014.md create mode 100644 fa/news/_posts/2013-11-21-fukuoka-ruby-award-2014.md create mode 100644 fa/news/_posts/2013-11-22-heap-overflow-in-floating-point-parsing-cve-2013-4164.md create mode 100644 fa/news/_posts/2013-11-22-ruby-1-9-3-p484-is-released.md create mode 100644 fa/news/_posts/2013-11-22-ruby-2-0-0-p353-is-released.md create mode 100644 fa/news/_posts/2013-11-22-ruby-2-1-0-preview2-is-released.md create mode 100644 fa/news/_posts/2013-11-30-russian-translation.md create mode 100644 fa/news/_posts/2013-12-09-rubyconf-tw-2014-cfp.md create mode 100644 fa/news/_posts/2013-12-14-rubyconf-india-2014.md create mode 100644 fa/news/_posts/2013-12-17-maintenance-of-1-8-7-and-1-9-2.md create mode 100644 fa/news/_posts/2013-12-20-ruby-2-1-0-rc1-is-released.md create mode 100644 fa/news/_posts/2013-12-21-ruby-version-policy-changes-with-2-1-0.md create mode 100644 fa/news/_posts/2013-12-25-ruby-2-1-0-is-released.md create mode 100644 fa/news/_posts/2014-01-10-ruby-1-9-3-will-end-on-2015.md create mode 100644 fa/news/_posts/2014-01-20-abril-pro-ruby-2014.md create mode 100644 fa/news/_posts/2014-02-12-the-2014-ruby-hero-awards.md create mode 100644 fa/news/_posts/2014-02-24-ruby-1-9-3-p545-is-released.md create mode 100644 fa/news/_posts/2014-02-24-ruby-2-0-0-p451-is-released.md create mode 100644 fa/news/_posts/2014-02-24-ruby-2-1-1-is-released.md create mode 100644 fa/news/_posts/2014-03-10-regression-of-hash-reject-in-ruby-2-1-1.md create mode 100644 fa/news/_posts/2014-03-14-rubyconf-taiwan-2014.md create mode 100644 fa/news/_posts/2014-03-15-eurucamp-2014.md create mode 100644 fa/news/_posts/2014-03-29-heap-overflow-in-yaml-uri-escape-parsing-cve-2014-2525.md create mode 100644 fa/news/_posts/2014-04-10-severe-openssl-vulnerability.md create mode 100644 fa/news/_posts/2014-05-09-dispute-of-vulnerability-cve-2014-2734.md create mode 100644 fa/news/_posts/2014-05-09-ruby-2-0-0-p481-is-released.md create mode 100644 fa/news/_posts/2014-05-09-ruby-2-1-2-is-released.md create mode 100644 fa/news/_posts/2014-05-16-ruby-1-9-3-p547-released.md create mode 100644 fa/news/_posts/2014-05-31-stopped-mailing-list-temporarily.md create mode 100644 fa/news/_posts/2014-06-16-rubyworld-conference-2014-speaker-invite.md create mode 100644 fa/news/_posts/2014-07-01-eol-for-1-8-7-and-1-9-2.md create mode 100644 fa/news/_posts/2014-07-26-rubykaigi-2014-registration-online.md create mode 100644 fa/news/_posts/2014-08-19-ruby-1-9-2-p330-released.md create mode 100644 fa/news/_posts/2014-09-10-confoo-cfp.md create mode 100644 fa/news/_posts/2014-09-18-ruby-2-2-0-preview1-released.md create mode 100644 fa/news/_posts/2014-09-19-ruby-2-0-0-p576-is-released.md create mode 100644 fa/news/_posts/2014-09-19-ruby-2-1-3-is-released.md create mode 100644 fa/news/_posts/2014-10-27-changing-default-settings-of-ext-openssl.md create mode 100644 fa/news/_posts/2014-10-27-rexml-dos-cve-2014-8080.md create mode 100644 fa/news/_posts/2014-10-27-ruby-1-9-3-p550-is-released.md create mode 100644 fa/news/_posts/2014-10-27-ruby-2-0-0-p594-is-released.md create mode 100644 fa/news/_posts/2014-10-27-ruby-2-1-4-released.md create mode 100644 fa/news/_posts/2014-11-03-tropicalrb-2015-cfp.md create mode 100644 fa/news/_posts/2014-11-13-rexml-dos-cve-2014-8090.md create mode 100644 fa/news/_posts/2014-11-13-ruby-1-9-3-p551-is-released.md create mode 100644 fa/news/_posts/2014-11-13-ruby-2-0-0-p598-is-released.md create mode 100644 fa/news/_posts/2014-11-13-ruby-2-1-5-is-released.md create mode 100644 fa/news/_posts/2014-11-28-ruby-2-2-0-preview2-released.md create mode 100644 fa/news/_posts/2014-12-18-ruby-2-2-0-rc1-released.md create mode 100644 fa/news/_posts/2014-12-25-ruby-2-2-0-released.md create mode 100644 fa/news/_posts/2015-02-23-support-for-ruby-1-9-3-has-ended.md create mode 100644 fa/news/_posts/2015-02-25-ruby-2-0-0-p643-is-released.md create mode 100644 fa/news/_posts/2015-03-03-ruby-2-2-1-released.md create mode 100644 fa/news/_posts/2015-03-06-google-summer-of-code-2015.md create mode 100644 fa/news/_posts/2015-04-13-ruby-2-0-0-p645-released.md create mode 100644 fa/news/_posts/2015-04-13-ruby-2-1-6-released.md create mode 100644 fa/news/_posts/2015-04-13-ruby-2-2-2-released.md create mode 100644 fa/news/_posts/2015-04-13-ruby-openssl-hostname-matching-vulnerability.md create mode 100644 fa/news/_posts/2015-06-30-ruby-prize-2015.md create mode 100644 fa/news/_posts/2015-07-14-rubyconftw-2015-call-for-proposals.md create mode 100644 fa/news/_posts/2015-08-04-rubyconf-taiwan-registration-is-open.md create mode 100644 fa/news/_posts/2015-08-18-ruby-2-0-0-p647-released.md create mode 100644 fa/news/_posts/2015-08-18-ruby-2-1-7-released.md create mode 100644 fa/news/_posts/2015-08-18-ruby-2-2-3-released.md create mode 100644 fa/news/_posts/2015-08-31-confoo-cfp.md create mode 100644 fa/news/_posts/2015-10-13-fukuoka-ruby-award-2016.md create mode 100644 fa/news/_posts/2015-11-11-ruby-2-3-0-preview1-released.md create mode 100644 fa/news/_posts/2015-12-11-ruby-2-3-0-preview2-released.md create mode 100644 fa/news/_posts/2015-12-16-ruby-2-0-0-p648-released.md create mode 100644 fa/news/_posts/2015-12-16-ruby-2-1-8-released.md create mode 100644 fa/news/_posts/2015-12-16-ruby-2-2-4-released.md create mode 100644 fa/news/_posts/2015-12-16-unsafe-tainted-string-usage-in-fiddle-and-dl-cve-2015-7551.md create mode 100644 fa/news/_posts/2015-12-25-ruby-2-3-0-released.md create mode 100644 fa/news/_posts/2016-02-24-support-plan-of-ruby-2-0-0-and-2-1.md create mode 100644 fa/news/_posts/2016-03-30-ruby-2-1-9-released.md create mode 100644 fa/news/_posts/2016-04-01-ruby-2-1-10-released.md create mode 100644 fa/news/_posts/2016-04-26-ruby-2-2-5-released.md create mode 100644 fa/news/_posts/2016-04-26-ruby-2-3-1-released.md create mode 100644 fa/news/_posts/2016-05-16-confoo-cfp.md create mode 100644 fa/news/_posts/2016-06-20-ruby-2-4-0-preview1-released.md create mode 100644 fa/news/_posts/2016-07-25-ruby-prize-2016.md create mode 100644 fa/news/_posts/2016-08-26-confoo-cfp.md create mode 100644 fa/news/_posts/2016-09-08-ruby-2-4-0-preview2-released.md create mode 100644 fa/news/_posts/2016-10-20-fukuoka-ruby-award-2017.md create mode 100644 fa/news/_posts/2016-11-09-ruby-2-4-0-preview3-released.md create mode 100644 fa/news/_posts/2016-11-15-ruby-2-2-6-released.md create mode 100644 fa/news/_posts/2016-11-15-ruby-2-3-2-released.md create mode 100644 fa/news/_posts/2016-11-21-ruby-2-3-3-released.md create mode 100644 fa/news/_posts/2016-12-12-ruby-2-4-0-rc1-released.md create mode 100644 fa/news/_posts/2016-12-25-ruby-2-4-0-released.md create mode 100644 fa/news/_posts/2017-03-22-ruby-2-4-1-released.md create mode 100644 fa/news/_posts/2017-03-28-ruby-2-2-7-released.md create mode 100644 fa/news/_posts/2017-03-30-ruby-2-3-4-released.md create mode 100644 fa/news/_posts/2017-04-01-support-of-ruby-2-1-has-ended.md create mode 100644 fa/news/_posts/2017-07-21-ruby-prize-2017.md create mode 100644 fa/news/_posts/2017-08-29-multiple-vulnerabilities-in-rubygems.md create mode 100644 fa/news/_posts/2017-09-14-json-heap-exposure-cve-2017-14064.md create mode 100644 fa/news/_posts/2017-09-14-openssl-asn1-buffer-underrun-cve-2017-14033.md create mode 100644 fa/news/_posts/2017-09-14-ruby-2-2-8-released.md create mode 100644 fa/news/_posts/2017-09-14-ruby-2-3-5-released.md create mode 100644 fa/news/_posts/2017-09-14-ruby-2-4-2-released.md create mode 100644 fa/news/_posts/2017-09-14-sprintf-buffer-underrun-cve-2017-0898.md create mode 100644 fa/news/_posts/2017-09-14-webrick-basic-auth-escape-sequence-injection-cve-2017-10784.md create mode 100644 fa/news/_posts/2017-10-10-ruby-2-5-0-preview1-released.md create mode 100644 fa/news/_posts/2017-12-14-net-ftp-command-injection-cve-2017-17405.md create mode 100644 fa/news/_posts/2017-12-14-ruby-2-2-9-released.md create mode 100644 fa/news/_posts/2017-12-14-ruby-2-3-6-released.md create mode 100644 fa/news/_posts/2017-12-14-ruby-2-4-3-released.md create mode 100644 fa/news/_posts/2017-12-14-ruby-2-5-0-rc1-released.md create mode 100644 fa/news/_posts/2017-12-25-ruby-2-5-0-released.md create mode 100644 fa/news/_posts/2017-12-27-fukuoka-ruby-award-2018.md create mode 100644 fa/news/_posts/2018-02-17-multiple-vulnerabilities-in-rubygems.md create mode 100644 fa/news/_posts/2018-02-24-ruby-2-6-0-preview1-released.md create mode 100644 fa/news/_posts/2018-03-28-buffer-under-read-unpack-cve-2018-8778.md create mode 100644 fa/news/_posts/2018-03-28-http-response-splitting-in-webrick-cve-2017-17742.md create mode 100644 fa/news/_posts/2018-03-28-large-request-dos-in-webrick-cve-2018-8777.md create mode 100644 fa/news/_posts/2018-03-28-poisoned-nul-byte-dir-cve-2018-8780.md create mode 100644 fa/news/_posts/2018-03-28-poisoned-nul-byte-unixsocket-cve-2018-8779.md create mode 100644 fa/news/_posts/2018-03-28-ruby-2-2-10-released.md create mode 100644 fa/news/_posts/2018-03-28-ruby-2-3-7-released.md create mode 100644 fa/news/_posts/2018-03-28-ruby-2-4-4-released.md create mode 100644 fa/news/_posts/2018-03-28-ruby-2-5-1-released.md create mode 100644 fa/news/_posts/2018-03-28-unintentional-file-and-directory-creation-with-directory-traversal-cve-2018-6914.md create mode 100644 fa/news/_posts/2018-05-31-ruby-2-6-0-preview2-released.md create mode 100644 fa/news/_posts/2018-06-20-support-of-ruby-2-2-has-ended.md create mode 100644 fa/news/_posts/2018-10-17-not-propagated-taint-flag-in-some-formats-of-pack-cve-2018-16396.md create mode 100644 fa/news/_posts/2018-10-17-openssl-x509-name-equality-check-does-not-work-correctly-cve-2018-16395.md create mode 100644 fa/news/_posts/2018-10-17-ruby-2-3-8-released.md create mode 100644 fa/news/_posts/2018-10-17-ruby-2-4-5-released.md create mode 100644 fa/news/_posts/2018-10-17-ruby-2-5-2-released.md create mode 100644 fa/news/_posts/2018-10-18-ruby-2-5-3-released.md create mode 100644 fa/news/_posts/2018-11-06-ruby-2-6-0-preview3-released.md create mode 100644 fa/news/_posts/2018-11-08-snap.md create mode 100644 fa/news/_posts/2018-11-29-fukuoka-ruby-award-2019.md create mode 100644 fa/news/_posts/2018-12-06-ruby-2-6-0-rc1-released.md create mode 100644 fa/news/_posts/2018-12-15-ruby-2-6-0-rc2-released.md create mode 100644 fa/news/_posts/2018-12-25-ruby-2-6-0-released.md create mode 100644 fa/news/_posts/2019-01-30-ruby-2-6-1-released.md create mode 100644 fa/news/_posts/2019-03-05-multiple-vulnerabilities-in-rubygems.md create mode 100644 fa/news/_posts/2019-03-13-ruby-2-5-4-released.md create mode 100644 fa/news/_posts/2019-03-13-ruby-2-6-2-released.md create mode 100644 fa/news/_posts/2019-03-15-ruby-2-5-5-released.md create mode 100644 fa/security/index.md create mode 100644 stylesheets/fonts/LICENSE create mode 100644 stylesheets/fonts/Vazir-Black.eot create mode 100644 stylesheets/fonts/Vazir-Black.ttf create mode 100644 stylesheets/fonts/Vazir-Black.woff create mode 100644 stylesheets/fonts/Vazir-Black.woff2 create mode 100644 stylesheets/fonts/Vazir-Bold.eot create mode 100644 stylesheets/fonts/Vazir-Bold.ttf create mode 100644 stylesheets/fonts/Vazir-Bold.woff create mode 100644 stylesheets/fonts/Vazir-Bold.woff2 create mode 100644 stylesheets/fonts/Vazir-Light.eot create mode 100644 stylesheets/fonts/Vazir-Light.ttf create mode 100644 stylesheets/fonts/Vazir-Light.woff create mode 100644 stylesheets/fonts/Vazir-Light.woff2 create mode 100644 stylesheets/fonts/Vazir-Medium.eot create mode 100644 stylesheets/fonts/Vazir-Medium.ttf create mode 100644 stylesheets/fonts/Vazir-Medium.woff create mode 100644 stylesheets/fonts/Vazir-Medium.woff2 create mode 100644 stylesheets/fonts/Vazir-Thin.eot create mode 100644 stylesheets/fonts/Vazir-Thin.ttf create mode 100644 stylesheets/fonts/Vazir-Thin.woff create mode 100644 stylesheets/fonts/Vazir-Thin.woff2 create mode 100644 stylesheets/fonts/Vazir.eot create mode 100644 stylesheets/fonts/Vazir.ttf create mode 100644 stylesheets/fonts/Vazir.woff create mode 100644 stylesheets/fonts/Vazir.woff2 create mode 100644 stylesheets/rtl.css diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8723f37b14..40ebcb3c38 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,6 +12,8 @@ en/ @ruby/www-ruby-lang-org-editorial es/ @ruby/www-ruby-lang-org-i18n-es +fa/ @ruby/www-ruby-lang-org-i18n-fa + fr/ @ruby/www-ruby-lang-org-i18n-fr id/ @ruby/www-ruby-lang-org-i18n-id diff --git a/_config.yml b/_config.yml index 1004b1bfe1..05253cd35e 100644 --- a/_config.yml +++ b/_config.yml @@ -99,6 +99,21 @@ locales: url: /es/security - text: Acerca de Ruby url: /es/about + fa: + - text: دانلودها + url: /fa/downloads + - text: مستندات + url: /fa/documentation + - text: کتابخانه‌ها + url: /fa/libraries + - text: جامعه + url: /fa/community + - text: اخبار + url: /fa/news + - text: امنیت + url: /fa/security + - text: درباره روبی + url: /fa/about fr: - text: Téléchargements url: /fr/downloads @@ -293,6 +308,8 @@ locales: cx_id: "013598269713424429640:g5orptiw95w" es: text: Buscar + fa: + text: جستجو fr: text: Recherche cx_id: "016749562256550695330:efcmgh3a1ac" @@ -325,6 +342,7 @@ locales: de: "Der beste Freund eines Programmierers" en: "A Programmer's Best Friend" es: "El mejor amigo de un desarrollador" + fa: "بهترین دوست یک برنامه نویس" fr: "A Programmer's Best Friend" id: "Sahabat Terbaik Programmer" it: "Il migliore amico dei programmatori" @@ -343,6 +361,7 @@ locales: de: "Ruby" en: "Ruby" es: "Ruby" + fa: "روبی" fr: "Ruby" id: "Ruby" it: "Ruby" @@ -361,6 +380,7 @@ locales: de: [Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember] en: [January, February, March, April, May, June, July, August, September, October, November, December] es: [Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre] + fa: [ژانویه, فوریه, مارس, آوریل, مه, ژوئن, جولای, اوت, سپتامبر, اکتبر, نوامبر, دسامبر] fr: [Janvier, Février, Mars, Avril, Mai, Juin, Juillet, Août, Septembre, Octobre, Novembre, Décembre] id: [Januari, Februari, Maret, April, Mei, Juni, Juli, Agustus, September, Oktober, November, Desember] it: [Gennaio, Febbraio, Marzo, Aprile, Maggio, Giugno, Luglio, Agosto, Settembre, Ottobre, Novembre, Dicembre] @@ -375,6 +395,7 @@ locales: de: "Geschrieben von AUTHOR am %-d.%-m.%Y" en: "Posted by AUTHOR on %-d %b %Y" es: "Publicado por AUTHOR el %Y-%m-%d" + fa: "ارسال شده توسط AUTHOR در تاریخ %-d %b %Y" fr: "Posté par AUTHOR le %Y-%m-%d" id: "Ditulis oleh AUTHOR tanggal %Y-%m-%d" it: "Inserito da AUTHOR il %Y-%m-%d" @@ -393,6 +414,7 @@ locales: de: "Übersetzt von" en: "Translated by" es: "Traducción de" + fa: "ترجمه شده توسط" fr: "Traduit par" id: "Diterjemahkan oleh" it: "Tradotto da" @@ -423,6 +445,10 @@ locales: title: Noticias de Ruby por RSS description: Las últimas noticias de ruby-lang.org en español. lang_code: es-ES + fa: + title: اخبار روبی + description: آخرین اخبار از ruby-lang.org. + lang_code: fa-IR fr: title: Actualités de Ruby-lang description: Les dernières news sur ruby-lang.org. @@ -521,6 +547,18 @@ locales: monthly_archives: Noticias por mes yearly_archive_link: "Noticias de %Y" monthly_archive_link: "%B %Y" + fa: + other_news: سایر اخبار + more_news: اخبار بیشتر... + continue: در ادامه بخوانید... + back_to_year: "بازگشت به بایگانی %Y" + recent_news: آخرین اخبار + yearly_archive_title: "بایگانی %Y" + monthly_archive_title: "بایگانی %Y %B" + yearly_archives: بایگانی سالیانه + monthly_archives: بایگانی ماهانه + yearly_archive_link: "بایگانی %Y" + monthly_archive_link: "%B %Y" fr: other_news: Autres actualités more_news: Plus d’actualités... @@ -903,6 +941,66 @@ locales: recent_news: text: En español url: /es/feeds/news.rss + fa: + get_started: + text: شروع کنید، آسان است! + try_ruby: + text: روبی را امتحان کن! (در مرورگر خود) + <<: *try_ruby + quickstart: + text: روبی در ۲۰ دقیقه + url: /fa/documentation/quickstart/ + ruby_from_other_languages: + text: روبی از زبان‌های دیگر + url: /fa/documentation/ruby-from-other-languages/ + explore: + text: کاوش در دنیای جدید… + documentation: + text: مستندات + url: /fa/documentation/ + # books: + # text: کتاب‌ها + rubybib: + text: تحقیقات دانشگاهی + <<: *rubybib + libraries: + text: کتابخانه‌ها + url: /fa/libraries/ + success_stories: + text: داستان‌های موفقیت + url: /fa/documentation/success-stories/ + participate: + text: مشارکت در یک جامعه دوستانه و رو به رشد. + mailing_lists: + text: فهرست‌های ایمیل + url: /fa/community/mailing-lists/ + description: | + در مورد روبی با برنامه نویسان سراسر جهان صحبت کنید. + user_groups: + text: گروه‌های کاربری + url: /fa/community/user-groups/ + description: | + با Rubyists در منطقه خود تماس بگیرید. + weblogs: + text: وبلاگ‌ها + url: /fa/community/weblogs/ + description: | + اطلاعات بیشتر در مورد آنچه که الان در جامعه روبی اتفاق می‌افتد. + ruby_core: + text: هسته روبی + url: /fa/community/ruby-core/ + description: | + Help polish the rough edges of the latest Ruby. + issue_tracking: + text: ردیابی موضوع + url: https://bugs.ruby-lang.org/ + description: | + گزارش یا کمک به حل مسائل در روبی. + syndicate: + text: سندیکا + recent_news: + text: آخرین اخبار (آر‌اس‌اس) + url: /fa/feeds/news.rss fr: get_started: text: Lancez-vous, c’est facile ! @@ -1640,6 +1738,15 @@ locales: subscribe: Subscribe unsubscribe: Unsubscribe submit: Enviar + fa: + list: Mailing List + first_name: نام + last_name: نام خانوادگی + email: آدرس ایمیل + action: عمل + subscribe: اشتراک + unsubscribe: لغو اشتراک + submit: ثبت فرم fr: list: Liste de diffusion first_name: Prénom @@ -1753,6 +1860,7 @@ locales: bg: "Този сайт на други езици:" de: "Diese Website in anderen Sprachen:" en: "This site in other languages:" + fa: "این سایت به زبان‌های دیگر:" fr: "Autres langues disponibles :" id: "Situs ini dalam bahasa lain:" it: "Questo sito in altre lingue:" @@ -1778,6 +1886,9 @@ locales: Si quieres contribuir, por favor hazlo en GitHub o contacta a nuestro webmaster si tienes preguntas o comentarios. + fa: | + این وب‌سایت + با افتخار توسط اعضای جامعه روبی نگهداری می‌شود. fr: | Ce site est propulsé par Ruby et Jekyll. Il est fièrement maintenu par des membres de la communauté Ruby. diff --git a/_includes/languages.html b/_includes/languages.html index 7fb863ca8a..980ce0c817 100644 --- a/_includes/languages.html +++ b/_includes/languages.html @@ -8,6 +8,7 @@ Deutsch, English, Español, +فارسی, Français, Bahasa Indonesia, Italiano, diff --git a/_layouts/default.html b/_layouts/default.html index 603c5eea3c..0012312d41 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -19,10 +19,13 @@ - + {% if page.lang == "fa" %} + + {% endif %} + {% include rss_discovery.html %} - + {% if layout.javascript != null %} @@ -30,6 +33,7 @@ {% endfor %} {% endif %} + {% capture homepage_url %}/{{ page.lang }}/{% endcapture %} diff --git a/fa/about/index.md b/fa/about/index.md new file mode 100644 index 0000000000..3cc558561e --- /dev/null +++ b/fa/about/index.md @@ -0,0 +1,240 @@ +--- +layout: page +title: "درباره روبی" +lang: fa +--- + +Wondering why Ruby is so popular? Its fans call it a beautiful, artful +language. And yet, they say it’s handy and practical. What gives? +{: .summary} + +### The Ideals of Ruby’s Creator + +Ruby is a language of careful balance. Its creator, [Yukihiro “Matz” +Matsumoto][matz], blended parts of his favorite languages (Perl, Smalltalk, +Eiffel, Ada, and Lisp) to form a new language that balanced functional +programming with imperative programming. + +He has often said that he is “trying to make Ruby natural, not simple,” +in a way that mirrors life. + +Building on this, he adds: + +> Ruby is simple in appearance, but is very complex inside, just like +> our human body[1](#fn1). + +### About Ruby’s Growth + +Since its public release in 1995, Ruby has drawn devoted coders +worldwide. In 2006, Ruby achieved mass acceptance. With active user +groups formed in the world’s major cities and Ruby-related conferences +filled to capacity. + +Ruby-Talk, the primary [mailing list](/en/community/mailing-lists/) for +discussion of the Ruby language, climbed to an average of 200 messages +per day in 2006. It has dropped in recent years as the size of the +community pushed discussion from one central list into many smaller +groups. + +Ruby is ranked among the top 10 on most of the indices that measure +the growth and popularity of programming languages worldwide +(such as the [TIOBE index][tiobe]). Much of the growth is attributed to the +popularity of software written in Ruby, particularly the +[Ruby on Rails][ror] web framework. + +Ruby is also [completely free]({{ site.license.url }}). Not only free of charge, but +also free to use, copy, modify, and distribute. + +### Seeing Everything as an Object + +Initially, Matz looked at other languages to find an ideal syntax. +Recalling his search, he said, “I wanted a scripting language that was +more powerful than Perl, and more object-oriented than +Python[2](#fn2).” + +In Ruby, everything is an object. Every bit of information and code can +be given their own properties and actions. Object-oriented programming +calls properties by the name *instance variables* and actions are known +as *methods*. Ruby’s pure object-oriented approach is most commonly +demonstrated by a bit of code which applies an action to a number. + +{% highlight ruby %} +5.times { print "We *love* Ruby -- it's outrageous!" } +{% endhighlight %} + +In many languages, numbers and other primitive types are not objects. +Ruby follows the influence of the Smalltalk language by giving methods +and instance variables to all of its types. This eases one’s use of +Ruby, since rules applying to objects apply to all of Ruby. + +### Ruby’s Flexibility + +Ruby is seen as a flexible language, since it allows its users to freely +alter its parts. Essential parts of Ruby can be removed or redefined, at +will. Existing parts can be added upon. Ruby tries not to restrict the +coder. + +For example, addition is performed with the plus (`+`) operator. But, if +you’d rather use the readable word `plus`, you could add such a method +to Ruby’s builtin `Numeric` class. + +{% highlight ruby %} +class Numeric + def plus(x) + self.+(x) + end +end + +y = 5.plus 6 +# y is now equal to 11 +{% endhighlight %} + +Ruby’s operators are syntactic sugar for methods. You can redefine them +as well. + +### Blocks: a Truly Expressive Feature + +Ruby’s block are also seen as a source of great flexibility. A +programmer can attach a closure to any method, describing how that +method should act. The closure is called a *block* and has become one of +the most popular features for newcomers to Ruby from other imperative +languages like PHP or Visual Basic. + +Blocks are inspired by functional languages. Matz said, “in Ruby +closures, I wanted to respect the Lisp culture[3](#fn3).” + +{% highlight ruby %} +search_engines = + %w[Google Yahoo MSN].map do |engine| + "http://www." + engine.downcase + ".com" + end +{% endhighlight %} + +In the above code, the block is described inside the `do ... end` +construct. The `map` method applies the block to the provided list of +words. Many other methods in Ruby leave a hole open for a coder to write +their own block to fill in the details of what that method should do. + +### Ruby and the Mixin + +Unlike many object-oriented languages, Ruby features single inheritance +only, **on purpose**. But Ruby knows the concept of modules (called +Categories in Objective-C). Modules are collections of methods. + +Classes can mixin a module and receive all its methods for free. For +example, any class which implements the `each` method can mixin the +`Enumerable` module, which adds a pile of methods that use `each` for +looping. + +{% highlight ruby %} +class MyArray + include Enumerable +end +{% endhighlight %} + +Generally, Rubyists see this as a much clearer way than multiple +inheritance, which is complex and can be too restrictive. + +### Ruby’s Visual Appearance + +While Ruby often uses very limited punctuation and usually prefers +English keywords, some punctuation is used to decorate Ruby. Ruby needs +no variable declarations. It uses simple naming conventions to denote +the scope of variables. + +* `var` could be a local variable. +* `@var` is an instance variable. +* `$var` is a global variable. + +These sigils enhance readability by allowing the programmer to easily +identify the roles of each variable. It also becomes unnecessary to use +a tiresome `self.` prepended to every instance member. + +### Beyond the Basics + +Ruby has a wealth of other features, among which are the following: + +* Ruby has exception handling features, like Java or Python, to make it + easy to handle errors. + +* Ruby features a true mark-and-sweep garbage collector for all Ruby + objects. No need to maintain reference counts in extension libraries. + As Matz says, “This is better for your health.” + +* Writing C extensions in Ruby is easier than in Perl or Python, with a + very elegant API for calling Ruby from C. This includes calls for + embedding Ruby in software, for use as a scripting language. A SWIG + interface is also available. + +* Ruby can load extension libraries dynamically if an OS allows. + +* Ruby features OS independent threading. Thus, for all platforms on + which Ruby runs, you also have multithreading, regardless of if the OS + supports it or not, even on MS-DOS! + +* Ruby is highly portable: it is developed mostly on GNU/Linux, but + works on many types of UNIX, macOS, Windows, DOS, BeOS, OS/2, etc. + +### Other Implementations of Ruby + +Ruby, as a language, has a few different implementations. +This page has been discussing the reference implementation, in the +community often referred to as **MRI** (“Matz’s Ruby Interpreter”) +or **CRuby** (since it is written in C), but there are also others. +They are often useful in certain situations, provide extra +integration to other languages or environments, or have special features +that MRI doesn’t. + +Here’s a list: + +* [JRuby][jruby] is Ruby atop the JVM (Java Virtual Machine), utilizing the + JVM’s optimizing JIT compilers, garbage collectors, concurrent + threads, tool ecosystem, and vast collection of libraries. +* [Rubinius][rubinius] is ‘Ruby written in Ruby’. Built on top of LLVM, + Rubinius sports a nifty virtual machine that other languages are being + built on top of, too. +* [TruffleRuby][truffleruby] is a high performance Ruby implementation on top of + GraalVM. +* [mruby][mruby] is a lightweight implementation of the Ruby language + that can be linked and embedded within an application. + Its development is led by Ruby’s creator Yukihiro “Matz” Matsumoto. +* [IronRuby][ironruby] is an implementation “tightly integrated with the .NET + Framework”. +* [MagLev][maglev] is “a fast, stable, Ruby implementation with integrated + object persistence and distributed shared cache”. +* [Cardinal][cardinal] is a “Ruby compiler for [Parrot][parrot] Virtual Machine” + (Perl 6). + +For a more complete list, see [Awesome Rubies][awesome-rubies]. + +### References + +1 Matz, speaking on the Ruby-Talk mailing list, [May 12th, +2000][blade]. +{: #fn1} + +2 Matz, in [An Interview with the Creator of Ruby][linuxdevcenter], Nov. +29th, 2001. +{: #fn2} + +3 Matz, in [Blocks and Closures in Ruby][artima], December 22nd, +2003. +{: #fn3} + + + +[matz]: http://www.rubyist.net/~matz/ +[blade]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/2773 +[ror]: http://rubyonrails.org/ +[linuxdevcenter]: http://www.linuxdevcenter.com/pub/a/linux/2001/11/29/ruby.html +[artima]: http://www.artima.com/intv/closures2.html +[tiobe]: http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html +[jruby]: http://jruby.org +[rubinius]: http://rubini.us +[truffleruby]: https://github.com/oracle/truffleruby +[mruby]: http://www.mruby.org/ +[ironruby]: http://www.ironruby.net +[maglev]: http://maglev.github.io +[cardinal]: https://github.com/parrot/cardinal +[parrot]: http://parrot.org +[awesome-rubies]: https://github.com/planetruby/awesome-rubies diff --git a/fa/about/license.txt b/fa/about/license.txt new file mode 100644 index 0000000000..426810a7fb --- /dev/null +++ b/fa/about/license.txt @@ -0,0 +1,56 @@ +Ruby is copyrighted free software by Yukihiro Matsumoto . +You can redistribute it and/or modify it under either the terms of the +2-clause BSDL (see the file BSDL), or the conditions below: + + 1. You may make and give away verbatim copies of the source form of the + software without restriction, provided that you duplicate all of the + original copyright notices and associated disclaimers. + + 2. You may modify your copy of the software in any way, provided that + you do at least ONE of the following: + + a) place your modifications in the Public Domain or otherwise + make them Freely Available, such as by posting said + modifications to Usenet or an equivalent medium, or by allowing + the author to include your modifications in the software. + + b) use the modified software only within your corporation or + organization. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 3. You may distribute the software in object code or binary form, + provided that you do at least ONE of the following: + + a) distribute the binaries and library files of the software, + together with instructions (in the manual page or equivalent) + on where to get the original distribution. + + b) accompany the distribution with the machine-readable source of + the software. + + c) give non-standard binaries non-standard names, with + instructions on where to get the original software distribution. + + d) make other distribution arrangements with the author. + + 4. You may modify and include the part of the software into any other + software (possibly commercial). But some files in the distribution + are not written by the author, so that they are not under these terms. + + For the list of those files and their copying conditions, see the + file LEGAL. + + 5. The scripts and library files supplied as input to or produced as + output from the software do not automatically fall under the + copyright of the software, but belong to whomever generated them, + and may be sold commercially, and may be aggregated with this + software. + + 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. diff --git a/fa/about/logo/index.md b/fa/about/logo/index.md new file mode 100644 index 0000000000..c9505d798c --- /dev/null +++ b/fa/about/logo/index.md @@ -0,0 +1,22 @@ +--- +layout: page +title: "لوگوی روبی" +lang: fa +--- + +![لوگوی روبی][logo] + +کپی‌رایت لوگوی روبی © ۲۰۰۶، یوکیهیرو ماتسوموتو. + +این مجوز تحت شرایط +[مجوز کرییتیو کامنز اشتراک همسان ۲٫۵][cc-by-sa] است. + + +## دانلود + +[کیت لوگوی روبی][logo-kit] شامل لوگو روبی در فرمت‌های مختلف (PNG, JPG, PDF, AI, SWF, XAR). + + +[logo]: /images/header-ruby-logo.png +[logo-kit]: https://cache.ruby-lang.org/pub/misc/logo/ruby-logo-kit.zip +[cc-by-sa]: https://creativecommons.org/licenses/by-sa/2.5/deed.fa diff --git a/fa/about/website/index.md b/fa/about/website/index.md new file mode 100644 index 0000000000..39f6ca51a6 --- /dev/null +++ b/fa/about/website/index.md @@ -0,0 +1,60 @@ +--- +layout: page +title: "درباره وب‌سایت روبی" +lang: fa +--- + +این وب‌سایت توسط روبی با استفاده از [جکیل][jekyll] تولید شده است،
+سورس آن در [گیت‌هاب][github-repo] میزبانی می‌شود. + +طراحی بصری توسط [جیسون زیمدرس][jzimdars].
+براساس طراحی قبلی توسط تیم هویت بصری روبی. + +کپی رایت [لوگوی روبی][logo] © ۲۰۰۶، یوکیهیرو ماتسوموتو. + + +## گزارش مشکلات ## + + برای گزارش مشکل، از سیستم [ردیاب موضوع][github-issues] استفاده کنید یا با [مدیر وب‌سایت][webmaster] ما تماس بگیرید (به زبان انگلیسی). + + +## چگونه مشارکت کنیم ## + +این وب‌سایت با افتخار توسط اعضای جامعه روبی نگهداری می‌شود. + +اگر می‌خواهید مشارکت کنید، [دستورالعمل‌های مشارکت][github-wiki] را بخوانید و فقط شروع به باز کردن issue یا pull request کنید! + + +## تقدیرنامه‌ها ## + +ما از همه متعهدین، نویسندگان، مترجمان و دیگر مشارکت کنندگان این وب‌سایت سپاسگزاریم. + +همچنین از سازمان‌هایی که از ما حمایت می‌کنند سپاسگزاریم: + + * [Ruby Association][rubyassociation] (میزبانی) + * [Heroku][heroku] (میزبانی) + * [IIJ][iij] (میزبانی) + * [GlobalSign][globalsign] (گواهینامه SSL) + * [Fastly][fastly] (CDN) + * [Hatena][hatena] ([mackerel][mackerel]، نظارت بر سرور) + * [![CloudCore][cloudcore-logo] CloudCore][cloudcore] (ساخت سرور) + * [Ruby no Kai][rubynokai] (ساخت سرور) + + +[logo]: /fa/about/logo/ +[webmaster]: mailto:webmaster@ruby-lang.org +[jekyll]: http://www.jekyllrb.com/ +[jzimdars]: https://twitter.com/jasonzimdars +[github-repo]: https://github.com/ruby/www.ruby-lang.org/ +[github-issues]: https://github.com/ruby/www.ruby-lang.org/issues +[github-wiki]: https://github.com/ruby/www.ruby-lang.org/wiki +[rubyassociation]: http://www.ruby.or.jp +[heroku]: https://www.heroku.com/ +[iij]: http://www.iij.ad.jp +[globalsign]: https://www.globalsign.com +[fastly]: http://www.fastly.com +[hatena]: http://hatenacorp.jp/ +[mackerel]: https://mackerel.io/ +[cloudcore]: http://www.cloudcore.jp/?utm_source=ad&utm_medium=ad&utm_content=dev&utm_campaign=vps +[cloudcore-logo]: http://www.cloudcore.jp/develop/links/images/74x36_white.gif +[rubynokai]: http://ruby-no-kai.org/ diff --git a/fa/community/conferences/index.md b/fa/community/conferences/index.md new file mode 100644 index 0000000000..227d37bbc2 --- /dev/null +++ b/fa/community/conferences/index.md @@ -0,0 +1,92 @@ +--- +layout: page +title: "Ruby Conferences" +lang: en +--- + +Ruby programmers around the world are getting involved in more and more +conferences, where they get together to share reports on +work-in-progress, discuss the future of Ruby, and welcome newcomers to +the Ruby community. + +[RubyConferences.org][rc] is a simple list of Ruby-specific conferences, +published collaboratively with the Ruby community. There you will find +event dates, location, CFP (Call For Proposals) and Registration information. + + +### Major Ruby Conferences + +[RubyConf][1] +: Every year since 2001, [Ruby Central, Inc.][2] has produced RubyConf, + the International Ruby conference. Attendance grew by a factor of ten + between 2001 and 2006. RubyConf has provided a forum for presentations + about Ruby technologies by their creators, including talks by + Nathaniel Talbot on Test Unit, Jim Weirich on Rake, David Heinemeier + Hansson on Ruby on Rails, Why the Lucky Stiff on the YAML library, and + Sasada Koichi on YARV. Matz has attended, and spoken at, all the + RubyConfs but one. + +[RubyKaigi][3] +: The first Japanese Ruby conference, RubyKaigi 2006, took place in + Odaiba. RubyKaigi provides many new and exciting talks by Matz and + other Rubyists in every year. + +[EuRuKo (European Ruby Conference)][4] +: The first annual European Ruby Conference (EuRuKo) was held in + Karlsruhe, Germany, in 2003. Organized by a team of German Rubyists + including Armin Roehrl and Michael Neumann, EuRuKo emerged as the + second annual Ruby event, starting two years after RubyConf. + +### Regional Ruby Conferences + +[Ruby Central][2] administers a [Regional Conference Grant Program][6], +to offset expenses for local and regional groups wanting to organize +events. + +Ruby Central has also teamed up with [SVForum][7] (previously known as SDForum) +to produce the Silicon Valley Ruby Conference, entering its second year in 2007. + +[RubyNation][8] is an annual Ruby conference serving the Virginia, West +Virginia, Maryland, and Washington, DC areas. + +[WindyCityRails][9] is an annual gathering for all who are passionate about +Ruby on Rails. The Chicago-based conference has served the Ruby +community since 2008. + +[Steel City Ruby][16]: Pittsburg, PA + +[GoRuCo][19]: New York City's annual Ruby conference. A one-day single-track conference. + +[DeccanRubyConf][20]: Pune's (India) annual Ruby conference, +themed around fun activities filled around the day. +It is a single-day single-track conference. + +### Ruby At Other Conferences + +There has been a Ruby track at the [O’Reilly Open Source Conference][10] +(OSCON) since 2004, and an increasing presence on the part of Ruby and +Rubyists at other non-Ruby-specific gatherings. A number of conferences +have also been devoted to [Ruby on Rails][11], including Ruby Central’s +[RailsConf][12], [RailsConf Europe][13] (co-produced in 2006 by Ruby +Central and [Skills Matter][14], and in 2007 by Ruby Central and +O’Reilly), and Canada on Rails. + + + +[rc]: http://rubyconferences.org/ +[1]: http://rubyconf.org/ +[2]: http://rubycentral.org +[3]: http://rubykaigi.org/ +[4]: http://euruko.org +[6]: http://rubycentral.org/community/grant +[7]: http://www.svforum.org +[8]: http://rubynation.org/ +[9]: http://windycityrails.org +[10]: http://conferences.oreillynet.com/os2006/ +[11]: http://www.rubyonrails.org +[12]: http://www.railsconf.org +[13]: http://europe.railsconf.org +[14]: http://www.skillsmatter.com +[16]: http://steelcityruby.org/ +[19]: http://goruco.com/ +[20]: http://www.deccanrubyconf.org/ diff --git a/fa/community/index.md b/fa/community/index.md new file mode 100644 index 0000000000..2c2fc2a80d --- /dev/null +++ b/fa/community/index.md @@ -0,0 +1,59 @@ +--- +layout: page +title: "Community" +lang: en +--- + +The community that grows up around a programming language is one of its +most important strengths. Ruby has a vibrant and growing community that +is friendly towards people of all skill levels. +{: .summary} + +If you are interested in getting involved, here are a couple of places +to start: + +[Ruby User Groups](user-groups/) +: Your local Ruby user group is a great place to network with other Ruby + programmers. Ruby user groups are self-organizing and typically + feature monthly meetings, a mailing list, a Web site, and if you are + lucky, frequent codefests. + +[Ruby Mailing Lists and Newsgroups](mailing-lists/) +: Ruby has an assortment of lists on different topics and in several + languages. If you have questions about Ruby, asking them on a mailing + list is a great way to get answers. + +[Ruby on IRC (#ruby)](irc://irc.freenode.net/ruby) +: The Ruby Language IRC Channel is a wonderful way to chat with fellow + Rubyists. + +[Ruby Core](ruby-core/) +: Now is a fantastic time to follow Ruby’s development. + If you are interested in helping with Ruby, start here. + +[Ruby Blogs](weblogs/) +: Very little happens in the Ruby community that is not talked about on + the blogs. We’ve got a nice list of suggestions for you here for + getting plugged in. + +[Ruby Conferences](conferences/) +: Ruby programmers around the world are getting involved in more and + more conferences, where they get together to share reports on + work-in-progress, discuss the future of Ruby, and welcome newcomers to + the Ruby community. + +[Podcasts](podcasts/) +: If you like to hear about Ruby rather than read about you can listen + to podcasts which cover new Ruby or gem releases, interviews and + discussions between Ruby programmers, contributors, and maintainers. + +General Ruby Information +: * [Ruby Central][ruby-central] + * [Ruby at Open Directory Project][ruby-opendir] + * [Rails at Open Directory Project][rails-opendir] + + + +[ruby-central]: http://rubycentral.org/ +[ruby-opendir]: https://dmoztools.net/Computers/Programming/Languages/Ruby/ +[rails-opendir]: https://dmoztools.net/Computers/Programming/Languages/Ruby/Software/Frameworks/Rails/ diff --git a/fa/community/mailing-lists/index.md b/fa/community/mailing-lists/index.md new file mode 100644 index 0000000000..8b67cde270 --- /dev/null +++ b/fa/community/mailing-lists/index.md @@ -0,0 +1,49 @@ +--- +layout: page +title: "Mailing Lists" +lang: en +--- + +Mailing-lists are a great way to keep your finger on the pulse of the +Ruby community. +{: .summary} + +Ruby has four primary English speaking mailing lists: + +Ruby-Talk +: This is the most popular mailing-list and deals with general topics + about Ruby. ([Archives][3], [Posting Guidelines][guidelines]) + +Ruby-Core +: This list deals with core and implementation topics about Ruby, often + used to run patches for review. ([Archives][4]) + +Ruby-Doc +: This list is for discussing documentation standards and tools for + Ruby. ([Archives][5]) + +Ruby-CVS +: This list reports all commits to Ruby’s Subversion repository. + +The comp.lang.ruby Newsgroup +: Those who prefer Usenet over mailing lists will want to checkout the + [comp.lang.ruby](news:comp.lang.ruby) newsgroup. ([FAQ][clrFAQ]) + +See [lists.ruby-lang.org](http://lists.ruby-lang.org) +for more information about all mailing lists on ruby-lang.org, +including the lists in Japanese language. + +## Subscribe or Unsubscribe + +{% include subscription-form.html %} + +If you fail to receive a confirmation e-mail using the form, try +subscribing the [manual way](manual-instructions/). + + + +[guidelines]: ruby-talk-guidelines/ +[clrFAQ]: http://rubyhacker.com/clrFAQ.html +[3]: http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml +[4]: http://blade.nagaokaut.ac.jp/ruby/ruby-core/index.shtml +[5]: http://lists.ruby-lang.org/pipermail/ruby-doc/ diff --git a/fa/community/mailing-lists/manual-instructions/index.md b/fa/community/mailing-lists/manual-instructions/index.md new file mode 100644 index 0000000000..e60d18366f --- /dev/null +++ b/fa/community/mailing-lists/manual-instructions/index.md @@ -0,0 +1,63 @@ +--- +layout: page +title: "Manual Mailing List Instructions" +lang: en +--- + +NOTE: If you cannot subscribe, please refer to +[lists.ruby-lang.org](http://lists.ruby-lang.org). + +To subscribe to a mailing list, please send a plain text mail +with the following mail body (not the subject) to the automated +“controller” address: + + subscribe +{: .code} + +Ruby-Talk +: For the Ruby-Talk list, the controller address is + [ruby-talk-request@ruby-lang.org](mailto:ruby-talk-request@ruby-lang.org), the + posting address is + [ruby-talk@ruby-lang.org](mailto:ruby-talk@ruby-lang.org), and the + human administrator address is + [ruby-talk-owner@ruby-lang.org](mailto:ruby-talk-owner@ruby-lang.org). + +Ruby-Core +: For the Ruby-Core list, the controller address is + [ruby-core-request@ruby-lang.org](mailto:ruby-core-request@ruby-lang.org), the + posting address is + [ruby-core@ruby-lang.org](mailto:ruby-core@ruby-lang.org), and the + “human” administrator address is + [ruby-core-owner@ruby-lang.org](mailto:ruby-core-owner@ruby-lang.org). + +Ruby-Doc +: For the Ruby-Doc list, the controller address is + [ruby-doc-request@ruby-lang.org](mailto:ruby-doc-request@ruby-lang.org), the + posting address is + [ruby-doc@ruby-lang.org](mailto:ruby-doc@ruby-lang.org), and the + “human” administrator address is + [ruby-doc-owner@ruby-lang.org](mailto:ruby-doc-owner@ruby-lang.org). + +Ruby-CVS +: For the Ruby-CVS list, the controller address is + [ruby-cvs-request@ruby-lang.org](mailto:ruby-cvs-request@ruby-lang.org), the + posting address is + [ruby-cvs@ruby-lang.org](mailto:ruby-cvs@ruby-lang.org), and the + “human” administrator address is + [ruby-cvs-owner@ruby-lang.org](mailto:ruby-cvs-owner@ruby-lang.org). + +### Unsubscribing + +To unsubscribe from a list, send a mail which body is “unsubscribe” to +the **controller address**: + + unsubscribe +{: .code} + +Make sure to send a plain text mail, an HTML mail might not work. + +### Getting Help + +To see the list of commands, send a mail which body is “help” to the +controller address. + diff --git a/fa/community/mailing-lists/ruby-talk-guidelines/index.md b/fa/community/mailing-lists/ruby-talk-guidelines/index.md new file mode 100644 index 0000000000..a9879ea121 --- /dev/null +++ b/fa/community/mailing-lists/ruby-talk-guidelines/index.md @@ -0,0 +1,82 @@ +--- +layout: page +title: "Posting Guidelines for the Ruby-Talk Mailing List" +lang: en +--- + +You should follow these guidelines when posting to the ruby-talk mailing list. +{: .summary} + + +1. **Always** be friendly, considerate, tactful, and tasteful. We want to + keep this list hospitable to the growing ranks of newbies, very + young people, and their teachers, as well as cater to fire breathing + wizards. :-) + +2. Keep your content relevant and easy to follow. Try to keep your + content brief and to the point, but also try to include all relevant + information. + + 1. The general format guidelines (aka Netiquette) are + matters of common sense and common courtesy that make life + easier for third parties to follow along (in real time or when + perusing archives): + + * **Please note:** + Include quoted text from previous posts **before** your responses + and **selectively** quote as much as is relevant. + * Use **plain text**; don't use HTML, RTF, or Word. + Most email programs have an option for this; if yours doesn't, + get a (free) program or use a web-based service that does. + * Include examples from files as **in-line** text; don't use + attachments. + + 2. If reporting a problem, give **all** the relevant information + the first time; this isn't the psychic friends newsgroup. :-) + + When appropriate, include: + + * an example (preferably simple) that produces the problem + * the actual error messages + * the version of Ruby (`ruby -v`) + * the OS type and version (`uname -a`) + * the compiler name and version used to build Ruby + +3. Make the subject line maximally informative, so that people who + should be interested will read your post and so that people who + wouldn't be interested can easily avoid it. + + **Usefully** describe the contents of your post. + + This is OK: + + * "How can I do x with y on z?" + * "Problem: did x, expected y, got z." + * "BUG: doing x with module y crashed z." + + This is **not** OK: + + * "Please help!!!" + * "Newbie question" + * "Need Ruby guru to tell me what's wrong" + + These prefixes have become common for subject lines: + + * `[ANN]` (for announcements) + * `[BUG]` (for bug reports) + * `[OT]` (for off-topic, if you must post off-topic) + +4. Finally, be considerate: Don't be too lazy. If you are seeking + information, first make a reasonable effort to look it up. As + appropriate, check the [Ruby home page][ruby-lang], + check the [Ruby FAQ][faq] and other documentation, + use a search engine to search past postings, and so on. + + +_These guidelines where adopted from the [comp.lang.ruby FAQ][clrFAQ]._ + + + +[ruby-lang]: /en/ +[faq]: /en/documentation/faq/ +[clrFAQ]: http://rubyhacker.com/clrFAQ.html diff --git a/fa/community/podcasts/index.md b/fa/community/podcasts/index.md new file mode 100644 index 0000000000..187c76cafe --- /dev/null +++ b/fa/community/podcasts/index.md @@ -0,0 +1,18 @@ +--- +layout: page +title: "Podcasts" +lang: en +--- + +Listen to news, interviews, and discussions about Ruby and its community. + +[Ruby Rogues][rogues] +: The Ruby Rogues podcast is a panel discussion about topics relating to + programming, careers, community, and Ruby. + +[Ruby on Rails Podcast][rorpodcast] +: The Ruby on Rails Podcast, a weekly conversation about Ruby on Rails, + open source software, and the programming profession. + +[rorpodcast]: http://5by5.tv/rubyonrails +[rogues]: https://devchat.tv/ruby-rogues diff --git a/fa/community/ruby-core/index.md b/fa/community/ruby-core/index.md new file mode 100644 index 0000000000..d12fd8e2bb --- /dev/null +++ b/fa/community/ruby-core/index.md @@ -0,0 +1,166 @@ +--- +layout: page +title: "Ruby Core" +lang: en +--- + +Now is a fantastic time to follow Ruby’s development. With the increased +attention Ruby has received in the past few years, there’s a growing need +for good talent to help enhance Ruby and document its parts. +So, where do you start? +{: .summary} + +The topics related to Ruby development covered here are: + +* [Using Subversion to Track Ruby Development](#following-ruby) +* [How to Use Git With the Main Ruby Repository](#git-ruby) +* [Improving Ruby, Patch by Patch](#patching-ruby) +* [Rules for Core Developers](#coding-standards) + +### Using Subversion to Track Ruby Development +{: #following-ruby} + +Getting the latest Ruby source code is a matter of an anonymous checkout +from the [Subversion][1] repository. From your command line: + +{% highlight sh %} +$ svn co https://svn.ruby-lang.org/repos/ruby/trunk ruby +{% endhighlight %} + +The `ruby` directory will now contain the latest source code +for the development version of Ruby (ruby-trunk). +Currently patches applied to the trunk are backported to the stable +{{ site.svn.stable.version }}, {{ site.svn.previous.version }}, +and {{ site.svn.old.version }} branches (see below). + +If you’d like to follow patching of Ruby {{ site.svn.stable.version }}, +you should use the `{{ site.svn.stable.branch }}` branch when checking out: + +{% highlight sh %} +$ svn co https://svn.ruby-lang.org/repos/ruby/branches/{{ site.svn.stable.branch }} +{% endhighlight %} + +Similarly for Ruby {{ site.svn.previous.version }}: + +{% highlight sh %} +$ svn co https://svn.ruby-lang.org/repos/ruby/branches/{{ site.svn.previous.branch }} +{% endhighlight %} + +This will check out the respective development tree into a +`{{ site.svn.stable.branch }}` or `{{ site.svn.previous.branch }}` directory. +Developers working on the maintenance branches are expected to migrate +their changes to Ruby’s trunk, so often the branches are very similar, +with the exception of improvements made by Matz and Nobu to the language +itself. + +If you prefer, you may browse [Ruby’s Subversion repository via the web][2]. + +For information about Subversion, please see the [Subversion FAQ][3] +and the [Subversion book][4]. Alternatively, you may find +[Pragmatic Version Control with Subversion][5] to be a useful introductory book. + +### How to Use Git With the Main Ruby Repository +{: #git-ruby} + +Those who prefer to use [Git][6] over Subversion can find instructions +with the [mirror on GitHub][7], both for [those with commit access][8] +and [everybody else][9]. + +### Improving Ruby, Patch by Patch +{: #patching-ruby} + +The core team maintains an [issue tracker][10] for submitting patches and +bug reports to Matz and the gang. These reports also get submitted to +the [Ruby-Core mailing list][mailing-lists] for discussion, +so you can be sure your request won’t go unnoticed. You can +also send your patches straight to the mailing list. Either way, you are +encouraged to take part in the discussion that ensues. + +Please look over the [Patch Writer’s Guide][writing-patches] for some tips, +straight from Matz, on how to get your patches considered. + +To summarize, the steps for building a patch are: + +1. Check out a copy of the Ruby source code from Subversion. + Usually patches for bugfixes or new features should be submitted + for the trunk of Ruby’s source. Even if you wish to add a feature + to Ruby {{ site.svn.previous.version }}, it has to be proven in + the trunk first. + + $ svn co https://svn.ruby-lang.org/repos/ruby/trunk ruby + + If you are fixing a bug that is specific to only one maintenance branch, + check out a copy of the respective branch, + e.g. `{{ site.svn.previous.branch }}`. + + $ svn co https://svn.ruby-lang.org/repos/ruby/branches/{{ site.svn.previous.branch }} + +2. Add your improvements to the code. + +3. Create a patch. + + $ svn diff > ruby-changes.patch + +4. Create a ticket in the [issue tracker][10] or email your patch to + the [Ruby-Core mailing list][mailing-lists] with a ChangeLog entry + describing the patch. + +5. If there are no issues raised about the patch, committers will be + given the approval to apply it. + +**Please note:** patches should be submitted as a [unified diff][12]. +For more on how patches are merged, see [the diffutils reference][13]. + +Discussion of Ruby’s development converges on the +[Ruby-Core mailing list][mailing-lists]. So, if you are curious +about whether your patch is worthwhile or you want to spark a discussion +about Ruby’s future, don’t hesitate to come aboard. Be warned that +off-topic discussions are not tolerated on this list, the noise level +should be very low, topics should be pointed, well-conceived and +well-written. Since we’re addressing Ruby’s creator, let’s have some +reverence. + +Keep in mind that Ruby’s core developers live in Japan and, while many +speak very good English, there is a significant timezone difference. +They also have an entire body of Japanese development lists happening +alongside the English counterparts. Be patient, if your claim isn’t +resolved, be persistent—give it another shot a few days later. + +### Rules for Core Developers +{: #coding-standards} + +Generally, the developers of Ruby should be familiar with the source +code and the style of development used by the team. To be clear, the +following guidelines should be honored when checking into Subversion: + +* All check-ins should be described in the `ChangeLog`, following the + [GNU conventions][14]. (Many Ruby core developers use Emacs `add-log` + mode, which can be accessed with the command `C-x 4 a`.) +* Check-in dates should be given in Japan Standard Time (UTC+9). +* The bulleted points from your ChangeLog should also be placed in the + Subversion commit message. This message will be automatically mailed + to the Ruby-CVS list after you commit. +* Function prototypes are used throughout Ruby’s source code and its + packaged extensions. +* Please, do not use C++-style comments (`//`), Ruby’s maintainers + instead prefer the standard C multi-line comment (`/* .. */`). + +See also the information in [Ruby’s issue tracker][10]. + + + +[mailing-lists]: /en/community/mailing-lists/ +[writing-patches]: /en/community/ruby-core/writing-patches/ +[1]: http://subversion.apache.org/ +[2]: https://svn.ruby-lang.org/cgi-bin/viewvc.cgi/ +[3]: http://subversion.apache.org/faq.html +[4]: http://svnbook.org +[5]: http://www.pragmaticprogrammer.com/titles/svn/ +[6]: http://git-scm.com/ +[7]: https://github.com/ruby/ruby +[8]: https://github.com/shyouhei/ruby/wiki/committerhowto +[9]: https://github.com/shyouhei/ruby/wiki/noncommitterhowto +[10]: https://bugs.ruby-lang.org/ +[12]: http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html +[13]: http://www.gnu.org/software/diffutils/manual/html_node/Merging-with-patch.html#Merging%20with%20patch +[14]: http://www.gnu.org/prep/standards/standards.html#Change-Logs diff --git a/fa/community/ruby-core/writing-patches/index.md b/fa/community/ruby-core/writing-patches/index.md new file mode 100644 index 0000000000..da58f110a8 --- /dev/null +++ b/fa/community/ruby-core/writing-patches/index.md @@ -0,0 +1,52 @@ +--- +layout: page +title: "Patch Writer’s Guide" +lang: en +--- + +Here follow some tips, straight from Matz, on how to get +your patches considered. +{: .summary} + +These guidelines were adopted from a [post by Matz][ruby-core-post] +on the Ruby-Core mailing list: + +* Implement one modification per patch + + This is the biggest issue for most deferred patches. When you + submit a patch that fixes multiple bugs (and adds features) at once, + we have to separate them before applying it. It is a rather hard task + for us busy developers, so this kind of patches tends to be deferred. + No big patches please. + +* Provide descriptions + + Sometimes a mere patch does not sufficiently describe the problem it fixes. + A better description (the problem it fixes, preconditions, platform, etc.) + would help a patch to be merged earlier. + +* Diff to the latest revision + + Your problem might have been fixed in the latest revision. Or the code + might be totally different by now. Before submitting a patch, try to fetch + the latest version (the `trunk` branch for the latest development version, + `{{ site.svn.stable.branch }}` for {{ site.svn.stable.version }}) + from the Subversion repository, please. + +* Use `diff -u` + + We prefer `diff -u` style unified diff patches to `diff -c` + or any other style of patches. They are far easier to review. + Do not send modified files, we do not want to make a diff by ourselves. + +* Provide test cases (optional) + + A patch providing test cases (preferably a patch to `test/*/test_*.rb`) + would help us understand the patch and your intention. + +We might move to a Git style push/pull workflow in the future. +But until then, following the above guidelines would help you to avoid +frustration. + + +[ruby-core-post]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/25139 diff --git a/fa/community/user-groups/index.md b/fa/community/user-groups/index.md new file mode 100644 index 0000000000..3788b4fce0 --- /dev/null +++ b/fa/community/user-groups/index.md @@ -0,0 +1,44 @@ +--- +layout: page +title: "User Groups" +lang: en +--- + +In the programming community, user groups form support networks for +people interested in certain topics. They are a great place to increase +your skills and network with other programmers. User groups are informal +and their structure varies from group to group. Anyone can form their +own group and set their own rules and schedule. +{: .summary} + +### Ruby User Groups + +If you want to get together with other Ruby programmers, a local user +group may be just the thing. Ruby user groups are entirely devoted to +Ruby. They typically feature monthly meetings, a mailing list, a website, +and if you're lucky, frequent hacking sessions (meetings devoted +to giving people a chance to write Ruby code). + +Information about Ruby user groups can be found on various websites: + +[rubyusergroups.org][1] +: A public listing of Ruby groups throughout the world. Also allows + Rubyists to place themselves on a map of the world. + +[Ruby Meetup Groups][2] +: A substantial number of Ruby User Groups have chosen to make Meetup + their home. Meetup provides a number of tools for user groups, + including: private forums, a place for announcements, automated + meeting reminders, and a nice RSVP system. + +### Organizing Your Own Group + +If you are interested in forming your own group, be sure to find out if +there is already a Ruby user group in your area. Larger meetings are +usually much more fun, so starting your own group may not be the best +option if there is already one nearby. + + + +[1]: http://www.rubyusergroups.org/ +[2]: http://ruby.meetup.com diff --git a/fa/community/weblogs/index.md b/fa/community/weblogs/index.md new file mode 100644 index 0000000000..5acfeb5ea2 --- /dev/null +++ b/fa/community/weblogs/index.md @@ -0,0 +1,48 @@ +--- +layout: page +title: "Blogs" +lang: en +--- + +Ruby blogs have exploded over the past years and given sufficient +hunting, you can unearth hundreds of blogs sharing bits of Ruby code, +describing new techniques, or speculating on Ruby’s future. +{: .summary} + +### Mining for Ruby Blogs + +* [**RubyFlow**][rubyflow], “the Ruby and Rails community linklog”, + is a Ruby news site with links to libraries, blog posts, tutorials, + and other Ruby resources. +* [**Rubyland**][rubyland] aggregates news and blog posts about Ruby + from RSS feeds. + +### Blogs of Note + +A few notable blogs stand out for the frequency and immediacy of their +updates. + +* [**Ruby Weekly**][ruby-weekly]: Although more of a newsletter than a + blog, Ruby Weekly is a distillation of the most interesting Ruby + articles and news each week. +* [**Riding Rails**][riding-rails] is the official group blog of the + Ruby on Rails team. If you are running Rails, this blog is essential + for notification of security updates and an overall view of the wide + Rails community. + +### Spreading the Word + +If you're interested in writing for any of the above blogs, you should +contact the authors. + +Ruby is also a common topic on [reddit][reddit] and [Hacker News][hn], +in their respective programming news. If you find some brilliant code +out there, be sure to share! + + +[rubyflow]: http://www.rubyflow.com/ +[rubyland]: http://rubyland.news/ +[ruby-weekly]: https://rubyweekly.com/ +[riding-rails]: http://weblog.rubyonrails.org/ +[reddit]: http://www.reddit.com/r/ruby +[hn]: http://news.ycombinator.com/ diff --git a/fa/conduct/index.md b/fa/conduct/index.md new file mode 100644 index 0000000000..7dbdc22974 --- /dev/null +++ b/fa/conduct/index.md @@ -0,0 +1,22 @@ +--- +layout: page +title: "The Ruby Community Conduct Guideline" +lang: en +--- + +We have picked the following conduct guideline based on an early proposed draft +of the PostgreSQL CoC, for Ruby developers community for safe, productive +collaboration. +Each Ruby related community (conference etc.) may pick their own Code of Conduct. +{: .summary} + +This document provides community guidelines for a safe, respectful, productive, +and collaborative place for any person who is willing to contribute to the Ruby +community. It applies to all "collaborative space", which is defined as +community communications channels (such as mailing lists, submitted patches, +commit comments, etc.). + + * Participants will be tolerant of opposing views. + * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks. + * When interpreting the words and actions of others, participants should always assume good intentions. + * Behaviour which can be reasonably considered harassment will not be tolerated. diff --git a/fa/documentation/faq/1/index.md b/fa/documentation/faq/1/index.md new file mode 100644 index 0000000000..f12ebf27f5 --- /dev/null +++ b/fa/documentation/faq/1/index.md @@ -0,0 +1,344 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## General questions + +### What is Ruby? + +Ruby is a simple and powerful object-oriented programming language, created by +Yukihiro Matsumoto (who goes by the handle "Matz" in this document and on the +mailing lists). + +Like Perl, Ruby is good at text processing. Like Smalltalk, everything in Ruby +is an object, and Ruby has blocks, iterators, meta-classes and other good +stuff. + +You can use Ruby to write servers, experiment with prototypes, and for +everyday programming tasks. As a fully-integrated object-oriented language, +Ruby scales well. + +Ruby features: + +* Simple syntax, +* Basic OO features (classes, methods, objects, and so on), +* Special OO features (mixins, singleton methods, renaming, and so on), +* Operator overloading, +* Exception handling, +* Iterators and closures, +* Garbage collection, +* Dynamic loading (depending on the architecture), +* High transportability (runs on various Unices, Windows, DOS, macOS, OS/2, + Amiga, and so on). + +### Show me some Ruby code! + +Let's define a class called `Person`, with a name and an age. We'll test our +code by creating a few people and examining them. + +~~~ +class Person + attr_accessor :name, :age + + def initialize(name, age) + @name = name + @age = age.to_i + end + + def inspect + "#{name} (#{age})" + end +end + +p1 = Person.new("Elmo", 4) +p2 = Person.new("Zoe", 7) + +p1 # => Elmo (4) +p2 # => Zoe (7) +~~~ + +Now let's populate an array of people by reading their names and ages from a +file `ages` containing lines like: + +~~~ +Bert: 8 +Cookie: 11 +Elmo: 4 +Ernie: 8 +Zoe: 7 +~~~ + +The code uses regular expressions to parse successive lines from the input +file, creating a new `Person` object for each match and pushing it onto the +end of the array `people`. + +~~~ +people = Array.new + +File.foreach("ages") do |line| + people << Person.new($1, $2) if line =~ /(.*):\s+(\d+)/ +end + +people # => [Bert (8), Cookie (11), Elmo (4), Ernie (8), Zoe (7)] +~~~ + +Now, let's sort the result based on the person's age. There are many ways to +do this. We can define a sort block, which tells Ruby how to do the comparison +of two people: + +~~~ +sorted = people.sort {|a, b| a.age <=> b.age } +sorted # => [Elmo (4), Zoe (7), Bert (8), Ernie (8), Cookie (11)] +~~~ + +Another way would be to change the comparison method for class `Person`: + +~~~ +class Person + def <=>(other) + age <=> other.age + end +end +people.sort # => [Elmo (4), Zoe (7), Bert (8), Ernie (8), Cookie (11)] +~~~ + +### Why the name “Ruby”? + +Influenced by Perl, Matz wanted to use a jewel name for his new language, so +he named Ruby after a colleague's birthstone. + +Later, he realized that Ruby comes right after Perl in several situations. +In birthstones, pearl is June, ruby is July. When measuring font sizes, +pearl is 5pt, ruby is 5.5pt. He thought Ruby was a good name for a +programming language newer (and hopefully better) than Perl. + +(Based on an explanation from Matz in [\[ruby-talk:00394\]][ruby-talk:00394] +on June 11, 1999.) + +[ruby-talk:00394]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/394 + +### What is the history of Ruby? + +The following is a summary of a posting made by Matz in +[\[ruby-talk:00382\]][ruby-talk:00382] on June 4, 1999. +(The birthday of Ruby has been corrected in +[\[ruby-list:15977\]][ruby-list:15977].) + +> Well, Ruby was born on February 24, 1993. I was talking with my colleague +> about the possibility of an object-oriented scripting language. I knew Perl +> (Perl4, not Perl5), but I didn't like it really, because it had the smell of +> a toy language (it still has). The object-oriented scripting language seemed +> very promising. + +> I knew Python then. But I didn't like it, because I didn't think it was a +> true object-oriented language---OO features appeared to be an add-on to the +> language. As a language manic and OO fan for 15 years, I really wanted a +> genuine object-oriented, easy-to-use scripting language. I looked for, but +> couldn't find one. + +> So, I decided to make it. It took several months to make the interpreter +> run. I put into it the features I love to have in my language, such as +> iterators, exception handling, garbage collection. + +> Then, I reorganized the features of Perl into a class library, and +> implemented them. I posted Ruby 0.95 to the Japanese domestic newsgroups +> in Dec. 1995. + +> Since then, highly active mailing lists have been established and +> web pages formed. + +[ruby-talk:00382]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/382 +[ruby-list:15977]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/15977 + +### Where is the Ruby Home Page? + +The official Ruby Home Page is [www.ruby-lang.org](https://www.ruby-lang.org). +Besides the English and Japanese versions, there exist translations +into various other languages. + +Good starting points for finding Ruby information are the +[Documentation](/en/documentation/) and [Community](/en/community/) +pages. + +### Is there a Ruby newsgroup? + +comp.lang.ruby was established in May, 2000 (thanks to the efforts of +[Conrad Schneiker](mailto:schneiker@jump.net)). + +### Is there a Ruby mailing list? + +There are several mailing lists talking about Ruby. See the +[Mailing Lists](/en/community/mailing-lists/) +page for more information. + +You can search the mailing list archives using +[http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml](http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml). +(This is the URL for the ruby-talk list, munge as required for the others). + +### How can I thread the mailing list in mutt? + +{% include faq-out-of-date.html %} + +For some of the Ruby mailing lists, the mailing list software adds a prefix +to the subject lines, for example `ruby-core:1234`. This can confuse the +threading in some mail user agents. + +In mutt, you can get threading to work using the following variable setting. + +~~~ +# reply regexp, to support MLs like ruby-talk. +set reply_regexp="^(\[[a-z0-9:-]+\][[:space:]]*)?(re([\[0-9\]+])*|aw):[[:space:]]*" +~~~ + +### Which is correct, “Ruby” or “ruby”? + +Officially, the language is called “Ruby”. On most systems, it is invoked +using the command `ruby`. It's OK to use “ruby” instead of “Ruby”. + +Please don't use “RUBY” as the language name. + +Originally, or historically, it was called “ruby”. + +### Are there any Ruby books? + +{% include faq-out-of-date.html %} + +* Programming Ruby: The Pragmatic Programmer's Guide, + (the Pickaxe Book) by David Thomas and Andrew Hunt: ISBN 0-20171-089-7, + Addison-Wesley, October 2000. + +* A Japanese language Ruby reference book by Matz et al. and published by + ASCII is available in Japan (ISBN 4-7561-3254-5). An English translation, + “The Ruby Programming Language”, is available from O'Reilly & Associates + (ISBN 978-0596516178). + +* A Japanese language “Ruby Pocket Reference” is published by O'Reilly Japan + (ISBN 4-87311-023-8). Let O'Reilly in the US know if you'd like to see a + translation. + +* In addition, “Mastering Regular Expressions”, by Jeffrey Friedl, + (the Hip Owl Book): ISBN 1-56592-257-3 from O'Reilly & Associates, + is a reference work that covers the art and implementation of regular + expressions in various programming languages. Most of it is highly + relevant to Ruby regular expressions. + +### Which editors provide support for Ruby? + +{% include faq-out-of-date.html %} + +* [Emacs](http://www.gnu.org/software/emacs/emacs.html) + or [XEmacs](http://www.xemacs.org/): `ruby-mode.el` is supplied in the Ruby + distribution. With some versions of XEmacs, you may need to add + `(load "font-lock")` to your `.emacs` file to allow `ruby-mode.el` to detect + the syntax highlighting package you are using. +* [Vim](http://www.vim.org/): Vim 5.7 and later have Ruby syntax files as + standard in the runtime package. For prior versions, a syntax file for Ruby + is available at + [http://www.xs4all.nl/~hipster/lib/ruby/ruby.vim](http://www.xs4all.nl/~hipster/lib/ruby/ruby.vim). +* [Jedit](http://jedit.sourceforge.net/): A portable editor written in Java, + comes with support for Ruby. +* [Nedit](http://www.nedit.org): Eric Santonacci has written Ruby support for + Nedit, available from + [ftp://ftp.talc.fr/pub/ruby/ruby.nedit-0.1.tar.gz](ftp://ftp.talc.fr/pub/ruby/ruby.nedit-0.1.tar.gz). +* Barry Shultz has written a Ruby definition file for TextPad, available at + [https://www.textpad.com/add-ons/synn2t.html](https://www.textpad.com/add-ons/synn2t.html). + +### How can I annotate Ruby code with its results? + +{% include faq-out-of-date.html %} + +People commonly annotate Ruby code by showing the results of executing each +statement as a comment attached to that statement. For example, in the +following code, we show that the assignment generates the string "Billy Bob", +and then the result of extracting some substrings. + +~~~ +str = "Billy" + " Bob" # => "Billy Bob" +str[0,1] + str[2,1] + str[-2,2] # => "Blob" +~~~ + +Gotoken's `xmp` package, available from +[http://www.ruby-lang.org/en/raa-list.rhtml?name=xmp](http://www.ruby-lang.org/en/raa-list.rhtml?name=xmp) +is a utility that annotates Ruby source code this way. + +Emacs and vim users can integrate this with their editing environments, which +is useful if you want to send people e-mail with annotated Ruby code. Having +installed `xmp`, Emacs users can add the following to their `.emacs` file: + +~~~ +(defun ruby-xmp-region (reg-start reg-end) + "Pipe the region through Ruby's xmp utility and replace the region with + the result." + (interactive "r") + (shell-command-on-region reg-start reg-end + "ruby -r xmp -n -e 'xmp($_, \"%l\t\t# %r\n\")'" + t)) +(global-set-key [(meta f10)] 'ruby-xmp-region) +~~~ + +Vim users can use the mapping (thanks to hipster): + +~~~ +map :!ruby -r xmp -n -e 'xmp($_, "\%l\t\t\# \%r\n")' +~~~ + +In both cases, highlight a region of code and hit Meta-F10 to annotate it. + +### I can't understand Ruby even after reading the manual! + +{% include faq-out-of-date.html %} + +The syntax of Ruby has been fairly stable since Ruby 1.0, but new features are +added every now and then. So, the books and the online documentation can get +behind. + +If you have a problem, feel free to ask in the mailing list +(see the [Mailing Lists page](/en/community/mailing-lists/)). +Generally you'll get timely answers from Matz himself, the +author of the language, from other gurus, and from those who have solved +problems similar to your own. + +Please include the output of `ruby -v` along with any problematic +source code. + +If you have a problem using [`irb`](../10/#irb), +be aware that it has some limitations. +Try the script using `irb --single-irb`, or directly using the +`ruby` command. + +There might be similar questions in the mailing list, and it is good +netiquette to read through recent mails (RFC1855:3.1.1, 3.1.2) before asking. +But do ask on the list, and a correct answer will be forthcoming. diff --git a/fa/documentation/faq/10/index.md b/fa/documentation/faq/10/index.md new file mode 100644 index 0000000000..d361458b60 --- /dev/null +++ b/fa/documentation/faq/10/index.md @@ -0,0 +1,145 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Extension library + +### How can I use Ruby interactively? +{: #irb} + +{% include faq-out-of-date.html %} + +You can try using `irb`. The following is paraphrased from Kentaro Goto +(Gotoken), and originally appeared in [\[ruby-talk:444\]][ruby-talk:444]. + +1. Get the latest tarball of `irb` from the + [contrib directory](ftp://ftp.netlab.co.jp/pub/lang/ruby/contrib/) + in the Ruby archive. +2. Extract the `irb` directory tree. +3. Add the location of the `irb/` directory to the `$RUBYLIB` + environment variable. +4. Make a symbolic link from `$RUBYLIB/irb/irb.rb` to a file called `irb` + somewhere in your path. +5. `chmod +x $RUBYLIB/irb/irb.rb` +6. Possibly use `rehash` to tell your login shell about the new command. +7. Type `irb`. + +If the readline extension module works with your interpreter, it makes `irb` +a lot more fun to use. + +There is also a simple program, `eval`, in the `samples/` directory of the +Ruby distribution. It lets you enter expressions and view their values. +You can copy `eval` into the `site_ruby` directory in the Ruby tree, and +then invoke it using: + +~~~ +ruby -r eval -e0 +~~~ + +[ruby-talk:444]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/444 + +### Is there a debugger for Ruby? + +There is a gdb-like debugger for Ruby. + +~~~ +ruby -r debug your_program +~~~ + +### How can I use a library written in C from Ruby? + +Of all the scripting languages, Ruby is probably the easiest to extend. +There are no problems with reference counting and variable types, and very +few interfaces to learn. In fact, C code used to extend Ruby often ends up +looking surprisingly like Ruby code itself. + +First, read the `doc/extension.rdoc` file in the Ruby source, +or read [extension.rdoc on docs.ruby-lang.org][extension-rdoc]. +This is a good document, not only if you are writing an extension library, +but also if you want to understand Ruby more deeply. + +Then, the RubyGems site provides a +[guide on creating gems with extensions][rubygems-guide]. +It shows how to setup a gem with C extensions that are built at install time. +It has also links to some existing gems that wrap C libraries and +to further reading. + +You might also want to have a look at the source of the interpreter itself, +and at the various supplied extensions in the `ext/` directory +(you can browse the [Ruby repository on GiHub][ruby-github]). + +[extension-rdoc]: http://docs.ruby-lang.org/en/trunk/extension_rdoc.html +[rubygems-guide]: http://guides.rubygems.org/gems-with-extensions/ +[ruby-github]: https://github.com/ruby/ruby + +### Can I use Tcl/Tk in Ruby? + +{% include faq-out-of-date.html %} + +There are two interfaces to Tcl/Tk included in the standard distribution. +One is under `ext/tcltk/` and loaded with `require "tcltk"`. The syntax is +very close to that Tcl which is passed on to the Tcl interpreter. +Unfortunately, the description for this library is written in Japanese. + +The other is under `ext/tk/` and loaded with `require "tk"`. Its syntax +is closer to the style of the Tk interface provided by the Perl and Python +interfaces. + +### Tk won't work. Why? + +{% include faq-out-of-date.html %} + +Your Tk version may be old, try a newer version. + +### Can I use gtk+ or xforms interfaces in Ruby? + +{% include faq-out-of-date.html %} + +You will find `ruby-gtk-x.xx.tar.gz` and `ruby-forms-x.x.tar.gz` +under `contrib/` on the Ruby ftp sites. + +### How can I do date arithmetic? + +{% include faq-out-of-date.html %} + +A `Time` object can express only the dates between Jan 1, 1970 and +Jan 19, 2038. + +Two standard extension library modules are provided: +`require "date"`, which is simple and uses the English calendar, +and `require "date2"`, which is more general purpose. + +Also see `sample/cal.rb`. diff --git a/fa/documentation/faq/11/index.md b/fa/documentation/faq/11/index.md new file mode 100644 index 0000000000..4e87342532 --- /dev/null +++ b/fa/documentation/faq/11/index.md @@ -0,0 +1,192 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Other features + +### What does `a ? b : c` mean? + +This is the so-called “ternary operator” and is the same as saying +`if a then b else c end`. + +### How can I count the number of lines in a file? + +The following code may give the fastest result. + +~~~ +File.readlines("example").size # => 3 +~~~ + +### What do `MatchData#begin` and `MatchData#end` return? + +They act with `$~`, and return the start index and the end index of +the matched data in the original string. See an example in +[tab expansion](../9/#tab-expansion). + +### How can I sum the elements in an array? + +{% include faq-out-of-date.html %} + +Rather than solve the specific problem, let's solve the general case. +The first thing we will do is produce a method that will iterate over +an `Enumerable` object and collect a single result. Smalltalk calls that +method inject, so we will too: + +~~~ +module Enumerable + + # inject(n) {|n, i| ...} + def inject(n) + each {|i| n = yield(n, i) } + + n + end +end +~~~ + +Notice how we have added the method to `Enumerable`. This means that anything +that includes Enumerable can now use `inject`. But how do we use it? It takes +a single argument `n` and a block. For each element in the thing being +enumerated, it calls the block, passing in `n` and the element itself. +The result of the block is assigned back to `n`. So, to define `sum`, +we could write: + +~~~ +module Enumerable + def sum + inject(0) {|n, i| n + i } + end +end + +[1,3,5,7,9].sum # => 25 +(1..100).sum # => 5050 +~~~ + +### How can I use continuations? + +{% include faq-out-of-date.html %} + +Ruby's continuations allow you to create an object representing a place in a +Ruby program, and then return to that place at any time (even if it has +apparently gone out of scope). Continuations can be used to implement complex +control structures, but are typically more useful as ways of confusing people. + +In [\[ruby-talk:4482\]][ruby-talk:4482], Jim Weirich posted the following +examples of continuations: + +~~~ +# -------------------------------------------------------------------- +# Simple Producer/Consumer +# -------------------------------------------------------------------- +# Connect a simple counting task and a printing task together using +# continuations. +# +# Usage: count(limit) + +def count_task(count, consumer) + (1..count).each do |i| + callcc {|cc| consumer.call cc, i } + end + nil +end + +def print_task() + producer, i = callcc { |cc| return cc } + print "#{i} " + callcc { |cc| producer.call } +end + +def count(limit) + count_task(limit, print_task()) + print "\n" +end +~~~ + + +~~~ +# -------------------------------------------------------------------- +# Filtering Out Multiples of a Given Number +# -------------------------------------------------------------------- +# Create a filter that is both a consumer and producer. Insert it +# between the counting task and the printing task. +# +# Usage: omit(2, limit) + +def filter_task(factor, consumer) + producer, i = callcc { |cc| return cc } + if (i%factor) != 0 then + callcc { |cc| consumer.call cc, i } + end + producer.call +end + +def omit(factor, limit) + printer = print_task() + filter = filter_task(factor, printer) + count_task(limit, filter) + print "\n" +end +~~~ + + +~~~ +# -------------------------------------------------------------------- +# Prime Number Generator +# -------------------------------------------------------------------- +# Create a prime number generator. When a new prime number is +# discovered, dynamically add a new multiple filter to the chain of +# producers and consumers. +# +# Usage: primes(limit) + +def prime_task(consumer) + producer, i = callcc { |cc| return cc } + if i >= 2 then + callcc { |cc| consumer.call cc, i } + consumer = filter_task(i, consumer) + end + producer.call +end + +def primes(limit) + printer = print_task() + primes = prime_task(printer) + count_task(limit, primes) + print "\n" +end +~~~ + +[ruby-talk:4482]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/4482 diff --git a/fa/documentation/faq/2/index.md b/fa/documentation/faq/2/index.md new file mode 100644 index 0000000000..eda470ace3 --- /dev/null +++ b/fa/documentation/faq/2/index.md @@ -0,0 +1,102 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## How does Ruby stack up against...? + +### How does Ruby compare with Python? + +Python and Ruby are both object oriented languages that provide a smooth +transition from procedural to OO programming styles. Smalltalk, by contrast, +is object only---you can't do anything until you understand objects, +inheritance and the sizable Smalltalk class hierarchy. By providing procedural +training wheels, Python and Ruby “fix” one of the features that may have +kept Smalltalk out of the mainstream. The two languages differ by approaching +this solution from opposite directions. + +Python is a hybrid language. It has functions for procedural programming and +objects for OO programming. Python bridges the two worlds by allowing +functions and methods to interconvert using the explicit `self` parameter +of every method def. When a function is inserted into an object, the first +argument automagically becomes a reference to the receiver. + +Ruby is a pure OO language that can masquerade as a procedural one. It has no +functions, only method calls. In a Ruby method the receiver, also called +`self`, is a hidden argument like `this` in C++. A `def` statement outside of +a class definition, which is a function in Python, is actually a method call +in Ruby. These ersatz functions become private methods of class Object, the +root of the Ruby class hierarchy. Procedural programming is neatly solved from +the other direction---everything is an object. If the user doesn't grok +objects yet, they can just pretend that `def` is a function definition and +still get useful work done. + +Ruby's OO purity provides a number features that Python lacks or is still +working toward: a unified type/class hierarchy, metaclasses, the ability to +subclass everything, and uniform method invocation (none of this `len()` is a +function but `items()` is a method rubbish). Ruby, like Smalltalk, only +supports single inheritance, but it does have a very powerful mixin concept: +a class definition may include a module, which inserts that module's methods, +constants, etc. into the class. + +Ruby, again like Smalltalk, provides closures and code blocks and uses them +to the same good effect. The Ruby collection classes and iterators are +outstanding, much more powerful and elegant than the ad hoc solutions that +Python is sprouting (lambdas and list comprehensions). + +Ruby's syntax and design philosophy are heavily influenced by Perl. It has a +lot of syntactic variability. Statement modifiers (`if`, `unless`, `while`, +`until`, etc.) may appear at the end of any statement. Some key words are +optional (the `then` in an `if` statement for example). Parentheses may +sometimes be elided in method calls. The receiver of a method may usually be +elided. +Many, many things are lifted directly from Perl. +Built in regular expressions, `$_` and friends, here documents, the +single-quoted / double-quoted string distinction, `$` and `@` prefixes to +distinguish different kinds of names and so forth. + +If you like Perl, you will like Ruby and be right at home with its syntax. +If you like Smalltalk, you will like Ruby and be right at home with its +semantics. If you like Python, you may or may not be put off by the huge +difference in design philosophy between Python and Ruby/Perl. + +Ruby is much more complex than Python but its features, for the most part, +hang together well. Ruby is well designed and full of neat ideas that might be +mined for P3K. I'm not sure how many Python programmers will be attracted to +it though---it hasn't won me over (yet). But it is worthy of serious study and +could be a real threat to Perl. + +Posted by [John Dell'Aquila](mailto:jbd@alum.mit.edu) in comp.lang.python, +11/17/2000. Reproduced with permission. diff --git a/fa/documentation/faq/3/index.md b/fa/documentation/faq/3/index.md new file mode 100644 index 0000000000..d2a7f82f41 --- /dev/null +++ b/fa/documentation/faq/3/index.md @@ -0,0 +1,212 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Installing Ruby + +For current information on downloading and installing Ruby +see the [Installation](/en/documentation/installation/) +or [Downloads](/en/downloads/) page. + +### What operating systems support Ruby? + +{% include faq-out-of-date.html %} + +Ruby is developed under Linux, and is written in fairly straightforward C. +It runs under Linux and other UNIX-like operating systems, macOS, +Windows, DOS, BeOS, Amiga, Acorn Risc OS, and OS/2. + +### Where can I get Ruby sources? + +The latest version of Ruby can be downloaded from: +[www.ruby-lang.org/en/downloads/](/en/downloads/). +Mirror sites are also listed on this page. + +Also on this page is a link to a nightly snapshot of the development tree. + +### Can I get to the development source tree? + +{% include faq-out-of-date.html %} + +If you have a CVS client, you can check out the current source tree using: + +~~~ +$ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs login +(Logging in to anonymous@cvs.netlab.co.jp) +CVS password: guest +$ cvs -d :pserver:anonymous@cvs.netlab.co.jp:/home/cvs co ruby +~~~ + +If you do not have CVS you can get a nightly snapshot of the development +source from +[https://cache.ruby-lang.org/pub/ruby/snapshot.tar.gz](https://cache.ruby-lang.org/pub/ruby/snapshot.tar.gz). + +### How do I compile Ruby? + +Under Unix, Ruby uses the `autoconf` system to configure the build +environment. You don't need the `autoconf` command on your box to build Ruby +from a distribution; just use the commands: + +~~~ +$ ./configure [configure options] +$ make +$ make test +$ make install +~~~ + +You may need superuser privileges to install Ruby if you don't override the +default installation location (`/usr/local`). You can get a full list of +`configure` options using: + +~~~ +$ ./configure --help +~~~ + +If you are working from the source repository, you may need to run +`autoconf` before running `configure`. + +### How do I tell Ruby where my libraries are? + +{% include faq-out-of-date.html %} + +On some systems, the build process may fail to find libraries used by +extension modules (for example the `dbm` libraries). + +You can tell Ruby where to find libraries using options to `configure`. +From [\[ruby-talk:5041\]][ruby-talk:5041]: + +~~~ +$ ./configure --with-xxx-yyy=DIR +~~~ + +where xxx is either + +~~~ +opt extra software path in general +dbm path for dbm library +gdbm path for gdbm library +x11 ...for X11.. +tk ...for Tk... +tcl ...for Tcl... +~~~ + +and yyy is either + +~~~ +dir specifies -I DIR/include -L DIR/lib +include specifies -I DIR +lib specifies -L DIR +~~~ + +On HP-UX, there may be problems building with `gcc`. Try using the native +compiler instead. WATANABE Tetsuya recommends: + +~~~ +$ CC="cc -Ae" CFLAGS=-O ./configure --prefix=/opt/gnu +~~~ + +There may also be problems with HP's native `sed`. +He recommends installing the GNU equivalent. + +[ruby-talk:5041]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/5401 + +### Are precompiled binaries available? + +{% include faq-out-of-date.html %} + +A single download that contains everything you need to run Ruby under various +Windows operating systems is available from +[RubyCentral's One-click Windows installer](http://www.rubycentral.com/downloads/ruby-install.html). +This installation uses cygwin, and includes Tk support. + +If you want other installation options, precompiled binaries for Windows are +also available from +[http://www.os.rim.or.jp/~eban/](http://www.os.rim.or.jp/~eban/). +If you download the `ruby-1.x.y-yyyymmdd-i386-cygwin.tar.gz` package +(which is a good choice), you'll also need to download the cygwin DLL, +available from the same page. + +[Reuben Thomas](mailto:Reuben.Thomas@cl.cam.ac.uk) writes: + +> You could mention that there's a port to Acorn RISC OS, currently of v1.4.3. +> I made the port, and have no plans to maintain it, but I did send the +> patches to matz, so newer versions may well compile too. + +> I do provide a binary distribution of 1.4.3 for the Acorn at +> [http://www.cl.cam.ac.uk/users/rrt1001/ruby.zip](http://www.cl.cam.ac.uk/users/rrt1001/ruby.zip). + +### What's all this “cygwin”, “mingw”, and “djgpp” stuff? + +{% include faq-out-of-date.html %} + +Ruby is written to take advantage of the rich feature set of a Unix +environment. Unfortunately, Windows is missing some of the functions, and +implements others differently. As a result, some kind of mapping layer is +needed to run Ruby (and other Unix-based programs) under Windows. + +You may come across different versions of the Ruby executable that use +different wrapper mapping layers. + +The rbdj version is a stand-alone version of the Windows binary of Ruby. +It uses the DJ Delorie tools +([http://www.delorie.com](http://www.delorie.com)). + +The rbcw version is a Windows binary of Ruby that requires the cygwin library, +available at [http://www.cygwin.com](http://www.cygwin.com) or from the +Ruby download pages. Cygwin is both an emulation layer and a set of +utilities initially produced by Cygnus Solutions (now part of Redhat). +The cygwin version of Ruby probably has the fullest set of features under +Windows, so most programmers will want to use it. + +To use the rbcw version, you will need to install the cygwin .dll separately. +Once you have installed cygwin on your computer, copy `cygwin1.dll` (which +is found in the `bin` subdirectory of the cygwin distribution) to your +`Windows\System32` folder (or somewhere else on your path). + +Thanks to Anders Schneiderman for the basis of this description. + +### Why doesn't Tk graphics work under Windows? + +{% include faq-out-of-date.html %} + +Is Tk installed correctly on your Windows box? Go to +[http://dev.scriptics.com/software/tcltk/](http://dev.scriptics.com/software/tcltk/) +to find a precompiled binary Tcl/Tk distribution for your box. + +Are the environment variables `TCL_LIBRARY` and `TK_LIBRARY` pointing to the +directories containing tcl and tk? + +Is the tk library in your path? diff --git a/fa/documentation/faq/4/index.md b/fa/documentation/faq/4/index.md new file mode 100644 index 0000000000..800c496e45 --- /dev/null +++ b/fa/documentation/faq/4/index.md @@ -0,0 +1,428 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Variables, constants, and arguments + +### Does assignment generate a new copy of an object? +{: #assignment} + +All variables and constants reference (point at) some object. (With the +exception of uninitialized local variables, which reference nothing. +These raise a `NameError` exception if used). When you assign to a variable, +or initialize a constant, you set the object that the variable or constant +references. + +Assignment on its own therefore never creates a new copy of an object. + +There's a slightly deeper explanation in certain special cases. Instances of +`Fixnum`, `NilClass`, `TrueClass`, and `FalseClass` are contained directly in +variables or constants---there is no reference involved. A variable holding +the number `42` or the constant `true` actually holds the value, and not a +reference to it. Assignment therefore physically produces a copy of objects +of these types. We discuss this more in +[Immediate and Reference Objects](../6/#immediate). + +### What is the scope of a local variable? + +A new scope for a local variable is introduced in (1) the toplevel (main), +(2) a class (or module) definition, or (3) a method definition. + +~~~ +var = 1 # (1) +class Demo + var = 2 # (2) + def method + var = 3 # (3) + puts "in method: var = #{var}" + end + puts "in class: var = #{var}" +end +puts "at top level: var = #{var}" +Demo.new.method +~~~ + +Produces: + +~~~ +in class: var = 2 +at top level: var = 1 +in method: var = 3 +~~~ + +(Note that the class definition is executable code: the trace message it +contains is written as the class is defined). + +A block (`{ ... }` or `do ... end`) almost introduces a new scope ;-) +Local variables created within a block are not accessible outside the block. +However, if a local variable within the block has the same name as an existing +local variable in the caller's scope, then no new local variable is created, +and you can subsequently access that variable outside the block. + +~~~ +a = 0 +1.upto(3) do |i| + a += i + b = i*i +end +a # => 6 +# b is not defined here +~~~ + +This becomes significant when you use threading---each thread receives its +own copy of the variables local to the thread's block: + +~~~ +threads = [] + +["one", "two"].each do |name| + threads << Thread.new do + local_name = name + a = 0 + 3.times do |i| + Thread.pass + a += i + puts "#{local_name}: #{a}" + end + end +end + +threads.each {|t| t.join } +~~~ + +Might produce (in case the scheduler switches threads as hinted +by `Thread.pass`; this depends on OS and processor): + +~~~ +one: 0 +two: 0 +one: 1 +two: 1 +one: 3 +two: 3 +~~~ + +`while`, `until`, and `for` are control structures, not blocks, so local +variables within them will be accessible in the enclosing environment. +`loop`, however, is a method and the associated block introduces a new scope. + +### When does a local variable become accessible? + +Actually, the question may be better asked as: “at what point does Ruby work +out that something is a variable?” The problem arises because the simple +expression `a` could be either a variable or a call to a method with no +parameters. To decide which is the case, Ruby looks for assignment statements. +If at some point in the source prior to the use of `a` it sees it being +assigned to, it decides to parse `a` as a variable, otherwise it treats it +as a method. As a somewhat pathological case of this, consider this code +fragment, originally submitted by Clemens Hintze: + +~~~ +def a + puts "method `a' called" + + 99 +end + +[1, 2].each do |i| + if i == 2 + puts "a = #{a}" + else + a = 1 + puts "a = #{a}" + end +end +~~~ + +Produces: + +~~~ +a = 1 +method `a' called +a = 99 +~~~ + +During the parse, Ruby sees the use of `a` in the first `puts` statement +and, as it hasn't yet seen any assignment to `a`, assumes that it is a method +call. By the time it gets to the second `puts` statement, though, it has seen +an assignment, and so treats `a` as a variable. + +Note that the assignment does not have to be executed---Ruby just has to have +seen it. This program does not raise an error: + +~~~ +a = 1 if false; a # => nil +~~~ + +This issue with variables is not normally a problem. If you do bump into it, +try putting an assignment such as `a = nil` before the first access to the +variable. This has the additional benefit of speeding up the access time to +local variables that subsequently appear in loops. + +### What is the scope of a constant? + +A constant defined in a class or module definition can be accessed directly +within that class's or module's definition. + +You can directly access the constants in outer classes and modules from +within nested classes and modules. + +You can also directly access constants in superclasses and included modules. + +Apart from these cases, you can access class and module constants using +the `::` operator, `ModuleName::CONST1` or `ClassName::CONST2`. + +### How are arguments passed? + +The actual argument is assigned to the formal argument when the method is +invoked. +(See [assignment](#assignment) for more on the semantics of assignment.) + +~~~ +def add_one(number) + number += 1 +end + +a = 1 +add_one(a) # => 2 +a # => 1 +~~~ + +As you are passing object references, it is possible that a method may modify +the contents of a mutable object passed into it. + +~~~ +def downer(string) + string.downcase! +end + +a = "HELLO" # => "HELLO" +downer(a) # => "hello" +a # => "hello" +~~~ + +There is no equivalent of other language's pass-by-reference semantics. + +### Does assignment to a formal argument influence the actual argument? + +A formal argument is a local variable. Within a method, assigning to a formal +argument simply changes the argument to reference another object. + +### What happens when I invoke a method via a formal argument? + +All Ruby variables (including method arguments) act as references to objects. +You can invoke methods in these objects to get or change the object's state +and to make the object do something. You can do this with objects passed to +methods. You need to be careful when doing this, as these kinds of side +effects can make programs hard to follow. + +### What does `*` prepended to an argument mean? + +When used as part of a formal parameter list, the asterisk allows arbitrary +numbers of arguments to be passed to a method by collecting them into an +array, and assigning that array to the starred parameter. + +~~~ +def foo(prefix, *all) + all.each do |element| + puts "#{prefix}#{element}" + end +end + +foo("val = ", 1, 2, 3) +~~~ + +Produces: + +~~~ +val = 1 +val = 2 +val = 3 +~~~ + +When used in a method call, `*` expands an array, passing its individual +elements as arguments. + +~~~ +a = [1, 2, 3] +foo(*a) +~~~ + +You can prepend `*` to the last argument of + +1. Left hand side of a multiple assignment. +2. Right hand side of a multiple assignment. +3. Definition of method formal arguments. +4. Actual arguments in a method call. +5. In `when` clause of `case` structure. + +For example: + +~~~ +x, *y = [7, 8, 9] +x # => 7 +y # => [8, 9] +x, = [7, 8, 9] +x # => 7 +x = [7, 8, 9] +x # => [7, 8, 9] +~~~ + +### What does `&` prepended to an argument mean? + +If the last formal argument of a method is preceded with an ampersand (`&`), +a block following the method call will be converted into a `Proc` object +and assigned to the formal parameter. + +If the last actual argument in a method invocation is a `Proc` object, +you can precede its name with an ampersand to convert in into a block. +The method may then use `yield` to call it. + +~~~ +def meth1(&b) + puts b.call(9) +end + +meth1 {|i| i + i } + +def meth2 + puts yield(8) +end + +square = proc {|i| i * i } + +meth2 {|i| i + i } +meth2 &square +~~~ + +Produces: + +~~~ +18 +16 +64 +~~~ + +### How can I specify a default value for a formal argument? + +~~~ +def greet(p1="hello", p2="world") + puts "#{p1} #{p2}" +end + +greet +greet("hi") +greet("morning", "mom") +~~~ + +Produces: + +~~~ +hello world +hi world +morning mom +~~~ + +The default value (which can be an arbitrary expression) is evaluated when +the method is invoked. It is evaluated using the scope of the method. + +### How do I pass arguments to a block? + +The formal parameters of a block appear between vertical bars at the start +of the block: + +~~~ +proc {|a, b| a <=> b } +~~~ + +These parameters are actually local variables. If an existing local variable +of the same name exists when the block executes, that variable will be +modified by the call to the block. This may or may not be a good thing. + +Typically, arguments are passed to a block using `yield` (or an iterator that +calls `yield`), or by using the `Proc.call` method. + +### Why did my object change unexpectedly? + +~~~ +A = a = b = "abc" +b.concat("d") # => "abcd" +a # => "abcd" +A # => "abcd" +~~~ + +Variables hold references to objects. The assignment `A = a = b = "abc"` puts +a reference to the string `"abc"` into `A`, `a`, and `b`. + +When you call `b.concat("d")`, you invoke the concat method on that object, +changing it from `"abc"` to `"abcd"`. Because `a` and `A` also reference that +same object, their apparent values change too. + +This is less of a problem in practice than it might appear. + +In addition, all objects may be frozen, protecting them from change. + +### Does the value of a constant ever change? + +A constant is a variable whose name starts with an upper case letter. +Constants may not be reassigned from within instance methods, +but can otherwise be changed at will. +When a constant is assigned a new value, a warning is issued. + +### Why can't I load variables from a separate file? + +Say `file1.rb` contains: + +~~~ +var1 = 99 +~~~ + +and some other file loads it in: + +~~~ +require_relative "file1" +puts var1 +~~~ + +Produces: + +~~~ +prog.rb:2:in `
': undefined local variable or method `var1' for main:Object (NameError) +~~~ + +You get an error because `load` and `require` arrange for local variables to +be stored into a separate, anonymous namespace, effectively discarding them. +This is designed to protect your code from being polluted. diff --git a/fa/documentation/faq/5/index.md b/fa/documentation/faq/5/index.md new file mode 100644 index 0000000000..566518ee56 --- /dev/null +++ b/fa/documentation/faq/5/index.md @@ -0,0 +1,237 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Iterators + +### What is an iterator? + +An iterator is a method which accepts a block or a `Proc` object. In the +source file, the block is placed immediately after the invocation of the +method. Iterators are used to produce user-defined control +structures---especially loops. + +Let's look at an example to see how this works. Iterators are often used to +repeat the same action on each element of a collection, like this: + +~~~ +data = [1, 2, 3] +data.each do |i| + puts i +end +~~~ + +Produces: + +~~~ +1 +2 +3 +~~~ + +The each method of the array `data` is passed the `do ... end` block, +and executes it repeatedly. On each call, the block is passed successive +elements of the array. + +You can define blocks with `{ ... }` in place of `do ... end`. + +~~~ +data = [1, 2, 3] +data.each { |i| + puts i +} +~~~ + +Produces: + +~~~ +1 +2 +3 +~~~ + +This code has the same meaning as the last example. However, in some cases, +precedence issues cause `do ... end` and `{ ... }` to act differently. + +~~~ +foobar a, b do ... end # foobar is the iterator. +foobar a, b { ... } # b is the iterator. +~~~ + +This is because `{ ... }` binds more tightly to the preceding expression +than does a `do ... end` block. The first example is equivalent to +`foobar(a, b) do ... end`, while the second is `foobar(a, b { ... })`. + +### How can I pass a block to an iterator? + +You simply place the block after the iterator call. You can also pass a +`Proc` object by prepending `&` to the variable or constant name that refers +to the `Proc`. + +### How is a block used in an iterator? + +{% include faq-out-of-date.html %} + +There are three ways to execute a block from an iterator method: +(1) the `yield` control structure; (2) calling a `Proc` argument +(made from a block) with `call`; and (3) using `Proc.new` followed by a call. + +The `yield` statement calls the block, optionally passing it one or more +arguments. + +~~~ +def my_iterator + yield 1, 2 +end + +my_iterator {|a, b| puts a, b } +~~~ + +Produces: + +~~~ +1 +2 +~~~ + +If a method definition has a block argument (the last formal parameter has +an ampersand (`&`) prepended), it will receive the attached block, converted +to a `Proc` object. This may be called using `prc.call(args)`. + +~~~ +def my_iterator(&b) + b.call(1, 2) +end + +my_iterator {|a, b| puts a, b } +~~~ + +Produces: + +~~~ +1 +2 +~~~ + +`Proc.new` (or the equivalent `proc` or `lambda` calls), when used in an +iterator definition, takes the block which is given to the method as its +argument and generates a procedure object from it. +(`proc` and `lambda` are effectively synonyms.) + +_[Update needed: `lambda` behaves in a slightly different way and +produces a warning `tried to create Proc object without a block`.]_ + +~~~ +def my_iterator + Proc.new.call(3, 4) + proc.call(5, 6) + lambda.call(7, 8) +end + +my_iterator {|a, b| puts a, b } +~~~ + +Produces: + +~~~ +3 +4 +5 +6 +7 +8 +~~~ + +Perhaps surprisingly, `Proc.new` and friends do not in any sense consume +the block attached to the method---each call to `Proc.new` generates a new +procedure object out of the same block. + +You can tell if there is a block associated with a method by calling +`block_given?`. + +### What does `Proc.new` without a block do? + +`Proc.new` without a block cannot generate a procedure object and an error +occurs. In a method definition, however, `Proc.new` without a block implies +the existence of a block at the time the method is called, and so no error +will occur. + +### How can I run iterators in parallel? + +Here an adoption of a solution by Matz, in +[\[ruby-talk:5252\]][ruby-talk:5252], that uses threads: + +~~~ +require "thread" + +def combine(*iterators) + queues = [] + threads = [] + + iterators.each do |it| + queue = SizedQueue.new(1) + th = Thread.new(it, queue) do |i, q| + send(i) {|x| q << x } + end + queues << queue + threads << th + end + + loop do + ary = [] + queues.each {|q| ary << q.pop } + yield ary + + iterators.size.times do |i| + return if !threads[i].status && queues[i].empty? + end + end +end + +def it1 + yield 1; yield 2; yield 3 +end + +def it2 + yield 4; yield 5; yield 6 +end + +combine(:it1, :it2) do |x| + # x is [1, 4], then [2, 5], then [3, 6] +end +~~~ + +[ruby-talk:5252]: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/5252 diff --git a/fa/documentation/faq/6/index.md b/fa/documentation/faq/6/index.md new file mode 100644 index 0000000000..c37ed43051 --- /dev/null +++ b/fa/documentation/faq/6/index.md @@ -0,0 +1,293 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Syntax + +### What is the difference between an immediate value and a reference? +{: #immediate} + +{% include faq-out-of-date.html %} + +`Fixnum`, `true`, `nil`, and `false` are implemented as immediate values. +With immediate values, variables hold the objects themselves, rather than +references to them. + +Singleton methods cannot be defined for such objects. Two `Fixnums` of the +same value always represent the same object instance, so (for example) +instance variables for the `Fixnum` with the value `1` are shared between +all the `1`'s in the system. This makes it impossible to define a singleton +method for just one of these. + +### What is the difference between `nil` and `false`? + +First the similarity: `nil` and `false` are the only two objects +that evaluate to `false` in a boolean context. +(In other words: they are the only “falsy” values, all other +objects are “truthy”.) + +However, `nil` and `false` are instances of different classes +(`NilClass` and `FalseClass`), and have different behavior elsewhere. + +We recommend that predicate methods (those whose name ends with a question +mark) return `true` or `false`. Other methods that need to indicate failure +should return `nil`. + +### Why is an empty string not `false`? + +Q: An empty string (`""`) returns `true` in a conditional expression! +In Perl, it's `false`. + +A: But Ruby is not Perl ;-). It's very simple: in Ruby, only `nil` +and `false` are false in conditional contexts. + +You can use `empty?`, compare the string to `""`, or compare the string's +`size` or `length` to `0` to find out if a string is empty. + +### What does `:name` mean? + +A colon followed by a name generates a Symbol object which corresponds +one to one with the identifier. During the duration of a program's +execution the same Symbol object will be created for a given name or string. +Symbols can also be created with `"name".intern` or `"name".to_sym`. + +Symbol objects can represent identifiers for methods, variables, and so on. +Some methods, like `define_method`, `method_missing`, or `trace_var`, +require a symbol. Other methods, e.g. `attr_accessor`, `send`, or `autoload`, +also accept a string. + +Due to the fact that they are created only once, Symbols are often used as +hash keys. String hash keys would create a new object for every single use, +thereby causing some memory overhead. +There is even a special syntax for symbol hash keys: + +~~~ +person_1 = { :name => "John", :age => 42 } +person_2 = { name: "Jane", age: 24 } # alternate syntax +~~~ + +Symbols can also be used as enumeration values +or to assign unique values to constants: + +~~~ +status = :open # :closed, ... + +NORTH = :NORTH +SOUTH = :SOUTH +~~~ + +### How can I access the value of a symbol? + +To get the value of the variable corresponding to a symbol, you can use +`symbol.to_s` or `"#{symbol}"` to get the name of the variable, and then +eval that in the scope of the symbol to get the variable's contents: + +~~~ +a = "This is the content of `a'" +b = eval("#{:a}") +a.object_id == b.object_id # => true +~~~ + +You can also use + +~~~ +b = binding.local_variable_get(:a) +~~~ + +If your symbol corresponds to the name of a method, you can use `send`: + +~~~ +class Demo + def hello + "Hello, world" + end +end + +demo = Demo.new +demo.send(:hello) +~~~ + +Or you can use `Object#method` to return a corresponding `Method` object, +which you may then call: + +~~~ +m = demo.method(:hello) # => # +m.call # => "Hello, world" +~~~ + +### Is `loop` a control structure? + +Although `loop` looks like a control structure, it is actually a method +defined in `Kernel`. The block which follows introduces a new scope for +local variables. + +### Ruby doesn't have a post-test loop + +Q: Ruby does not have a `do { ... } while` construct, so how can I implement +loops that test the condition at the end? + +Clemens Hintze says: You can use a combination of Ruby's `begin ... end` +and the `while` or `until` statement modifiers to achieve the same effect: + +~~~ +i = 0 +begin + puts "i = #{i}" + i += 1 +end until i > 4 +~~~ + +Produces: + +~~~ +i = 0 +i = 1 +i = 2 +i = 3 +i = 4 +~~~ + +### Why can't I pass a hash literal to a method: `p {}`? + +The `{}` is parsed as a block, not a `Hash` constructor. You can force the +`{}` to be treated as an expression by making the fact that it's a parameter +explicit: `p({})`. + +### I can't get `def pos=(val)` to work! + +I have the following code, but I cannot use the method `pos = 1`. + +~~~ +def pos=(val) + @pos = val + puts @pos +end +~~~ + +Methods with `=` appended must be called with an explicit receiver +(without the receiver, you are just assigning to a local variable). +Invoke it as `self.pos = 1`. + +### What is the difference between `'\1'` and `'\\1'`? + +They have the same meaning. In a single quoted string, only `\'` and `\\` +are transformed and other combinations remain unchanged. + +However, in a double quoted string, `"\1"` is the byte `\001` +(an octal bit pattern), while `"\\1"` is the two character string +containing a backslash and the character `"1"`. + +### What is the difference between `..` and `...`? + +`..` includes the right hand side in the range, `...` does not: + +~~~ +(5..8).to_a # => [5, 6, 7, 8] +(5...8).to_a # => [5, 6, 7] +~~~ + +### What is the difference between `or` and `||`? + +Q: `p(nil || "Hello")` prints `"Hello"`, while `p(nil or "Hello")` gives a +parse error. Why? + +A: `or` has a very low precedence, `p( (nil or "Hello") )` will work. + +The precedence of `or` is for instance also lower than that of `=`, +whereas `||` has a higher precedence: + +~~~ +foo = nil || "Hello" # parsed as: foo = (nil || "Hello") +foo # => "Hello" + +# but perhaps surprisingly: + +foo = nil or "Hello" # parsed as: (foo = nil) or "Hello" +foo # => nil +~~~ + +`or` (and similarly `and`) is best used **not** for combining +boolean expressions, but for control flow, like in + +~~~ +do_something or raise "some error!" +~~~ + +where `do_something` returns `false` or `nil` when an error occurs. + +### Does Ruby have function pointers? + +A `Proc` object generated by `Proc.new`, `proc`, or `lambda` can be referenced +from a variable, so that variable could be said to be a function pointer. You +can also get references to methods within a particular object instance using +`object.method`. + +### What is the difference between `load` and `require`? + +`load` will load and execute a Ruby program (`*.rb`). + +`require` loads Ruby programs as well, but will also load binary Ruby +extension modules (shared libraries or DLLs). In addition, +`require` ensures that a feature is never loaded more than once. + +### Does Ruby have exception handling? + +Ruby supports a flexible exception handling scheme: + +~~~ +begin + statements which may raise exceptions +rescue [exception class names] + statements when an exception occurred +rescue [exception class names] + statements when an exception occurred +ensure + statements that will always run +end +~~~ + +If an exception occurs in the `begin` clause, the `rescue` clause with the +matching exception name is executed. The `ensure` clause is executed whether +an exception occurred or not. `rescue` and `ensure` clauses may be omitted. + +If no exception class is designated for a `rescue` clause, `StandardError` +exception is implied, and exceptions which are in a `is_a?` relation to +`StandardError` are captured. + +This expression returns the value of the `begin` clause. + +The latest exception is accessed by the global variable `$!` +(and so its type can be determined using `$!.type`). diff --git a/fa/documentation/faq/7/index.md b/fa/documentation/faq/7/index.md new file mode 100644 index 0000000000..5524ec547a --- /dev/null +++ b/fa/documentation/faq/7/index.md @@ -0,0 +1,442 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Methods + +### How does Ruby choose which method to invoke? + +Ruby binds all messages to methods dynamically. It searches first for +singleton methods in the receiver, then for methods defined in the receiver's +own class, and finally for methods defined in the receiver's superclasses +(including any modules which may have been mixed in). You can see the order +of searching by displaying `ClassName.ancestors`, which shows the ancestor +classes and modules of `ClassName`. + +If after searching the alternatives a matching method could not be found, +Ruby tries to invoke a method called `method_missing`, repeating the same +search procedure to find it. This allows you to handle messages to unknown +methods, and is often used to provide dynamic interfaces to classes. + +~~~ +module Emphasizable + def emphasize + "**#{self}**" + end +end + +class String + include Emphasizable +end + +String.ancestors + # => [String, Emphasizable, Comparable, Object, Kernel, BasicObject] + +"Wow!".emphasize # => "**Wow!**" +~~~ + +When the method `emphasize` is searched for, it is not found in class +`String`, so Ruby searches next in the module `Emphasizable`. + +In order to override a method that already exists in the receiver's class, +e.g. `String#capitalize`, you need to insert the module into the +ancestor chain in front of that class, by using `prepend`: + +~~~ +module PrettyCapitalize + def capitalize + "**#{super}**" + end +end + +class String + prepend PrettyCapitalize +end + +String.ancestors + # => [PrettyCapitalize, String, Comparable, Object, Kernel, BasicObject] + +"hello".capitalize # => "**Hello**" +~~~ + +### Are `+`, `-`, `*`, ... operators? + +`+`, `-`, and the like are not operators but method calls. +They can, therefore, be overloaded by new definitions. + +~~~ +class MyString < String + def -(other) + self[0...other.size] # self truncated to other's size + end +end +~~~ + +However, the following are built-in control structures, not methods, +which cannot be overridden: + +~~~ +=, .., ..., not, ||, &&, and, or, :: +~~~ + +To overload or to define the unary `+` and `-` operators, +you need to use `+@` and `-@` as the method names. + +`=` is used to define a method to set an attribute of the object: + +~~~ +class Test + def attribute=(val) + @attribute = val + end +end + +t = Test.new +t.attribute = 1 +~~~ + +If operators such as `+` and `-` are defined, Ruby automatically handles +the self assignment forms (`+=`, `-=`, and so on). + +### Where are `++` and `--` ? + +Ruby does not have the autoincrement and autodecrement operators. +You can use `+= 1` and `-= 1` instead. + +### What is a singleton method? +{: #singleton-method} + +A singleton method is an instance method associated with one specific object. + +You create a singleton method by including the object in the definition: + +~~~ +class Foo; end + +foo = Foo.new +bar = Foo.new + +def foo.hello + puts "Hello" +end + +foo.hello +bar.hello +~~~ + +Produces: + +~~~ +Hello +prog.rb:11:in `
': undefined method `hello' for # (NoMethodError) +~~~ + +Singleton methods are useful when you want to add a method to an object and +creating a new subclass is not appropriate. + +### All these objects are fine, but does Ruby have any simple functions? + +Yes and no. Ruby has methods that look like functions in languages such +as C or Perl: + +~~~ +def hello(name) + puts "Hello, #{name}!" +end + +hello("World") +~~~ + +Produces: + +~~~ +Hello, World! +~~~ + +However, they are actually method calls with the receiver omitted. +In this case, Ruby assumes the receiver is self. + +So, `hello` resembles a function but it's actually a method belonging to +class `Object` and sent as a message to the hidden receiver self. +Ruby is a pure object-oriented language. + +Of course you can use such methods as if they were functions. + +### So where do all these function-like methods come from? + +Almost all classes in Ruby are derived from class `Object`. The definition +of class `Object` mixes in the methods defined in the `Kernel` module. +These methods are therefore available within every object in the system. + +Even if you are writing a simple Ruby program without classes, you are +actually working inside class `Object`. + +### Can I access an object's instance variables? + +An object's instance variables (those variables starting with `@`) are not +directly accessible outside the object. This promotes good encapsulation. +However, Ruby makes it easy for you to define accessors to these instance +variables in such a way that users of your class can treat instance variables +just like attributes. Just use one or more of `attr_reader`, `attr_writer`, +or `attr_accessor`. + +~~~ +class Person + attr_reader :name # read only + attr_accessor :wearing_a_hat # read/write + + def initialize(name) + @name = name + end +end + +p = Person.new("Dave") +p.name # => "Dave" +p.wearing_a_hat # => nil +p.wearing_a_hat = true +p.wearing_a_hat # => true +~~~ + +You can also define your own accessor functions (perhaps to perform +validation, or to handle derived attributes). The read accessor is simply a +method that takes no parameters, and the assignment accessor is a method name +ending in `=` that takes a single parameter. Although there can be no space +between the method name and the `=` in the method definition, you can insert +spaces there when you call the method, making it look like any other +assignment. You can also utilize self assignments such as `+=` and `-=`, +as long as the corresponding `+` or `-` methods are defined. + +### What's the difference between `private` and `protected`? + +The visibility keyword `private` makes a method callable only in a function +form, without an explicit receiver, and so it can only have `self` as its +receiver. A private method is callable only within the class in which the +method was defined or in its subclasses. + +~~~ +class Test + def foo + 99 + end + + def test(other) + p foo + p other.foo + end +end + +t1 = Test.new +t2 = Test.new + +t1.test(t2) + +# Now make `foo' private + +class Test + private :foo +end + +t1.test(t2) +~~~ + +Produces: + +~~~ +99 +99 +99 +prog.rb:8:in `test': private method `foo' called for # (NoMethodError) + from prog.rb:23:in `
' +~~~ + +Protected methods are also callable only from within their own class or +its subclasses, but they can be called both in function form and using +a receiver. For example: + +~~~ +def <=>(other) + age <=> other.age +end +~~~ + +Will compile if `age` is a protected method, but not if it is private. + +These features help you control access to your class's internals. + +### How can I change the visibility of a method? + +You change the visibility of methods using `private`, `protected`, and +`public`. When used without parameters during a class definition, they affect +the visibility of subsequent methods. When used with parameters, they change +the visibility of the named methods. + +~~~ +class Foo + def test + puts "hello" + end + private :test +end + +foo = Foo.new +foo.test +~~~ + +Produces: + +~~~ +prog.rb:9:in `
': private method `test' called for # (NoMethodError) +~~~ + +You can make a class method private using `private_class_method`. + +~~~ +class Foo + def self.test + puts "hello" + end + private_class_method :test +end + +Foo.test +~~~ + +Produces: + +~~~ +prog.rb:8:in `
': private method `test' called for Foo:Class (NoMethodError) +~~~ + +The default visibility for the methods defined in a class is public. +The exception is the instance initializing method, `initialize`. + +Methods defined at the toplevel are also public by default. + +### Can an identifier beginning with a capital letter be a method name? + +Yes, it can, but we don't do it lightly! If Ruby sees a capitalized name +followed by a space, it will probably (depending on the context) assume it's +a constant, not a method name. So, if you use capitalized method names, +always remember to put parameter lists in parentheses, and always put the +parentheses next to the method name with no intervening spaces. +(This last suggestion is a good idea anyway!) + +### Calling `super` gives an `ArgumentError`. + +Invoking `super` with no parameters in a method passes all the arguments of +that method to a method of the same name in a superclass. If the number of +arguments to the original method disagrees with that of the higher-level +method, an `ArgumentError` is raised. To get around this, simply call `super` +and pass a suitable number of arguments. + +### How can I call the method of the same name two levels up? + +`super` invokes the same named method one level up. If you are overloading a +method in a more distant ancestor, use `alias` to give it a new name before +masking it with your method definition. You can then call it using that +aliased name. + +### How can I invoke an original built-in method after redefining it? + +Within the method definition, you can use `super`. You can also use `alias` +to give it an alternative name. Finally, you can call the original method as +a singleton method of `Kernel`. + +### What is a destructive method? +{: #destructive-method} + +A destructive method is one which alters the state of an object. `String`, +`Array`, `Hash`, and others have such methods. Often there are two +versions of a method, one with a plain name, the other with the same name, +but followed by `!`. The plain version creates a copy of the receiver, makes +its change to it, and returns the copy. The “bang” version (with the `!`) +modifies the receiver in place. + +Beware, however, that there are a fair number of destructive methods that +do not have an `!`, including assignment methods (`name=`), array assignment +(`[]=`), and methods such as `Array.delete`. + +### Why can destructive methods be dangerous? + +Remember that assignment in most cases just copies object references, and that +parameter passing is equivalent to assignment. This means you can end up with +multiple variables referencing the same object. If one of those variables is +used to invoke a destructive method, the object referenced by all of them will +be changed. + +~~~ +def foo(str) + str.sub!(/foo/, "baz") +end + +obj = "foo" +foo(obj) # => "baz" +obj # => "baz" +~~~ + +In this case the actual argument is altered. + +### Can I return multiple values from a method? + +Yes and no. + +~~~ +def m1 + return 1, 2, 3 +end + +def m2 + [1, 2, 3] +end + +m1 # => [1, 2, 3] +m2 # => [1, 2, 3] +~~~ + +So, only one thing is returned, but that thing can be an arbitrarily complex +object. In the case of arrays, you can use multiple assignment to get the +effect of multiple return values. For example: + +~~~ +def foo + [20, 4, 17] +end + +a, b, c = foo +a # => 20 +b # => 4 +c # => 17 +~~~ diff --git a/fa/documentation/faq/8/index.md b/fa/documentation/faq/8/index.md new file mode 100644 index 0000000000..7d79609d38 --- /dev/null +++ b/fa/documentation/faq/8/index.md @@ -0,0 +1,378 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Classes and modules + +### Can a class definition be repeated? + +A class can be defined repeatedly. Each definition is added to the last +definition. If a method is redefined, the former one is overridden and lost. + +### Are there class variables? + +There are. A variable prefixed with two at signs (`@@`) is a class variable, +accessible within both instance and class methods of the class. + +~~~ +class Entity + + @@instances = 0 + + def initialize + @@instances += 1 + @number = @@instances + end + + def who_am_i + "I'm #{@number} of #{@@instances}" + end + + def self.total + @@instances + end +end + +entities = Array.new(9) { Entity.new } + +entities[6].who_am_i # => "I'm 7 of 9" +Entity.total # => 9 +~~~ + +However, you probably should use _class instance variables_ instead. + +### What is a class instance variable? + +Here the example of the previous section rewritten +using a class instance variable: + +~~~ +class Entity + + @instances = 0 + + class << self + attr_accessor :instances # provide class methods for reading/writing + end + + def initialize + self.class.instances += 1 + @number = self.class.instances + end + + def who_am_i + "I'm #{@number} of #{self.class.instances}" + end + + def self.total + @instances + end +end + +entities = Array.new(9) { Entity.new } + +entities[6].who_am_i # => "I'm 7 of 9" +Entity.instances # => 9 +Entity.total # => 9 +~~~ + +Here, `@instances` is a _class_ instance variable. It does not belong +to an instance of class `Entity`, but to the class object `Entity`, +which is an instance of class `Class`. + +Class instance variables are directly accessible only within class methods +of the class. + +### What is the difference between class variables and class instance variables? + +The main difference is the behavior concerning inheritance: +class variables are shared between a class and all its subclasses, +while class instance variables only belong to one specific class. + +Class variables in some way can be seen as global variables within +the context of an inheritance hierarchy, with all the problems +that come with global variables. +For instance, a class variable might (accidentally) be reassigned +by any of its subclasses, affecting all other classes: + +~~~ +class Woof + + @@sound = "woof" + + def self.sound + @@sound + end +end + +Woof.sound # => "woof" + +class LoudWoof < Woof + @@sound = "WOOF" +end + +LoudWoof.sound # => "WOOF" +Woof.sound # => "WOOF" (!) +~~~ + +Or, an ancestor class might later be reopened and changed, +with possibly surprising effects: + +~~~ +class Foo + + @@var = "foo" + + def self.var + @@var + end +end + +Foo.var # => "foo" (as expected) + +class Object + @@var = "object" +end + +Foo.var # => "object" (!) +~~~ + +So, unless you exactly know what you are doing and explicitly need +this kind of behavior, you better should use class instance variables. + +### Does Ruby have class methods? +{: #class-method} + +A [singleton method](../7/#singleton-method) of a class object is called a +class method. +(Actually, the class method is defined in the metaclass, but that is pretty +much transparent). Another way of looking at it is to say that a class method +is a method whose receiver is a class. + +It all comes down to the fact that you can call class methods without having +to have instances of that class (objects) as the receiver. + +Let's create a singleton method of class `Foo`: + +~~~ +class Foo + def self.test + "this is foo" + end +end + +# It is invoked this way. + +Foo.test # => "this is foo" +~~~ + +In this example, `Foo.test` is a class method. + +Instance methods which are defined in class `Class` can be used +as class methods for every(!) class. + +### What is a singleton class? + +A singleton class is an anonymous class that is created by subclassing the +class associated with a particular object. Singleton classes are another +way of extending the functionality associated with just one object. + +Take the lowly `Foo`: + +~~~ +class Foo + def hello + "hello" + end +end + +foo = Foo.new +foo.hello # => "hello" +~~~ + +Now let's say we need to add class-level functionality to just this one +instance: + +~~~ +class << foo + attr_accessor :name + + def hello + "hello, I'm #{name}" + end +end + +foo.name = "Tom" +foo.hello # => "hello, I'm Tom" +Foo.new.hello # => "hello" +~~~ + +We've customized `foo` without changing the characteristics of `Foo`. + +### What is a module function? + +{% include faq-out-of-date.html %} + +A module function is a private, singleton method defined in a module. +In effect, it is similar to a [class method](#class-method), +in that it can be called using the `Module.method` notation: + +~~~ +Math.sqrt(2) # => 1.414213562 +~~~ + +However, because modules can be mixed in to classes, module functions can +also be used without the prefix (that's how all those `Kernel` functions are +made available to objects): + +~~~ +include Math +sqrt(2) # => 1.414213562 +~~~ + +Use `module_function` to make a method a module function. + +~~~ +module Test + def thing + # ... + end + module_function :thing +end +~~~ + +### What is the difference between a class and a module? + +Modules are collections of methods and constants. They cannot generate +instances. Classes may generate instances (objects), and have per-instance +state (instance variables). + +Modules may be mixed in to classes and other modules. The mixed in module's +constants and methods blend into that class's own, augmenting the class's +functionality. Classes, however, cannot be mixed in to anything. + +A class may inherit from another class, but not from a module. + +A module may not inherit from anything. + +### Can you subclass modules? + +No. However, a module may be included in a class or another module to mimic +multiple inheritance (the mixin facility). + +This does not generate a subclass (which would require inheritance), but does +generate an `is_a?` relationship between the class and the module. + +### Give me an example of a mixin + +The module `Comparable` provides a variety of comparison operators +(`<`, `<=`, `==`, `>=`, `>`, `between?`). It defines these in terms +of calls to the general comparison method, `<=>`. However, it does +not itself define `<=>`. + +Say you want to create a class where comparisons are based on the number of +legs an animal has: + +~~~ +class Animal + include Comparable + + attr_reader :legs + + def initialize(name, legs) + @name, @legs = name, legs + end + + def <=>(other) + legs <=> other.legs + end + + def inspect + @name + end +end + +c = Animal.new("cat", 4) +s = Animal.new("snake", 0) +p = Animal.new("parrot", 2) + +c < s # => false +s < c # => true +p >= s # => true +p.between?(s, c) # => true +[p, s, c].sort # => [snake, parrot, cat] +~~~ + +All `Animal` must do is define its own semantics for the operator `<=>`, +and mix in the `Comparable` module. `Comparable`'s methods now become +indistinguishable from `Animal`'s and your class suddenly sprouts new +functionality. And because the same `Comparable` module is used by many +classes, your new class will share a consistent and well understood semantics. + +### Why are there two ways of defining class methods? + +You can define a class method in the class definition, and you can define +a class method at the top level. + +~~~ +class Demo + def self.class_method + end +end + +def Demo.another_class_method +end +~~~ + +There is only one significant difference between the two. +In the class definition you can refer to the class's constants directly, +as the constants are within scope. At the top level, you have to use the +`Class::CONST` notation. + +### What is the difference between `include` and `extend`? + +{% include faq-out-of-date.html %} + +`include` mixes a module into a class or another module. Methods from that +module are called function-style (without a receiver). + +`extend` is used to include a module in an object (instance). +Methods in the module become methods in the object. + +### What does `self` mean? + +`self` is the currently executing receiver, the object to which a method +is applied. A function-style method call implies `self` as the receiver. diff --git a/fa/documentation/faq/9/index.md b/fa/documentation/faq/9/index.md new file mode 100644 index 0000000000..c89a09b315 --- /dev/null +++ b/fa/documentation/faq/9/index.md @@ -0,0 +1,372 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +{% include faq-notice.md %} + +## Built-in libraries + +### What does `instance_methods(false)` return? + +The method `instance_methods` returns an array containing the names of +instance methods in the receiving class or module. This will include +the methods in superclasses and in mixed in modules. + +`instance_methods(false)` or `instance_methods(nil)` returns the names +of just those methods which are defined in the receiver. + +### How do random number seeds work? + +If `rand` is called without a prior call to `srand`, +Ruby's pseudo-random number generator uses a random(ish) seed that +amongst other things uses an entropy source provided by the OS, +if available. +Successive runs of a program that does not use `srand` will generate +different sequences of random numbers. + +For testing purposes, you can get a predictable behavior with the same +series of numbers each time the program is run by calling `srand` +with a constant seed. + +### I read a file and changed it, but the file on disk has not changed. + +~~~ +File.open("example", "r+").readlines.each_with_index do |line, i| + line[0,0] = "#{i+1}: " +end +~~~ + +This program does _not_ add line numbers to the file `example`. It does read +the contents of the file, and for each line read does prepend the line number, +but the data is never written back. The code below _does_ update the file +(although somewhat dangerously, as it takes no backup before starting the +update): + +~~~ +File.open("example", "r+") do |f| + lines = f.readlines + lines.each_with_index {|line, i| line[0,0] = "#{i+1}: " } + f.rewind + f.puts lines +end +~~~ + +### How can I process a file and update its contents? + +Using the command-line option `-i`, or built-in variable `$-i`, you can read +a file and replace it. + +The code in the preceding question, which added line numbers to a file, +is probably best written using this technique: + +~~~ +$ ruby -i -ne 'print "#$.: #$_"' example +~~~ + +If you want to preserve the original file, use `-i.bak` to create a backup. + +### I wrote a file, copied it, but the end of the copy seems to be lost. + +This code will not work correctly: + +~~~ +require "fileutils" + +File.open("file", "w").puts "This is a file." +FileUtils.cp("file", "newfile") +~~~ + +Because I/O is buffered, `file` is being copied before its contents have been +written to disk. `newfile` will probably be empty. However, when the program +terminates, the buffers are flushed, and file has the expected content. + +The problem doesn't arise if you make sure that `file` is closed before +copying: + +~~~ +require "fileutils" + +File.open("file", "w") {|f| f.puts "This is a file." } +FileUtils.cp("file", "newfile") +~~~ + +### How can I get the line number in the current input file? + +As you read from a file, Ruby increments a line number counter in the global +variable `$.`. This is also available using the `lineno` attribute of the +`File` object. + +The special constant `ARGF` is a file-like object that can be used to read +all the input files specified on the command line (or standard input if there +are no files). `ARGF` is used implicitly by code such as: + +~~~ +while gets + print $_ +end +~~~ + +In this case, `$.` will be the cumulative number of lines read across all +input files. To get the line number in the current file, use + +~~~ +ARGF.file.lineno +~~~ + +You can also get the name of the current file using `ARGF.file.path`. + +### How can I use `less` to display my program's output? + +I tried the following, but nothing came out: + +~~~ +open("|less", "w").puts "abc" +~~~ + +That's because the program ends immediately, and `less` never gets a chance +to see the stuff you've written to it, never mind to display it. +Make sure that the IO is properly closed and it will wait until `less` ends. + +~~~ +open("|less", "w") {|f| f.puts "abc" } +~~~ + +### What happens to a `File` object which is no longer referenced? + +A `File` object which is no longer referenced becomes eligible for garbage +collection. The file will be closed automatically when the `File` object is +garbage collected. + +### I feel uneasy if I don't close a file. + +There are at least four good ways of ensuring that you do close a file: + +~~~ +# (1) +f = File.open("file") +begin + f.each {|line| print line } +ensure + f.close +end + +# (2) +File.open("file") do |f| + f.each {|line| print line } +end + +# (3) +File.foreach("file") {|line| print line } + +# (4) +File.readlines("file").each {|line| print line } +~~~ + +### How can I sort files by their modification time? + +~~~ +Dir.glob("*").sort {|a, b| File.mtime(b) <=> File.mtime(a) } +~~~ + +Although this works (returning a list in reverse chronological order) it +isn't very efficient, as it fetches the files' modification times from the +operating system on every comparison. + +More efficiency can be bought with some extra complexity: + +~~~ +Dir.glob("*").map {|f| [File.mtime(f), f] }. + sort {|a, b| b[0] <=> a[0] }.map(&:last) +~~~ + +### How can I count the frequency of words in a file? + +~~~ +freq = Hash.new(0) +File.read("example").scan(/\w+/) {|word| freq[word] += 1 } +freq.keys.sort.each {|word| puts "#{word}: #{freq[word]}" } +~~~ + +Produces: + +~~~ +and: 1 +is: 3 +line: 3 +one: 1 +this: 3 +three: 1 +two: 1 +~~~ + +### How can I sort strings in alphabetical order? + +If you want your strings to sort 'AAA', 'BBB', ..., 'ZZZ', 'aaa', 'bbb', +then the built-in comparison will work just fine. + +If you want to sort ignoring case distinctions, compare downcased versions of +the strings in the sort block: + +~~~ +array = %w( z bB Bb bb Aa BB aA AA aa a A ) +array.sort {|a, b| a.downcase <=> b.downcase } + # => ["a", "A", "Aa", "aA", "AA", "aa", "bB", "Bb", "bb", "BB", "z"] +~~~ + +If you want to sort so that the 'A's and 'a's come together, but 'a' is +considered greater than 'A' (so 'Aa' comes after 'AA' but before 'AB'), use: + +~~~ +array.sort {|a, b| (a.downcase <=> b.downcase).nonzero? || a <=> b } + # => ["A", "a", "AA", "Aa", "aA", "aa", "BB", "Bb", "bB", "bb", "z"] +~~~ + +### How can I expand tabs to spaces? +{: #tab-expansion} + +If `a` holds the string to be expanded, you could use one of: + +~~~ +1 while a.sub!(/(^[^\t]*)\t(\t*)/){$1+" "*(8-$1.size%8+8*$2.size)} +# or +1 while a.sub!(/\t(\t*)/){" "*(8-$~.begin(0)%8+8*$1.size)} +# or +a.gsub!(/([^\t]{8})|([^\t]*)\t/n){[$+].pack("A8")} +~~~ + +### How can I escape a backslash in a regular expression? + +`Regexp.quote('\\')` escapes a backslash. + +It gets trickier if you are using `sub` and `gsub`. Say you write +`gsub(/\\/, '\\\\')`, hoping to replace each backslash with two. +The second argument is converted to `'\\'` in syntax analysis. When the +substitution occurs, the regular expression engine converts this to `'\'`, +so the net effect is to replace each single backslash with another single +backslash. You need to write `gsub(/\\/, '\\\\\\')`! + +However, using the fact that `\&` contains the matched string, you could also +write `gsub(/\\/, '\&\&')`. + +If you use the block form of `gsub`, i.e. `gsub(/\\/) { '\\\\' }`, the string +for substitution is analyzed only once (during the syntax pass) and the +result is what you intended. + +### What is the difference between `sub` and `sub!`? + +In `sub`, a copy of the receiver is generated, substituted, and returned. + +In `sub!`, the receiver is altered and returned if any match was found. +Otherwise, `nil` is returned. + +Methods like `sub!`, which alter the attribute of the receiver, +are called [destructive methods](../7/#destructive-method). +Usually, if there are two similar methods and one is destructive, +the destructive one has a suffix `!`. + +~~~ +def foo(str) + str.sub(/foo/, "baz") +end + +obj = "foo" +foo(obj) # => "baz" +obj # => "foo" + +def foo(str) + str.sub!(/foo/, "baz") +end + +foo(obj) # => "baz" +obj # => "baz" +~~~ + +### Where does `\Z` match? + +`\Z` matches just before the last `\n` (newline) if the string ends +with a `\n`, otherwise it matches at the end of a string. + +### What is the difference between `thread` and `fork`? + +{% include faq-out-of-date.html %} + +Ruby threads are implemented within the interpreter, while `fork` invokes the +operating system to create a separately executing subprocess. + +Thread and fork have the following characteristics: + +* `fork` is slow, `thread` is not. +* `fork` does not share the memory space. +* `thread` does not cause thrashing. +* `thread` works on DOS. +* When `thread` gets in a deadlock, the whole process stops. +* `fork` can take advantage of pauses waiting for I/O to complete, + `thread` does not (at least not without some help). + +You probably shouldn't mix `fork` and `thread`. + +### How can I use `Marshal`? + +`Marshal` is used to store an object in a file or a string, and later +reconstitute it. Objects may be stored using: + +~~~ +Marshal.dump( obj [, io ] [, lev] ) +~~~ + +`io` is a writable `IO` object, `lev` designates the level to which objects +are dereferred and stored. If `lev` levels of dereferring are done and object +references still exist, then `dump` stores just the reference, not the object +referenced. This is not good, as these referenced objects cannot be +subsequently reconstructed. + +If `io` is omitted, the marshaled objects are returned in a string. + +You can load objects back using: + +~~~ +obj = Marshal.load(io) +# or +obj = Marshal.load(str) +~~~ + +where `io` is a readable `IO` object, `str` is the dumped string. + +### How can I use `trap`? + +`trap` associates code blocks with external events (signals). + +~~~ +trap("PIPE") { raise "SIGPIPE" } +~~~ diff --git a/fa/documentation/faq/index.md b/fa/documentation/faq/index.md new file mode 100644 index 0000000000..cc2c6f6947 --- /dev/null +++ b/fa/documentation/faq/index.md @@ -0,0 +1,62 @@ +--- +layout: page +title: "Official Ruby FAQ" +lang: en + +header: | +
+ Content + | + 1 + | + 2 + | + 3 + | + 4 + | + 5 + | + 6 + | + 7 + | + 8 + | + 9 + | + 10 + | + 11 +
+

Official Ruby FAQ

+ +--- + +This document contains Frequently Asked Questions about Ruby with answers. +{: .summary} + +This FAQ is based on "[The Ruby Language FAQ][original-faq]" originally +compiled by Shugo Maeda and translated into English by Kentaro Goto. +Thanks to Zachary Scott and Marcus Stollsteimer for incorporating +the FAQ into the site and for a major overhaul of the content. + +The code examples in this document have been run using Ruby 2.3. + +[original-faq]: http://ruby-doc.org/docs/ruby-doc-bundle/FAQ/FAQ.html + +{% include faq-notice.md %} + +## Content + +* [General questions](1/) +* [How does Ruby stack up against...?](2/) +* [Installing Ruby](3/) +* [Variables, constants, and arguments](4/) +* [Iterators](5/) +* [Syntax](6/) +* [Methods](7/) +* [Classes and modules](8/) +* [Built-in libraries](9/) +* [Extension library](10/) +* [Other features](11/) diff --git a/fa/documentation/index.md b/fa/documentation/index.md new file mode 100644 index 0000000000..30da430601 --- /dev/null +++ b/fa/documentation/index.md @@ -0,0 +1,175 @@ +--- +layout: page +title: "مستندات" +lang: fa +--- + +Guides, tutorials, and reference material to help you learn more about Ruby +{: .summary} + +### Installing Ruby + +Although you can easily [try Ruby in your browser][1], you can also read +the [installation guide](installation/) for help on installing Ruby. + +### Getting Started + +[Official FAQ](/en/documentation/faq/) +: The official frequently asked questions. + +[Ruby Koans][2] +: The Koans walk you along the path to enlightenment in order to learn + Ruby. The goal is to learn the Ruby language, syntax, structure, and + some common functions and libraries. We also teach you culture. + +[Why’s (Poignant) Guide to Ruby][5] +: An unconventional but interesting book that will teach you Ruby + through stories, wit, and comics. Originally created by *why the lucky + stiff*, this guide remains a classic for Ruby learners. + +[Learning Ruby][6] +: A thorough collection of Ruby study notes for those who are new to the + language and in search of a solid introduction to Ruby’s concepts and + constructs. + +[Ruby Essentials][7] +: Ruby Essentials is a free on-line book designed to provide a concise + and easy to follow guide to learning Ruby. + +[Learn to Program][8] +: A wonderful little tutorial by Chris Pine for programming newbies. If + you don’t know how to program, start here. + +[Learn Ruby the Hard Way][38] +: A very good set of exercises with explanations that guide you from + the absolute basics of Ruby all the way to OOP and web development. + +### Manuals + +[Programming Ruby][9] +: The seminal work on Ruby in English, this first edition of the + [Pragmatic Programmers’ book][10] is available for free online. + +[Ruby User’s Guide][11] +: Translated from the original Japanese version written by Yukihiro + Matsumoto (the creator of Ruby), this version, by Goto Kentaro and + Mark Slagell, is a nice overview of many aspects of the Ruby language. + +[The Ruby Programming Wikibook][12] +: A free online manual with beginner and intermediate content plus a + thorough language reference. + +### Reference Documentation + +[Official API Documentation][docs-rlo-en] +: The official Ruby API documentation for different versions including + the currently unreleased (trunk) version. + +[Ruby Core Reference][13] +: Pulled straight from the source code using [RDoc][14], this reference + work documents all of the core classes and modules (like String, + Array, Symbol, etc…). + +[Ruby Standard Library Reference][15] +: Also pulled from the source code using RDoc, this reference work + documents the standard library. + +[Ruby C API Reference][extensions] +: The official introduction to Ruby's C API. + Great if you want to write C extensions + or contribute to Ruby’s development. + +[RubyDoc.info][16] +: The one-stop web site for reference documentation about Ruby gems and + GitHub-hosted Ruby projects. + +[Ruby & Rails Searchable API Docs][17] +: Rails and Ruby documentation with smart searching. + +[APIdock][18] +: Ruby, Rails and RSpec documentation with users’ notes. + +### Editors and IDEs + +For coding in Ruby you can use the default editor of your operating +system. By the way, to be more effective in coding, it is worth to +choose a source code editor with basic Ruby support (e.g. +syntax-highlighting, file browsing) or an integrated development +environment with advanced features (e.g. code completion, refactoring, +testing support). + +Here is a list of popular tools used by Rubyists: + +* Linux and cross-platform tools: + * [Aptana Studio][19] + * [Emacs][20] with [Ruby mode][21] and [Rsense][22] + * [Geany][23] + * [gedit][24] + * [Vim][25] with [vim-ruby][26] plugin and [Rsense][22] + * [RubyMine][27] + * [SciTe][28] + * [NetBeans][36] + * [Sublime Text][37] + * [Atom][atom] + * [Visual Studio Code][vscode] + +* On Windows: + * [Notepad++][29] + * [E-TextEditor][30] + * [Ruby In Steel][31] + +* On macOS: + * [TextMate][32] + * [TextWrangler][33] + * [Dash][39] (documentation browser) + +### Further Reading + +[Ruby-doc.org][34] maintains a comprehensive list of English +documentation sources. There are also plenty of [books about Ruby][35]. +If you have questions about Ruby the +[mailing list](/en/community/mailing-lists/) is a great place to start. + + + +[1]: https://ruby.github.io/TryRuby/ +[2]: http://rubykoans.com/ +[5]: http://mislav.uniqpath.com/poignant-guide/ +[6]: http://rubylearning.com/ +[7]: http://www.techotopia.com/index.php/Ruby_Essentials +[8]: http://pine.fm/LearnToProgram/ +[9]: http://www.ruby-doc.org/docs/ProgrammingRuby/ +[10]: http://pragmaticprogrammer.com/titles/ruby/index.html +[11]: http://www.rubyist.net/~slagell/ruby/ +[12]: http://en.wikibooks.org/wiki/Ruby_programming_language +[13]: http://www.ruby-doc.org/core +[14]: https://ruby.github.io/rdoc/ +[15]: http://www.ruby-doc.org/stdlib +[extensions]: https://docs.ruby-lang.org/en/trunk/extension_rdoc.html +[16]: http://www.rubydoc.info/ +[17]: http://rubydocs.org/ +[18]: http://apidock.com/ +[19]: http://www.aptana.com/ +[20]: http://www.gnu.org/software/emacs/ +[21]: http://www.emacswiki.org/emacs/RubyMode +[22]: http://rsense.github.io/ +[23]: http://www.geany.org/ +[24]: http://projects.gnome.org/gedit/screenshots.html +[25]: http://www.vim.org/ +[26]: https://github.com/vim-ruby/vim-ruby +[27]: http://www.jetbrains.com/ruby/ +[28]: http://www.scintilla.org/SciTE.html +[29]: http://notepad-plus-plus.org/ +[30]: http://www.e-texteditor.com/ +[31]: http://www.sapphiresteel.com/ +[32]: http://macromates.com/ +[33]: http://www.barebones.com/products/textwrangler/ +[34]: http://ruby-doc.org +[35]: http://www.ruby-doc.org/bookstore +[36]: https://netbeans.org/ +[37]: http://www.sublimetext.com/ +[38]: http://ruby.learncodethehardway.org/ +[39]: http://kapeli.com/dash +[docs-rlo-en]: https://docs.ruby-lang.org/en/ +[atom]: https://atom.io/ +[vscode]: https://code.visualstudio.com/ diff --git a/fa/documentation/installation/index.md b/fa/documentation/installation/index.md new file mode 100644 index 0000000000..f964b79ae1 --- /dev/null +++ b/fa/documentation/installation/index.md @@ -0,0 +1,355 @@ +--- +layout: page +title: "نصب روبی" +lang: fa +--- + +With package managers or third-party tools, you have plenty of options +to install and manage Ruby. +{: .summary} + +You may already have Ruby installed on your computer. You can check +inside a [terminal emulator][terminal] by typing: + +{% highlight sh %} +ruby -v +{% endhighlight %} + +This should output some information on the installed Ruby version. + +## Choose Your Installation Method + +There are several ways to install Ruby: + +* On a UNIX-like operating system, using your system's + **package manager** is easiest. + However, the packaged Ruby version may not be the newest one. +* **Installers** can be used to install a specific or multiple + Ruby versions. There is also an installer for Windows. +* **Managers** help you to switch between multiple Ruby versions + on your system. +* Finally, you can also **build Ruby from source**. + +Here are available installation methods: + +* [Package Management Systems](#package-management-systems) + * [Debian, Ubuntu](#apt) + * [Windows WSL Ubuntu](#apt-wsl) + * [CentOS, Fedora, RHEL](#yum) + * [Snap](#snap) + * [Gentoo](#portage) + * [Arch Linux](#pacman) + * [macOS](#homebrew) + * [FreeBSD](#freebsd) + * [OpenIndiana](#openindiana) + * [Other Distributions](#other-systems) +* [Installers](#installers) + * [ruby-build](#ruby-build) + * [ruby-install](#ruby-install) + * [RubyInstaller](#rubyinstaller) (Windows) + * [RailsInstaller and Ruby Stack](#railsinstaller) +* [Managers](#managers) + * [chruby](#chruby) + * [rbenv](#rbenv) + * [RVM](#rvm) + * [uru](#uru) +* [Building from source](#building-from-source) + + +## Package Management Systems +{: #package-management-systems} + +If you cannot compile your own Ruby, and you do not want to use a +third-party tool, you can use your system's package manager to install Ruby. + +Some members of the Ruby community feel that you should avoid package +managers to install Ruby and that you should use dedicated tools instead. + +It is possible that major package managers will install older Ruby +versions instead of the latest release. To use the latest Ruby release, +check that the package name matches its version number. Or use a +dedicated [installer][installers]. + + +### apt (Debian or Ubuntu) +{: #apt} + +Debian GNU/Linux and Ubuntu use the apt package manager. You can use it +like this: + +{% highlight sh %} +$ sudo apt-get install ruby-full +{% endhighlight %} + +### apt (Windows WSL Ubuntu) +{: #apt-wsl} + +If you use Windows 10, you can use Linux Ubuntu OS with WSL. And you can also use Ruby with apt. + +There is an information that how to install WSL in this page: + +[Windows Subsystem for Linux Installation Guide for Windows 10](https://docs.microsoft.com/en-us/windows/wsl/install-win10) + +You can use the apt same as Linux OS like this: + +{% highlight sh %} +$ sudo apt-get install ruby-full +{% endhighlight %} + +Or you can also use Ruby managers like the rbenv on WSL. + +### yum (CentOS, Fedora, or RHEL) +{: #yum} + +CentOS, Fedora, and RHEL use the yum package manager. +You can use it like this: + +{% highlight sh %} +$ sudo yum install ruby +{% endhighlight %} + +The installed version is typically the latest version of Ruby available +at the release time of the specific distribution version. + + +### snap (Ubuntu or other Linux distributions) +{: #snap} + +Snap is a package manager developed by Canonical. +It is available out-of-the-box on Ubuntu, but snap also works +on many other Linux distributions. +You can use it like this: + +{% highlight sh %} +$ sudo snap install ruby --classic +{% endhighlight %} + +We have several channels per Ruby minor series. +For instance, the following commands switch to Ruby 2.3: + +{% highlight sh %} +$ sudo snap switch ruby --channel=2.3/stable +$ sudo snap refresh +{% endhighlight %} + + +### portage (Gentoo) +{: #portage} + +Gentoo uses the portage package manager. + +{% highlight sh %} +$ sudo emerge dev-lang/ruby +{% endhighlight %} + +To install a specific version, set `RUBY_TARGETS` in your `make.conf`. +See the [Gentoo Ruby Project website][gentoo-ruby] for details. + + +### pacman (Arch Linux) +{: #pacman} + +Arch Linux uses a package manager named pacman. +To get Ruby, just do this: + +{% highlight sh %} +$ sudo pacman -S ruby +{% endhighlight %} + +This should install the latest stable Ruby version. + + +### Homebrew (macOS) +{: #homebrew} + +Ruby versions 2.0 and above are included by default in macOS releases +since at least El Capitan (10.11). + +[Homebrew][homebrew] is a commonly used package manager on macOS. +Installing Ruby using Homebrew is easy: + +{% highlight sh %} +$ brew install ruby +{% endhighlight %} + +This should install the latest Ruby version. + + +### FreeBSD +{: #freebsd} + +FreeBSD offers both pre-packaged and source-based methods to install Ruby. +Prebuilt packages can be installed via the pkg tool: + +{% highlight sh %} +$ pkg install ruby +{% endhighlight %} + +A source-based method can be used to install Ruby using the +[Ports Collection][freebsd-ports-collection]. This is useful if you want +to customize the build configuration options. + +More information about Ruby and its surrounding ecosystem on FreeBSD +can be found on the [FreeBSD Ruby Project website][freebsd-ruby]. + + +### Ruby on OpenIndiana +{: #openindiana} + +To install Ruby on [OpenIndiana][openindiana], please use the +Image Packaging System (IPS) client. +This will install the Ruby binaries and RubyGems directly +from the OpenIndiana repositories. It’s easy: + +{% highlight sh %} +$ pkg install runtime/ruby +{% endhighlight %} + +However, the third-party tools might be a good way to obtain the +latest version of Ruby. + + +### Other Distributions +{: #other-systems} + +On other systems, you can search the package repository of your Linux +distribution's manager for Ruby. Alternatively, you can use a +[third-party installer][installers]. + + +## Installers +{: #installers} + +If the version of Ruby provided by your system or package manager is out +of date, a newer one can be installed using a third-party installer. + +Some installers allow you to install multiple versions on the same +system; associated managers can help to switch between the different +Rubies. + +If you are planning to use [RVM](#rvm) as a version manager you don't +need a separate installer, it comes with its own. + + +### ruby-build +{: #ruby-build} + +[ruby-build][ruby-build] is a plugin for [rbenv](#rbenv) that allows you +to compile and install different versions of Ruby. ruby-build can also +be used as a standalone program without rbenv. It is available for macOS, +Linux, and other UNIX-like operating systems. + + +### ruby-install +{: #ruby-install} + +[ruby-install][ruby-install] allows you to compile and install different +versions of Ruby into arbitrary directories. [chruby](#chruby) is a +complimentary tool used to switch between Ruby versions. It is available +for macOS, Linux, and other UNIX-like operating systems. + + +### RubyInstaller +{: #rubyinstaller} + +On Windows, [RubyInstaller][rubyinstaller] gives you everything you need +to set up a full Ruby development environment. + +Just download it, run it, and you are done! + + +### RailsInstaller and Ruby Stack +{: #railsinstaller} + +If you are installing Ruby in order to use Ruby on Rails, +you can use the following installers: + +* [RailsInstaller][railsinstaller] uses [RubyInstaller][rubyinstaller] + but gives you extra tools that help with Rails development. It + supports macOS and Windows. +* [Bitnami Ruby Stack][rubystack] provides a complete development + environment for Rails. It supports macOS, Linux, Windows, virtual + machines, and cloud images. + + +## Managers +{: #managers} + +Many Rubyists use Ruby managers to manage multiple Rubies. They allow +easy or even automatic switching between Ruby versions depending on the +project and other advantages but are not officially supported. You can +however find support within their respective communities. + + +### chruby +{: #chruby} + +[chruby][chruby] allows you to switch between multiple Rubies. It can +manage Rubies installed by [ruby-install](#ruby-install) or even built +from source. + + +### rbenv +{: #rbenv} + +[rbenv][rbenv] allows you to manage multiple installations of Ruby. +While it can't install Ruby by default, its [ruby-build](#ruby-build) +plugin can. Both tools are available for macOS, Linux, or other +UNIX-like operating systems. + + +### RVM ("Ruby Version Manager") +{: #rvm} + +[RVM][rvm] allows you to install and manage multiple installations of +Ruby on your system. It can also manage different gemsets. It is +available for macOS, Linux, or other UNIX-like operating systems. + + +### uru +{: #uru} + +[Uru][uru] is a lightweight, multi-platform command line tool that helps you +to use multiple Rubies on macOS, Linux, or Windows systems. + + +## Building from Source +{: #building-from-source} + +Of course, you can install Ruby from source. +[Download][download] and unpack a tarball, then just do this: + +{% highlight sh %} +$ ./configure +$ make +$ sudo make install +{% endhighlight %} + +By default, this will install Ruby into `/usr/local`. +To change, pass the `--prefix=DIR` option to the `./configure` script. + +You can find more information about building from source in the +[Ruby README file][readme]. + +Using the third-party tools or package managers might be a better idea, +though, because the installed Ruby won't be managed by any tools. + + +[rvm]: http://rvm.io/ +[rbenv]: https://github.com/rbenv/rbenv#readme +[ruby-build]: https://github.com/rbenv/ruby-build#readme +[ruby-install]: https://github.com/postmodern/ruby-install#readme +[chruby]: https://github.com/postmodern/chruby#readme +[uru]: https://bitbucket.org/jonforums/uru +[rubyinstaller]: https://rubyinstaller.org/ +[railsinstaller]: http://railsinstaller.org/ +[rubystack]: http://bitnami.com/stack/ruby/installer +[openindiana]: http://openindiana.org/ +[gentoo-ruby]: http://www.gentoo.org/proj/en/prog_lang/ruby/ +[freebsd-ruby]: https://wiki.freebsd.org/Ruby +[freebsd-ports-collection]: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html +[homebrew]: http://brew.sh/ +[terminal]: https://en.wikipedia.org/wiki/List_of_terminal_emulators +[download]: /en/downloads/ +[installers]: /en/documentation/installation/#installers +[readme]: https://github.com/ruby/ruby#how-to-compile-and-install diff --git a/fa/documentation/quickstart/2/index.md b/fa/documentation/quickstart/2/index.md new file mode 100644 index 0000000000..5a3101a82a --- /dev/null +++ b/fa/documentation/quickstart/2/index.md @@ -0,0 +1,126 @@ +--- +layout: page +title: "روبی در ۲۰ دقیقه" +lang: fa + +header: | +
+ ۱ + | + ۲ + | + ۳ + | + ۴ +
+

روبی در ۲۰ دقیقه

+ +--- + +What if we want to say “Hello” a lot without getting our fingers all +tired? We need to define a method! + +{% highlight irb %} +irb(main):010:0> def hi +irb(main):011:1> puts "Hello World!" +irb(main):012:1> end +=> :hi +{% endhighlight %} + +The code `def hi` starts the definition of the method. It tells Ruby that +we’re defining a method, that its name is `hi`. The next line is the body +of the method, the same line we saw earlier: `puts "Hello World"`. +Finally, the last line `end` tells Ruby we’re done defining the method. +Ruby’s response `=> :hi` tells us that it knows we’re done defining the +method. This response could be `=> nil` for Ruby 2.0 and earlier versions. +But, it's not important here, so let's go on. + +## The Brief, Repetitive Lives of a Method + +Now let’s try running that method a few times: + +{% highlight irb %} +irb(main):013:0> hi +Hello World! +=> nil +irb(main):014:0> hi() +Hello World! +=> nil +{% endhighlight %} + +Well, that was easy. Calling a method in Ruby is as easy as just +mentioning its name to Ruby. If the method doesn’t take parameters +that’s all you need. You can add empty parentheses if you’d like, but +they’re not needed. + +What if we want to say hello to one person, and not the whole world? +Just redefine `hi` to take a name as a parameter. + +{% highlight irb %} +irb(main):015:0> def hi(name) +irb(main):016:1> puts "Hello #{name}!" +irb(main):017:1> end +=> :hi +irb(main):018:0> hi("Matz") +Hello Matz! +=> nil +{% endhighlight %} + +So it works… but let’s take a second to see what’s going on here. + +## Holding Spots in a String + +What’s the `#{name}` bit? That’s Ruby’s way of inserting something into +a string. The bit between the braces is turned into a string (if it +isn’t one already) and then substituted into the outer string at that +point. You can also use this to make sure that someone’s name is +properly capitalized: + +{% highlight irb %} +irb(main):019:0> def hi(name = "World") +irb(main):020:1> puts "Hello #{name.capitalize}!" +irb(main):021:1> end +=> :hi +irb(main):022:0> hi "chris" +Hello Chris! +=> nil +irb(main):023:0> hi +Hello World! +=> nil +{% endhighlight %} + +A couple of other tricks to spot here. One is that we’re calling the +method without parentheses again. If it’s obvious what you’re doing, the +parentheses are optional. The other trick is the default parameter +`World`. What this is saying is “If the name isn’t supplied, use the +default name of `"World"`”. + +## Evolving Into a Greeter + +What if we want a real greeter around, one that remembers your name and +welcomes you and treats you always with respect. You might want to use +an object for that. Let’s create a “Greeter” class. + +{% highlight irb %} +irb(main):024:0> class Greeter +irb(main):025:1> def initialize(name = "World") +irb(main):026:2> @name = name +irb(main):027:2> end +irb(main):028:1> def say_hi +irb(main):029:2> puts "Hi #{@name}!" +irb(main):030:2> end +irb(main):031:1> def say_bye +irb(main):032:2> puts "Bye #{@name}, come back soon." +irb(main):033:2> end +irb(main):034:1> end +=> :say_bye +{% endhighlight %} + +The new keyword here is `class`. This defines a new class called Greeter +and a bunch of methods for that class. Also notice `@name`. This is an +instance variable, and is available to all the methods of the class. As +you can see it’s used by `say_hi` and `say_bye`. + +So how do we get this Greeter class set in motion? +[Create an object.](../3/) + diff --git a/fa/documentation/quickstart/3/index.md b/fa/documentation/quickstart/3/index.md new file mode 100644 index 0000000000..cebce10f0e --- /dev/null +++ b/fa/documentation/quickstart/3/index.md @@ -0,0 +1,230 @@ +--- +layout: page +title: "روبی در ۲۰ دقیقه" +lang: fa + +header: | +
+ ۱ + | + ۲ + | + ۳ + | + ۴ +
+

روبی در ۲۰ دقیقه

+ +--- + +Now let’s create a greeter object and use it: + +{% highlight irb %} +irb(main):035:0> greeter = Greeter.new("Pat") +=> # +irb(main):036:0> greeter.say_hi +Hi Pat! +=> nil +irb(main):037:0> greeter.say_bye +Bye Pat, come back soon. +=> nil +{% endhighlight %} + +Once the `greeter` object is created, it remembers that the name is Pat. Hmm, +what if we want to get at the name directly? + +{% highlight irb %} +irb(main):038:0> greeter.@name +SyntaxError: (irb):38: syntax error, unexpected tIVAR, expecting '(' +{% endhighlight %} + +Nope, can’t do it. + +## Under the Object’s Skin + +Instance variables are hidden away inside the object. They’re not +terribly hidden, you see them whenever you inspect the object, and there +are other ways of accessing them, but Ruby uses the good object-oriented +approach of keeping data sort-of hidden away. + +So what methods do exist for Greeter objects? + +{% highlight irb %} +irb(main):039:0> Greeter.instance_methods +=> [:say_hi, :say_bye, :instance_of?, :public_send, + :instance_variable_get, :instance_variable_set, + :instance_variable_defined?, :remove_instance_variable, + :private_methods, :kind_of?, :instance_variables, :tap, + :is_a?, :extend, :define_singleton_method, :to_enum, + :enum_for, :<=>, :===, :=~, :!~, :eql?, :respond_to?, + :freeze, :inspect, :display, :send, :object_id, :to_s, + :method, :public_method, :singleton_method, :nil?, :hash, + :class, :singleton_class, :clone, :dup, :itself, :taint, + :tainted?, :untaint, :untrust, :trust, :untrusted?, :methods, + :protected_methods, :frozen?, :public_methods, :singleton_methods, + :!, :==, :!=, :__send__, :equal?, :instance_eval, :instance_exec, :__id__] +{% endhighlight %} + +Whoa. That’s a lot of methods. We only defined two methods. What’s going +on here? Well this is **all** of the methods for Greeter objects, a +complete list, including ones defined by ancestor classes. If we want to +just list methods defined for Greeter we can tell it to not include +ancestors by passing it the parameter `false`, meaning we don’t want +methods defined by ancestors. + +{% highlight irb %} +irb(main):040:0> Greeter.instance_methods(false) +=> [:say_hi, :say_bye] +{% endhighlight %} + +Ah, that’s more like it. So let’s see which methods our greeter object +responds to: + +{% highlight irb %} +irb(main):041:0> greeter.respond_to?("name") +=> false +irb(main):042:0> greeter.respond_to?("say_hi") +=> true +irb(main):043:0> greeter.respond_to?("to_s") +=> true +{% endhighlight %} + +So, it knows `say_hi`, and `to_s` (meaning convert something to a +string, a method that’s defined by default for every object), but it +doesn’t know `name`. + +## Altering Classes—It’s Never Too Late + +But what if you want to be able to view or change the name? Ruby +provides an easy way of providing access to an object’s variables. + +{% highlight irb %} +irb(main):044:0> class Greeter +irb(main):045:1> attr_accessor :name +irb(main):046:1> end +=> nil +{% endhighlight %} + +In Ruby, you can open a class up again and modify it. The changes will +be present in any new objects you create and even available in existing +objects of that class. So, let’s create a new object and play with its +`@name` property. + +{% highlight irb %} +irb(main):047:0> greeter = Greeter.new("Andy") +=> # +irb(main):048:0> greeter.respond_to?("name") +=> true +irb(main):049:0> greeter.respond_to?("name=") +=> true +irb(main):050:0> greeter.say_hi +Hi Andy! +=> nil +irb(main):051:0> greeter.name="Betty" +=> "Betty" +irb(main):052:0> greeter +=> # +irb(main):053:0> greeter.name +=> "Betty" +irb(main):054:0> greeter.say_hi +Hi Betty! +=> nil +{% endhighlight %} + +Using `attr_accessor` defined two new methods for us, `name` to get the +value, and `name=` to set it. + +## Greeting Anything and Everything, MegaGreeter Neglects None! + +This greeter isn’t all that interesting though, it can only deal with +one person at a time. What if we had some kind of MegaGreeter that could +either greet the world, one person, or a whole list of people? + +Let’s write this one in a file instead of directly in the interactive +Ruby interpreter IRB. + +To quit IRB, type “quit”, “exit” or just hit Control-D. + +{% highlight ruby %} +#!/usr/bin/env ruby + +class MegaGreeter + attr_accessor :names + + # Create the object + def initialize(names = "World") + @names = names + end + + # Say hi to everybody + def say_hi + if @names.nil? + puts "..." + elsif @names.respond_to?("each") + # @names is a list of some kind, iterate! + @names.each do |name| + puts "Hello #{name}!" + end + else + puts "Hello #{@names}!" + end + end + + # Say bye to everybody + def say_bye + if @names.nil? + puts "..." + elsif @names.respond_to?("join") + # Join the list elements with commas + puts "Goodbye #{@names.join(", ")}. Come back soon!" + else + puts "Goodbye #{@names}. Come back soon!" + end + end +end + + +if __FILE__ == $0 + mg = MegaGreeter.new + mg.say_hi + mg.say_bye + + # Change name to be "Zeke" + mg.names = "Zeke" + mg.say_hi + mg.say_bye + + # Change the name to an array of names + mg.names = ["Albert", "Brenda", "Charles", + "Dave", "Engelbert"] + mg.say_hi + mg.say_bye + + # Change to nil + mg.names = nil + mg.say_hi + mg.say_bye +end +{% endhighlight %} + +Save this file as “ri20min.rb”, and run it as “ruby ri20min.rb”. The +output should be: + + Hello World! + Goodbye World. Come back soon! + Hello Zeke! + Goodbye Zeke. Come back soon! + Hello Albert! + Hello Brenda! + Hello Charles! + Hello Dave! + Hello Engelbert! + Goodbye Albert, Brenda, Charles, Dave, Engelbert. Come + back soon! + ... + ... +{: .code} + +There are a lot of new things thrown into this final example that we +[can take a deeper look at.](../4/) + diff --git a/fa/documentation/quickstart/4/index.md b/fa/documentation/quickstart/4/index.md new file mode 100644 index 0000000000..a40b976ee8 --- /dev/null +++ b/fa/documentation/quickstart/4/index.md @@ -0,0 +1,156 @@ +--- +layout: page +title: "روبی در ۲۰ دقیقه" +lang: fa + +header: | +
+ ۱ + | + ۲ + | + ۳ + | + ۴ +
+

روبی در ۲۰ دقیقه

+ +--- + +So, looking deeper at our new program, notice the initial lines, which +begin with a hash mark (#). In Ruby, anything on a line after a hash +mark is a comment and is ignored by the interpreter. The first line of +the file is a special case, and under a Unix-like operating system tells +the shell how to run the file. The rest of the comments are there just +for clarity. + +Our `say_hi` method has become a bit trickier: + +{% highlight ruby %} +# Say hi to everybody +def say_hi + if @names.nil? + puts "..." + elsif @names.respond_to?("each") + # @names is a list of some kind, iterate! + @names.each do |name| + puts "Hello #{name}!" + end + else + puts "Hello #{@names}!" + end +end +{% endhighlight %} + +It now looks at the `@names` instance variable to make decisions. If +it’s nil, it just prints out three dots. No point greeting nobody, +right? + +## Cycling and Looping—a.k.a. Iteration + +If the `@names` object responds to `each`, it is something that you can +iterate over, so iterate over it and greet each person in turn. Finally, +if `@names` is anything else, just let it get turned into a string +automatically and do the default greeting. + +Let’s look at that iterator in more depth: + +{% highlight ruby %} +@names.each do |name| + puts "Hello #{name}!" +end +{% endhighlight %} + +`each` is a method that accepts a block of code then runs that block of +code for every element in a list, and the bit between `do` and `end` is +just such a block. A block is like an anonymous function or `lambda`. +The variable between pipe characters is the parameter for this block. + +What happens here is that for every entry in a list, `name` is bound to +that list element, and then the expression `puts "Hello #{name}!"` is +run with that name. + +Most other programming languages handle going over a list using the +`for` loop, which in C looks something like: + +{% highlight c %} +for (i=0; i