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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'gosu' | |
def linear_map(value, mina, maxa, minb, maxb) | |
(maxb - minb) * (value - mina) / (maxa - mina) + minb | |
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
def foo | |
13 | |
end | |
2.times do | |
p foo | |
foo = 'something else' | |
p foo | |
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
describe '#reload' do | |
# Attributes | |
let(:id) { 25 } | |
let(:name) { 'Pikachu' } | |
let(:new_name) { 'Pika' } | |
let(:pokemon) { Pokemon.find(id) } | |
it 'returns an object with the original attributes' do | |
pokemon.name = new_name |
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 Foo | |
def initialize | |
singleton_class.class_eval { def foo; :bar; end } | |
singleton_class.class_eval do | |
alias_method :f_o_o, :foo | |
end if respond_to? :foo | |
end | |
end |
OlderNewer