Quantcast
Channel: Notes posted to Ruby
Browsing latest articles
Browse All 107 View Live

Why module_function creates a private method, when including the module?...

What’s the intention for doing that?

View Article


more loops (Kernel#loop)

fruits = [‘apple’,‘orange”]fruits.each do |fruit|puts"A fruit of type: #{fruit}"end

View Article


Step-By-Step Guide to Building Your First Ruby Gem (Kernel#loop)

Nowadays all the functionalities in Rails are built as Ruby gems. For example we can use devise gem for the authentication part of the application. It’s like a package or library that is written in...

View Article

How to Add Functionality to Ruby Classes with Decorators (Kernel#loop)

Decorators allow us to add behavior to objects in runtime and don’t affect other objects of the class. Decorators can be applied when you need to dynamically add and remove responsibility to a class....

View Article

Volt Framework for Ruby (Module#alias_method)

Volt – a new Framework for Ruby where both the server and client sides are written in Ruby via OPAL (a ruby to JavaScript compiler) so developer can write dynamic applications without writing a single...

View Article


Scheduling Recurring Events with Ice Cube Gem (Module#alias_method)

Ice_cube is a ruby library for effectively taking care of repeated events (schedules). The force lies in the ability to indicate multiple rules, and have ice_cube rapidly make sense of whether the...

View Article

How to use Acts_As_Votable Gem (Module#alias_method)

Acts_As_Votable is ruby gem specifically written for Rails/ActiveRecord models and This gem allows any model to be voted on upvote/downvote like/dislike, etc. It allows any model to be voted under...

View Article

Examples corrected (Module#alias_method)

I have documented this method clearly with corrections to the examples shown in this page on my blog: http://www.rubyplus.net/2016/11/aliasmethod-in-ruby.html

View Article


Ruby Developers (Module#alias_method)

How to create a RubyGemRuby Gems or “gem” is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries. It is easy to manage and...

View Article


Code Refactoring Gem – Flay (Module#alias_method)

Flay examines code for structural likenesses. Differences in literal values, variable, class, method names, whitespace, programming style, braces vs do/end, props versus do/end, and so forth are all...

View Article

Rails caching with dalli gem (Module#alias_method)

Dalli is a high performance pure Ruby client for accessing memcached servers. It works with memcached 1.4+ only, as it uses the newer binary protocol.Memcache Memcached is a quick in-memory protest...

View Article

Clarifying the confusing example (Module#alias_method)

since exit is a keyword in Ruby, the example may be confusing. The following example might be less so:module Foobegin# this raises an error b/c baz is not defined...

View Article

Sort Integers (Array#sort!)

ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]Sort From Greatest to Smallest>>[1,2,3,4].sort{|a,z|z<=>a}=>[4,3,2,1]

View Article


nope (Net::FTP#gettextfile)

If you pass nil as local file, it doesn’t write the file and only returns the content as string.

View Article

And yet another way to get relative path from absolute globbing (Dir#glob)

If you execute glob within a block passed to Dir.chdir, you get the paths relative to the directory specified by Dir.chdir… like...

View Article


Faker Gem: Fake Data Generation in Ruby (Dir#glob)

Gems are libraries in Rails that generally enable you to write the application code faster and thereby making a great product in far lesser time. Usually, whenever we start developing any application,...

View Article

Urlify Functions & Its Implementation (Dir#glob)

URLify is a simple gem that refines the conversion of UTF-8 strings to ASCII-safe URI strings and enables it to be used as readable URL-segments. After the gem is installed, you can call the URLify...

View Article


define_method with blocks works differently (Module#define_method)

As it is already stated that block is evaluated using instance_exec/instance_eval, so let me give you an example.module Servicemodule ClassMethodsdef...

View Article

OUTDATED!!! (Time#strftime)

Man, this stuff is so outdated. Be very careful using anything from here. A lot has changed since Ruby 1.9.You’ll want to look at the updated docs, like here for Ruby...

View Article

Make your custom enumerable "flattenable" (Array#flatten)

Just alias to_a to to_aryclass AincludeEnumerabledef eachyield"a"yield"b"endend[A.new,A.new].flatten=>[#<A:0x00007fbddf1b5d88>, #<A:0x00007fbddf1b5d60>]class Adef...

View Article
Browsing latest articles
Browse All 107 View Live


Latest Images