You want Ruby? We can do it! Hire us for Ruby on Rails, CoffeeScript, BackBone.js, MongoDb, _underscore.js,dojo,Extjs,jQuery,Node.js,LAMP, AJAX info {at} rubyassist {dot} com
Thursday, November 29, 2007
Calculating Time difference in Ruby
now = DateTime.new
date = Date.new
p now.strftime("%Y-%m-%d %I:%M:%S").to_s
p Time.now.strftime("%Y-%m-%d %I:%M:%S").to_s
dif = DateTime.parse(Time.now.strftime("%Y-%m-%d %I:%M:%S").to_s)-DateTime.parse("2007-9-12 14:07:00")
hours, mins, secs, ignore_fractions = Date::day_fraction_to_time(dif)
p hours * 60 * 60 + mins * 60 + secs
Tuesday, November 20, 2007
Pdf-writer -- Images in simple table
attr_accessor :data
# An array of Hash entries. Each row is a Hash where the keys are the
# names of the columns as specified in #column_order and the values are
# the values of the cell.
The following is the code change in simpletable.rb file is required to use images in respected cells.
line : 647
if(line.match("::Image"))
pic = line.gsub("::Image","")
line = pdf.add_image_from_file(pic,pos[name], pdf.y-5, @image_width)
line =""
else
line = pdf.add_text_wrap(pos[name], pdf.y,
max_width[name], line,
@font_size, just)
end
Note: Make sure that text should have "::Image" and remaing text is the path of the image .
like
data[i]["Q1Image"] ="::Image"+Dir.getwd+"/public/images/status_#{p.status_q1_image}.jpg"
For more information please post your comments.
Friday, November 09, 2007
Tuesday, May 01, 2007
Ruby and Related Links
(Zed on Ruby, Rails, Mongrel, and More)
Rails:
http://www-128.ibm.com/developerworks/java/library/j-cb08016/
Rails Deployment:
http://blog.duncandavidson.com/2005/12/deploying_rails.html
http://www.infoq.com/news/2006/12/deploy-rails-on-iis
Rails Migrations:
http://glu.ttono.us/articles/2005/10/27/the-joy-of-migrations
http://garrettsnider.backpackit.com/pub/367902
Scriptaculous Rails:
http://script.aculo.us/
http://www.juixe.com/techknow/index.php/2006/08/12/scriptaculous-rails/
Rest:
http://www.b-simple.de/documents
Second Life:
http://secondthoughts.typepad.com/second_thoughts/2006/06/getting_started.html
http://nwn.blogs.com/
Design Patterns:
http://www.dofactory.com/Patterns/Patterns.aspx
Agile SD:
http://www.adaptivesd.com/articles/cross_oct02.pdf
Sunday, January 14, 2007
Arjun Singh and the Love Goddess!
So what does the Love Goddess have to do with Arjun Singh and with reservations? As the Indian government, at the behest of Arjun Singh, rolled out yet another short sighted policy to deal with the horrible caste system, we found out about some other activities of Arjun Singh.
Thursday, December 28, 2006
ExampleDesignPatternsInRuby (Ruby)
Almost all of these examples are correct Ruby programs. If example output is shown, you should be able to copy code from the web page, run it in a Ruby interpreter and get the documented output.
Patterns
- AbstractFactoryPattern
- AbstractSessionPattern
- AdaptorPattern
- BouncerPattern
- ChainOfResponsibilityPattern
- CommandPattern
- CompositePattern
- DecoratorPattern
- DelegatorPattern
- FactoryMethodPattern
- FlyweightPattern
- IteratorPattern
- NullObjectPattern
- ObserverPattern
- ProductTraderPattern
- ProxyPattern
- RepositoryPattern
- SingletonPattern
- StatePattern
- StrategyPattern
- TemplateMethodPattern
- VisitorPattern
Design Patterns in Ruby : Observer
- Require the observer library
- Mixin the Observable module to your class which can be observed
- In the class that does the observing, implement the update method
That’s it.
Of course, an example would be nice. Here’s a small one.
require 'observer' # Key step 1
class MyObservableClass
include Observable # Key step 2
def blah
changed # note that our state has changed
notify_observers( 5 )
end
end
class MyObserverClass
def update(new_data) # Key step 3
puts "The new data is #{new_data}"
end
end
watcher = MyObservableClass.new
watcher.add_observer(MyObserverClass.new)
Now, any time that MyObservableClass#blah is called, the observing classes will get notified. In this example, we aren’t dynamically changing the data (in fact, it always stays constant), but I think you can see that if in fact the data DID change, the observers would all get notified of that change.