Uncategorized

Ruby, Testing

Posted on June 1, 2008. Filed under: Uncategorized |

In Ruby -> Test::unit::TestCase is easy
require ‘test/unit’
 
the name of the class to be tested is Roman then the testing class will TestRoman < Test::Unit::TestCase
and a simple method
def test_simple
assert_equal (“expected_result”, call_to the method of class to be checked –>actual result)
end
for testing a particular method….
ruby test_roman.rb –name “name of the method”
location of the test file should
$:.unshift File.join(File.dirname(__FILE__),”..”,”lib”)
require….the [...]

Read Full Post | Make a Comment ( None so far )

Ruby – Numeric

Posted on June 1, 2008. Filed under: Uncategorized |

Numeric
Integer Float
FixNum BigNum Rational ComplexNum
nan?
zero?/nonzero?
finite?/infinite?,integer?
ceil,floor,round,
divmod,quo,remainder
next,succ,step(10,2),times,chr,

Read Full Post | Make a Comment ( None so far )

ruby rake

Posted on April 21, 2008. Filed under: Uncategorized |

ruby is make like utility.Make utility makes a install with all the options and config you want .Rake is similar to Make
within a rails application go to that directory ask the rake to tell about itself
rake -T
rake rails:freeze:gems
rake doc:rails : will install the rdoc for the rails –> the activerecord#find etc…in the html format in [...]

Read Full Post | Make a Comment ( None so far )

Ruby : Math

Posted on April 21, 2008. Filed under: Uncategorized |

Math is a module which has a lot of useful Methods.
To convert from one class to another just call the class name followed by parameter.
Integer(field)
Float(field)
String(field)
All other method are applied on the object itself like 3.div 3 or 12.divmod 5 which divides and gives the balance. or you can remainder to get the remainder alone.
you [...]

Read Full Post | Make a Comment ( None so far )

rails basics

Posted on April 21, 2008. Filed under: Uncategorized |

render(:controller=>’say’ ,:action=>’hello’)
render(:partial => ‘form’)
redirect(:controller=>’say’ :action=>’hello’)
link_to(‘mylink’,:controller= >’say’,:action=>’hello’,:id=>1)
params.inspect
logger.warn,logger.error,logger.info,logger.fatal
(ActionView only) debug(params)
( FormHelpers only)
<input type =’text’ name=album[title]/> can be written as
<%= form_tag(:action=>’create’) do %>
<%= text_field(:album, :title) %>
<%= datetime_select(:album, :release_date) %>
<%= submit_tag(“name of button”) %>
<%= end %>
form_tag
form
 
error_messages_for(:album) —> debug(album.errors)
validates_presence_of :artist
before_filter(controller) :method nly/:except =>[]
after_filter(controller) :method nly
Model inherits from ActiveRecord::Base which has methods like find,find_by_id,find_by_sql,save,update,destroy
Controller is inherited [...]

Read Full Post | Make a Comment ( None so far )

ruby gems

Posted on April 20, 2008. Filed under: Uncategorized |

http://docs.rubygems.org/read/book/2
gem -v : would give the version
gem list –local : list of all gems in the system with thier version number.if there was 2 version then it would give them in descending order
gem outdated : would give list of gems which are outdate
gem update : would update all the gems.
gem update –include-dependencies –no-rdoc
 
gem cleanup : [...]

Read Full Post | Make a Comment ( None so far )

$0 , __FILE__

Posted on March 18, 2008. Filed under: Uncategorized |

$0 is the file which load any other ruby file which is contained in __FILE__….

Read Full Post | Make a Comment ( None so far )

Splat Operator in Ruby

Posted on March 18, 2008. Filed under: Uncategorized |

* is called the splat operator in ruby .The first time you come across is for variable argument.that is exactly what you will be using it for.it should be used as the last argument.
name,*rest_of_address = address[]
would put the first argument to name and rest to the * argument…
THe other thing about it is it gives [...]

Read Full Post | Make a Comment ( None so far )

Structures in Ruby

Posted on March 18, 2008. Filed under: Uncategorized |

If you wanted just a storage variable in terms of big structure with no code on them .The best way is to call Struct.new followed by what ever structure fields you want on them.Once the structure is created you can create a new on it by just calling the name of the Structure .new [...]

Read Full Post | Make a Comment ( None so far )

Ruby – Date/Time

Posted on March 13, 2008. Filed under: Uncategorized |

Time.now : will give the time now…
%a – The abbreviated weekday name (“Sun”)
%A – The full weekday name (“Sunday”)
%b – The abbreviated month name (“Jan”)
%B – The full month name (“January”)
%c – The preferred local date and time representation
%d – Day of the month (01..31)
%H – Hour of the day, 24-hour clock (00..23)
%I – [...]

Read Full Post | Make a Comment ( None so far )

« Previous Entries
  •  

    November 2009
    M T W T F S S
    « Jun    
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • My Fav

Liked it here?
Why not try sites on the blogroll...