1. Technology

Articles related to to_s

The Board Class - Ruby - About.com
def to_s cell_size = @board.flatten.max.to_s.length + 2 str = StringIO.new str.puts "Score: #{@score}" str.puts format_border(cell_size) (0...@size).each do|row| ...
Data Visualization - Ruby - About.com
We're going to hijack (or, more accurately, implement) the Node#to_s method. It should iterate over the tree, starting at itself (so if we want the whole tree, we call  ...
Getting and Printing Strings - Ruby - About.com
Aug 17, 2011 ... If the object you pass to puts is not a string, the puts method will attempt to call to_s on that object. For example, if I were to pass a number to ...
Method for Mapping the Values of an Array - Ruby - About.com
So, if we have an array of numbers but we want strings, we can do something like this. [ 1, 2, 3, 4 ].map(&:to_s) # This will produce the array [ "1", "2", "3", "4" ].
Symbols - Ruby - About.com
To test for a symbol without creating it, you could convert all the symbols to strings (using :some_symbol.to_s and test for the identifying strings. There is no real ...
Simple Programming under Linux - About.com
print "You entered " + a.length.to_s + " entries.\n\n" for i in 0...a.length do print " Entry " + (i+1).to_s + ": "+ a[i] + "\n" end. I save my ruby script to file "myprogram".
Using the Input / Output Methods in Ruby - About.com
For objects of all other types, puts will first call the object's to_s method which attempts to convert the object to a string, then prints the result of to_s followed by a ...
Block Parameters and Yielding - Ruby - About.com
... implicit Proc object ret = yield puts %Q{The block yielded "#{ret.to_s}"} end yield_and_print{ 10 } yield_and_print{ "Hello" } yield_and_print do (10 + 20) / 3 end ...
Cryptographic Hashes in Ruby - About.com
Whenever you want the hash, you can read it from the hexdigest method or simply from its to_s method. #!/usr/bin/env ruby # Computes the SHA1 hash of any ...
Part 3: Implementing - Ruby - About.com
def to_param if self.desc.nil? b36_id else "#{b36_id}/#{self.desc}" end end def b36_id self.id.to_i.to_s(36) end end. The first line is the attr_accessible line that ...
1  |  2  |  3      Next

©2014 About.com. All rights reserved.