This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Refactor following code using singleton pattern and explain your answer | |
require 'singleton' | |
class Logger | |
include Singleton | |
LOG_FILE_NAME = 'dev.log' | |
def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This module helps converting to string every object that includes it | |
module Stringfier | |
attr_reader :app | |
def to_str | |
"Your app http status is: -> #{@app[0]}<-, " + \ | |
"with headers: ->#{@app[1]}<-, " + \ | |
"and body: ->#{@app[2]}<-" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_app = lambda do |env| | |
[200, | |
{'Content-Type' => 'text/html', | |
'Content-Length' => '3'}, ['Yes']] | |
end | |
describe test_app, 'RackApp' do | |
it { should respond_to(:call) } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
BUNDLE_DISABLE_SHARED_GEMS: "1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RubyLearning | |
module Module | |
WRAPPER_PREFIX = 'wrapper_' | |
WRAPPED_PREFIX = 'wrapped_' | |
def before(method, prev_option = {}) | |
prev_option.merge!(:before => normalize_method_name(method)) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
end | |
puts "--" + A.instance_methods(false).join(', ') | |
class A | |
def otro | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.swp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
headers = nil | |
rows = [] | |
File.open(ARGV[0] || 'data.csv', 'r') do |file| | |
headers = file.gets.split(',') | |
while(line = file.gets) do | |
cols = line.split(',') | |
rows << cols | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Saludador | |
def initialize(*user) | |
@user = user[0] | |
raise "An user has to be provided" unless @user | |
end | |
def saluda | |
"Hola amigo" | |
end |
OlderNewer