This file contains 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
require 'logger' | |
module CoolLog | |
def logger | |
@cool_log_logger ||= ::Logger.new(STDOUT) | |
end | |
def level | |
@cool_log_level ||= :info | |
end |
This file contains 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
try | |
{ | |
// Algum código (provavelmente mais POG) | |
} | |
catch (Exception e) | |
{ | |
throw new Exception(e.Message); | |
} |
This file contains 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 SomeInstanceMethods | |
def self.included(base) | |
puts "Module #{self} has been included by #{base}." | |
end | |
def some_instance_method | |
puts "Some instance method..." | |
end | |
end |
This file contains 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 Numbers | |
def one | |
puts "1" | |
end | |
def two | |
puts "2" | |
end | |
end |
This file contains 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 CoolModule | |
def do_something | |
"I did it!" | |
end | |
end | |
class SomeClass | |
include CoolModule | |
end |
This file contains 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 FreteCorreios | |
def calcular | |
# Implementação do método | |
end | |
end | |
class FreteFedex | |
def calcular | |
# Implementação do método | |
end |
This file contains 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
def some_method | |
puts "Início do método" | |
my_proc = Proc.new do |message| | |
puts "Dentro do proc: #{message}" | |
return | |
end | |
my_proc.call "Ruby Fundamental" | |
puts "Fim do método" # Essa linha não é executada |
This file contains 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
my_proc = Proc.new { |x, y| x * y } |
This file contains 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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# listar_contatos.rb | |
raise ArgumentError, "=> Quantidade de argumentos incorreta. Exemplo de uso: ruby listar_contatos.rb root minhasenha" if ARGV.size != 2 | |
mysql_user, mysql_pass = ARGV | |
def criar_array(resultado) | |
resultado.split("\n").drop(1) | |
end |
This file contains 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
# encoding: utf-8 | |
# ramos_de_atividade.rb | |
nomes = File.readlines("ramos_de_atividade.txt") | |
File.open("ramos_de_atividade.yaml", "w") do |f| | |
nomes.each_with_index do |nome, i| | |
f.puts "ramo_de_atividade_#{i+1}" | |
f.puts " id: #{i+1}" | |
f.puts " nome: #{nome}\n" |