How to break out from a ruby block?

Use the keyword next. If you do not want to continue to the next item, use break. When next is used within a block, it causes the block to exit immediately, returning control to the iterator method, which may then begin a new iteration by invoking the block again: When used in a block, break … Read more

How to understand strptime vs. strftime

The difference between Time and DateTime has to do with implementation. A large amount of the DateTime functionality comes from the Rails world and is an arbitrary date with time of day. It’s more of a calendar-based system. Time is measured as seconds since January 1, 1970 UTC and is time-zone agnostic. On some systems it is limited to values between 1901 and … Read more

What is java interface equivalent in Ruby?

Ruby has Interfaces just like any other language. Note that you have to be careful not to conflate the concept of the Interface, which is an abstract specification of the responsibilities, guarantees and protocols of a unit with the concept of the interface which is a keyword in the Java, C# and VB.NET programming languages. In Ruby, we use the … Read more

Uploading a file in Rails

Update 2018 While everything written below still holds true, Rails 5.2 now includes active_storage, which allows stuff like uploading directly to S3 (or other cloud storage services), image transformations, etc. You should check out the rails guide and decide for yourself what fits your needs. While there are plenty of gems that solve file uploading pretty nicely (see https://www.ruby-toolbox.com/categories/rails_file_uploads for … Read more

Getting error: dyld: Symbol not found: _clock_gettime

I was getting the same dyld: Symbol not found: _clock_gettime error message during an attempted install of ruby 2.3.1 on El Capitan. The advice here to run xcode-select –install and allow the xcode command line tools to reinstall solved that issue for me. If you’re using that version of OS X perhaps it may help you as well?

Ruby 2.0.0p0 IRB warning: “DL is deprecated, please use Fiddle”

The message you received is common when you have ruby 2.0.0p0 (2013-02-24) on top of Windows. The message “DL is deprecated, please use Fiddle” is not an error; it’s only a warning. The source is the Deprecation notice for DL introduced some time ago in dl.rb ( see revisions/37910 ). On Windows the lib/ruby/site_ruby/2.0.0/readline.rb file … Read more