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
ruby-3.0.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
class SiByteCount | |
def initialize(n) | |
@n = n | |
end | |
def to_s | |
n = signif(@n, 3) | |
UNITS.each do |coef, abbrev| | |
if n >= coef |
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 TimeRange | |
def initialize(start_hour, stop_hour) | |
@start_hour = start_hour | |
@stop_hour = stop_hour | |
end | |
def complete? | |
@start_hour && @stop_hour | |
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
1 | |
"increment" | |
2 | |
"increment" | |
3 | |
"increment" |
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
# Exmaple using method_missing to expose dynamic attributes. | |
class Foo | |
def initialize | |
@attrs = {:a => 1, :b => 2} | |
end | |
def method_missing(method, *args, &block) | |
if @attrs.has_key?(method.to_sym) | |
send(:[], method, *args) |
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
require "forwardable" | |
# How to wrap an array | |
class Foo | |
extend Forwardable | |
def_delegator :@a, :each | |
include Enumerable |
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
# frozen_string_literal: true | |
module PercyDbMigrate | |
module PrereqPolicy | |
# A prereq policy that migrates both selected classes and | |
# prerequesites. | |
class All | |
# Return the migration classes to run. |
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
# Avoid linking an active user to franchises for which the user | |
# is inactive. | |
# | |
# * If the source user is inactive in all franchises, the user | |
# should be linked to all of the franchises in which it was | |
# present. | |
# | |
# * If the source user is active in all franchises, the | |
# destination user should be linked to all of the franchises | |
# in which it was present. |
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
Feature: Home Page | |
As a user | |
I want a home page | |
So that I won't be homeless | |
Scenario: Shows the home page after logging in | |
Given that I am logged in as an ordinary user | |
Then I should be on the home page | |
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 CpuSim::Cpu | |
class Angle | |
def self.zero | |
new(0) | |
end | |
def self.radians(v) | |
new(v) |
NewerOlder