Ruby

TwitterFacebook
Get flash to fully experience Pearltrees
You should look for the indicator lines (description, quality, text and stats) in a loop and fill the hash while processing the document line by line. Another option would be to use regular expressions and parse the document at once, but you don't really need regular expressions here, and if you're not familiar with them, I'd have to recommend against regexes. sections = [] File . open ( "deneme" ) do | f | current = {: description => "" , : text => "" , : quality => "" , : stats => "" } inDescription = false inQuality = false

Parsing a structured text file in Ruby

http://efreedom.com/Question/1-1942604/Parsing-Structured-Text-File-Ruby
http://www.ruby-forum.com/topic/103371

Parsing an text file

Hi, I cannot find a way to easily parse a text file. I am just starting to learn ruby so please bear with me. My text file looks like this: 0 8 2 9 3 0 0 4 9 2 8 3 9 3 0 2 2 3 4 9 8 8 9 0 Basically just numbers and spaces. So far, I know how to read the file and put each line into an array. def readfile(file) arr = IO.readlines(file) parsing(arr) end def parsing(arr) string1 = arr[0].to_s string2 = arr[1].to_s string3 = arr[2].to_s ans.each_byte {|b|p b.chr} end What I wanted to do is, for example, want to find all 8's and change it to 5's.
http://www.ibm.com/developerworks/aix/library/au-aix-manage-ruby/index.html?ca=drs-

Speaking UNIX, Part 14: Manage Ruby and gems with RVM

Although Internet Relay Chat, forums, and revision control tools such as Git and Github make distributed development a snap, reproducing another developer's environment can be quite maddening. Propping up an existing body of code on a new development machine requires matching with at least some and potentially all of the original coder's stack, or many prerequisite software components that power the application. A stack may demand a type of operating system (say, UNIX®, Linux®, Mac OS, or Windows®); a specific operating system version (Ubuntu 10 or 11? Mac OS X 10.6 Snow Leopard or 10.7 Lion?); a minimum collection of built-in and supplemental system libraries and header files; a supporting cast of daemons and services (MySQL or PostgreSQL?); and, of course, any number of language-specific resources, from the compiler to a specific patch level of supporting open source code.

Ruby for systems administrators

http://www.ibm.com/developerworks/aix/library/au-rubysysadmin/index.html?cmp=dw&cpb=dwaix&ct=dwgra&cr=twitter&ccy=zz&csr=doit81rubu4admins Introduction Ruby is a highly feature-rich, free, simple, extensible, portable, and object-oriented scripting language. It has gained immense popularity of late on the worldwide Web. This popularity can at least partly be attributed to the very powerful Web application development framework, Rails, which is written in Ruby.

Ruboto: Ruby on Android

http://www.ibm.com/developerworks/web/library/wa-ruby/index.html?cmp=dw&cpb=dwwdv&ct=dwgra&cr=twitter&ccy=zz&crs=ruboto4android Introduction Most of the interesting work in software development today occurs at one of the two extremes: huge cloud servers and tiny mobile devices. These domains solve significantly different problems, and, correspondingly, have different tool support. Server development often uses scripting languages to tie together different components and accomplish sophisticated automated tasks, while mobile development focuses on the particular capabilities and needs of a particular device and user. However, these two extremes share a common language: Java™. Whether Android or the Spring framework, many of the most popular technologies today have adopted a language that's widely understood and supported around the world.
Ruby alternatives for parsing CSV files Ruby String#split (slow) Ruby CSV (slow) FasterCSV (ok, recommended) ccsv (fast & recommended if you have control over CSV format) CSVScan (fast & recommended if you have control over CSV format) Excelsior (fast & recommended if you have control over CSV format) CSV library benchmarks can be found here and here Parsing with plain Ruby http://snippets.aktagon.com/snippets/246-How-to-parse-CSV-data-with-Ruby

How to parse CSV data with Ruby - Ruby - csv, parse, ruby, fastercsv, ccsv, csvscan, excelsior

Programmation Ruby/Types standards

Un livre de Wikibooks. << Retour au sommaire Nous allons voir ici tous les types que nous pouvons considérer comme "standards", dans le sens où nous les retrouvons dans la plupart des langages, et que ceux-ci sont directement intégrés à l'interpréteur ( built-in ). Néanmoins il ne faut pas perdre de vue qu'il s'agit en réalité d'objets. Pour rappel les méthodes dont le nom se termine par ! sont non pures : elles modifient l'objet. http://fr.wikibooks.org/wiki/Programmation_Ruby/Types_standards#split
http://www.zenspider.com/Languages/Ruby/QuickRef.html

Ruby QuickRef

Table of Contents Language General Tips

Getting Started with Nokogiri | Engine Yard Ruby on Rails Blog

https://blog.engineyard.com/2010/getting-started-with-nokogiri We’re decided to mix up the Engine Yard blog a little and invite some community members to contribute guest posts. This one (our first!) is from Aaron Patterson — a long-time member of the Ruby community, and the creator of Nokogiri. He hacks with the developers of Seattle.rb, and travels the world to speak about Nokogiri and other Ruby topics at industry conferences and events. Nokogiri is a library for dealing with XML and HTML documents. I wrote Nokogiri along with my (more attractive) partner in crime, Mike Dalessio .
Ruby on Rails is a new kid in the block into the world of Web application development that is rapidly gaining interest, even though it is in beta versions. These days, I am trying to get my hands dirty with Ruby on Rails using various tutorial posts and also some books. Over the coming days, i will try to share my learnings with you through the blog. Below, in this post, I am putting up a list of Top 5 Tutorials to get you started on Ruby on Rails (RoR). These are infact tutorials, i am going through in order to learn RoR. Ruby on Rails Tutorial for Newbies : This tutorial is a basic tutorial targeting the newbies in RoR arena.

Top 5 Tutorials on Ruby on Rails

http://www.technofriends.in/2007/10/26/top-5-tutorials-on-ruby-on-rails/
Ruby is a simple programming language that is designed to be easy to read and to behave in a predictable manner. Chef uses Ruby as its reference language for creating cookbooks and defining recipes, with an extended DSL (domain-specific language) that is used for specific resources. Chef provides a reasonable set of resources, enough to support many of the most common infrastructure automation scenarios; however, this DSL can also be extended when additional resources and capabilities are required. Chef uses a domain-specific language in Ruby to define recipes and to store settings, such as those which define a role or an environment. These settings are saved as Ruby files and are stored in the Chef repository.

Just Enough Ruby for Chef - Chef - Opscode Open Source Wiki

Ruby in Twenty Minutes

Introduction This is a small Ruby tutorial that should take no more than 20 minutes to complete. It makes the assumption that you already have Ruby installed.