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 something | |
return false | |
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
puts "Kupuje" if cena < 50 |
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 'test/unit' | |
def foo(x) | |
if x.kind_of?(Fixnum) | |
x = x * -1 | |
else | |
x = x.to_i | |
x = x * 1 | |
x = x.to_f | |
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 Sort | |
attr_reader :my_array | |
def initialize(my_array) | |
@my_array = my_array | |
end | |
def switch_array(element, element2) | |
@my_array[element], @my_array[element2] = @my_array[element2], @my_array[element] | |
end | |
def quicksort(p, r) | |
if p < r then |
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 NumberService | |
def number | |
12 | |
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
describe NumberService do | |
describe '#number' do | |
it 'returns 12' do | |
expect(NumberService.new.number).to eq(12) | |
end | |
it 'does not return 10' do | |
expect(NumberService.new.number).not_to eq(10) | |
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
class Server | |
attr_reader :env, :domain | |
end | |
class Config | |
def server | |
@server ||= Server.new | |
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
config = Config.new | |
config.server.env = 'production' | |
config.server.domain = 'domain.com' |
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 Server | |
attr_accessor :env, :domain | |
end | |
class Config | |
def initialize(&block) | |
instance_eval &block | |
end | |
def server |
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 Describe | |
attr_reader :context_name | |
def initialize(context_name, &block) | |
@context_name = context_name | |
instance_eval &block | |
end | |
end |
OlderNewer