blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 4 137 | path stringlengths 2 355 | src_encoding stringclasses 31
values | length_bytes int64 11 3.9M | score float64 2.52 5.47 | int_score int64 3 5 | detected_licenses listlengths 0 49 | license_type stringclasses 2
values | text stringlengths 11 3.93M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
3532911a83388e1d58dff97355b8983e7686ea2f | Ruby | tardjo/acme.test | /app/services/partner_service.rb | UTF-8 | 1,290 | 2.609375 | 3 | [] | no_license | class PartnerService
def get_all(params)
Partner.get_all(params)
end
def create_partner(params)
if params[:partner].present? && params[:partner][:name].present?
partner = Partner.new(name: params[:partner][:name])
if partner.save
{notice: 'Create partner successfully'}
else
... | true |
bd9865f77c7f7beddf5ac9a3cb4c86c952393648 | Ruby | amjad5/tic-tac-toe-rb-bootcamp-prep-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,826 | 4.09375 | 4 | [] | no_license | WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,3,6],
[1,4,7],
[2,5,8],
[0,4,8],
[6,4,2]
]
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{b... | true |
b6acd8c2f2265ab8818aae3ad435527333caf1f4 | Ruby | ClementMagniez/L3S5 | /lib/grille/CaseGazon.rb | UTF-8 | 419 | 3.171875 | 3 | [] | no_license | require_relative 'CaseVide'
# Classe implémentant CaseVide : représente une case engazonnée, valide
# tant qu'elle n'affiche pas une tente
class CaseGazon < CaseVide
# Appelle CaseVide#initialize avec :GAZON
# - i,j : coordonnées de la case
def initialize(i,j)
super(:GAZON,i,j)
end
# Return false si le statut ... | true |
373746e72c3cd154f2054291938b9fe2804318e7 | Ruby | armel50/ruby-collaborating-objects-lab-online-web-pt-081219 | /lib/artist.rb | UTF-8 | 536 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
@songs = []
end
def self.all
@@all
end
def songs
@songs
end
def add_song(song_object)
song_object.artist = self
end
def self.find_or_create_by_name(artist_name)... | true |
0f443ac2b2ae6ce8efb32b5bbf007caafdbf0f7b | Ruby | classpert/latinizer | /lib/lib/han.rb | UTF-8 | 408 | 3.0625 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | class Han
require 'chinese_pinyin'
def self.t(text, opt = nil)
latin = []
chars = text.split("")
chars.each_with_index do |char, index|
if char =~ /\p{Han}/
converted_char = Pinyin.t(char, opt == :ascii ? {} : {tonemarks: true})
latin << ' '
latin << converted_char
e... | true |
37e76e395a00e88de73c14d414934bf98a9d1a58 | Ruby | jbcool17/jbadmin | /CLI/lib/jbadmin/host_controller.rb | UTF-8 | 2,283 | 2.65625 | 3 | [
"MIT"
] | permissive | module Jbadmin
class HostController
class << self
def initialize_computers_storage
data_dir = "#{Jbadmin.main_dir}/.jbadmin"
if !Dir.exists? data_dir
Dir.mkdir data_dir
puts "Directory created..."
end
if !File.exists? Jbadmin.hosts
... | true |
76b4a2aa35a5ecd8fc00702f5a13c4befa71d810 | Ruby | cadyherron/assignment_oop_warmups_1 | /rockpaperscissors.rb | UTF-8 | 1,353 | 4.125 | 4 | [] | no_license | class RockPaperScissors
OPTIONS = ["rock", "paper", "scissors"]
def play_game
start
type = game_type
if type == 'c'
player_input
computer_input
match(@player, @computer)
else
player1 = player_input
player2 = player_input
match(player1, player2)
end
end
def start
puts "Welcome to... | true |
f2d4be4ff7d4b49901a5d3ef61908c6f6199c4f5 | Ruby | amorphid/blackjack_procedural | /spec/dealer_turn_spec.rb | UTF-8 | 544 | 2.875 | 3 | [] | no_license | require "blackjack"
describe "The Dealer" do
it "should hit on 10" do
dealer_score = 10
expect( dealer_hit?(dealer_score) ).to eq(true)
end
it "should hit on a soft 17" do
dealer_score = [17, "soft"]
expect( dealer_hit?(dealer_score) ).to eq(true)
end
it "should NOT hit on hard 17" do
... | true |
bba76ee7fdb442fa59f40d4cc4fdc98a621e599b | Ruby | isoworg/boris-bikes | /spec/docking_station_spec.rb | UTF-8 | 938 | 2.921875 | 3 | [] | no_license | require 'DockingStation'
describe DockingStation do
let(:working_bike) { double :bike, working?: true }
let(:broken_bike) { double :bike, working?: false }
let(:station) { DockingStation.new }
it "can release a bike" do
expect(subject).to respond_to(:release)
end
it "releases a docked bike" do... | true |
96ff88d025b14eda4ce5fc6454025eb5e636654d | Ruby | buren/site_health | /lib/site_health/issues_report.rb | UTF-8 | 906 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'csv'
require 'json'
require 'site_health/issue'
module SiteHealth
class IssuesReport
def initialize(issues)
@issues = issues
@fields = Issue.fields
@select_block = proc { true }
yield(self) if block_given?
end
def fields=(fields)
@fie... | true |
0545f64c3c6a8a24f8a44810670e9f96d6859222 | Ruby | amerdwar/hsg2 | /ru.rb | UTF-8 | 168 | 2.5625 | 3 | [
"MIT"
] | permissive |
re = /^.* s=(\d+\.\d+).*t=(\d+\.\d+)/
co=0;
ARGF.each_line do |line|
if re.match(line)
printf "%s %s \n",$1,$2 ;
co=co+1
end
end
printf " this is the count %d" ,co;
| true |
4139ef49fe6f2c424263c7dfaea8c1bec97b0b3e | Ruby | sapphyrus/PwnAdventure3Proxy | /src/proxy.rb | UTF-8 | 7,209 | 2.53125 | 3 | [] | no_license | class Proxy
attr_accessor :client
attr_accessor :server
def recv_loop
fds = [@client, @server]
return if fds.any?{|fd| fd.closed?}
closed = false
if ios = IO.select(fds, [], [], 10)
ios.first.each do |io|
is_client = io == client
other = is_client ? server : client
begin
# call hooks
... | true |
a2525d0fe01e5e6d50dd0b14d017d99f3c8628b2 | Ruby | danhoward/C2 | /lib/subscriber_list.rb | UTF-8 | 986 | 2.734375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | class SubscriberList
attr_reader :proposal
def initialize(proposal)
@proposal = proposal
end
# Returns triplets of (user, role name, observation)
def triples
requesters, approvers, observers = partitioned_roles
requesters = requesters.map { |role| [role.user, "Requester", nil] }
approvers = ... | true |
42f1f36c24d0d4a698f52b1a8b2ac2b7699c51b7 | Ruby | m00p1ng/kattis-problem | /LV1/1.4/parking2/parking2.rb | UTF-8 | 111 | 2.984375 | 3 | [] | no_license | n = gets.to_i
n.times do
_ = gets.to_i
park = gets.split.map(&:to_i)
puts 2 * (park.max - park.min)
end
| true |
e56b17b5bdc4a1a037f122d6e4b0ef1779ca35b7 | Ruby | Graciexia/Codewars_algorithm_practice- | /Float Precision.rb | UTF-8 | 393 | 3.421875 | 3 | [] | no_license | require_relative 'lib/test_frame'
def solution(number)
return sprintf("%.2f", number).to_f
end
Test.assert_equals(solution(23.23456), 23.23)
Test.assert_equals(solution(1.546), 1.55)
# Update the solution method to round the argument value to the closest precision of two. The argument will always be a float.
#
#... | true |
b825e2cc75b1e3299536ca4a3e9f7ef4f1ff3c23 | Ruby | garciajordy/tic_tac_toe | /spec/main_spec.rb | UTF-8 | 2,230 | 3.453125 | 3 | [] | no_license | require './lib/board'
require './lib/user'
describe Board do
describe '#verify' do
it 'returns true if the cells in the top horizontal line are the same' do
board = Board.new
board.update(1, 'X')
board.update(2, 'X')
board.update(3, 'X')
expect(board.verify).to eql(true)
end
... | true |
6bf5b353151a53db886bfe06fab3493515f197d7 | Ruby | MASisserson/rb101 | /lesson_3/medium_2/4.rb | UTF-8 | 448 | 4.21875 | 4 | [] | no_license | # Question 4
def tricky_method_two(a_string_param, an_array_param)
a_string_param << 'rutabaga'
an_array_param = ['pumpkins', 'rutabaga']
end
my_string = "pumpkins"
my_array = ["pumpkins"]
tricky_method_two(my_string, my_array)
puts "My string looks like this now: #{my_string}"
puts "My array looks like this now... | true |
9bfb6756db1f222cc15450363b1398d8f663fd96 | Ruby | cmhumphries7/BakeSale | /order_runner.rb | UTF-8 | 163 | 2.65625 | 3 | [] | no_license | require_relative 'order'
customer_name = "Chris"
recipe_name = "Sugar Cookies"
quantity = 24
order1 = Order.new customer_name, recipe_name, quantity
puts order1 | true |
430d0ade9de7bf492af232ef79784eb4ec763fb9 | Ruby | mr-infinity-xy/ruby | /problem1.rb | UTF-8 | 337 | 3.34375 | 3 | [] | no_license | def problem(n, k)
step = k
while k*step < n
step*= k
puts step
end
return step
end
array = []
puts "Enter number of contestants"
contestants = gets.chomp.to_i
puts "Enter interval of selection"
remove_interval = gets.chomp.to_i
(1..contestants).each { |n| array << n }
p problem(contestants, r... | true |
1ea1e869c9a4fcc6bc7bef562e8e7c9163d097d7 | Ruby | Dchyk/launch_school_101 | /101_109_sm_problems/repeat_yourself.rb | UTF-8 | 387 | 4.71875 | 5 | [] | no_license | # Easy 1 - Repeat Yourself
# Write a method that takes two arguments, a string and a positive integer,
# and prints the string as many times as the integer indicates.
# input:
# - a string
# - a positive integer
#
# output:
# - at least one string
#
def repeat(string, integer)
integer.times do
puts string
... | true |
138bb6e523f01da13e7d7c55e9bd204a814f08d7 | Ruby | coding-chimp/code_poetry | /lib/code_poetry/churn_calculator.rb | UTF-8 | 623 | 3.109375 | 3 | [
"MIT"
] | permissive | class ChurnCalculator
def initialize(path)
@repo_path = find_directory(path)
end
def calculate
parse_log_for_churns
end
private
def find_directory(path)
if File.file?(path)
File.dirname(path)
else
path
end
end
def parse_log_for_churns
churns = {}
logs.each do... | true |
17a3afe01210a1daa30a686919515dcce23125cc | Ruby | huffman442/Projects | /VowelCount/spec/VowelCount_Spec.rb | UTF-8 | 1,083 | 3.203125 | 3 | [
"MIT"
] | permissive | require "VowelCount"
describe VowelCount do
describe ".count" do
context "given 'hello'" do
it "returns 2" do
vc = VowelCount.new
expect(vc.count("hello")).to eql({"e" => 1, "o" => 1})
end
end
context "given 'ee'" do
... | true |
a060ae5e53082d82a27de10f813d9794fa44a2c3 | Ruby | johnjheejin/john.j.heejin.study | /Ruby/Day2/def_dollarExchange.rb | UTF-8 | 516 | 3.921875 | 4 | [] | no_license | require 'eu_central_bank' #다른 환율 gem도 많지만, 제일 굳건해 보이는 이름.
def dollarExchange(to)
# 은행 객체생성
bank = EuCentralBank.new
bank.update_rates
# 은행 객체에 환율정보를 업뎃해줘
return bank.exchange(100, 'USD', to)
# 100 cent = 1 dollar 를 from에서 to로
# return 없어도 됨 ㄷㄷ; 당연히 마지막이 리턴이겟거니
end
# def 정의한수이름(인자)
# 내용내용
# (return)반환값
# end
... | true |
0ce1e876a07fef83a2a41cc2093822613b08806d | Ruby | mandarenee/language_wiki | /db/seeds.rb | UTF-8 | 3,561 | 2.65625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
cd4bf590b78f4d527eb9b08a3823b6f0764aaad0 | Ruby | UMDBPP/COSMOS | /lib/xor_checksum_protocol_raw.rb | UTF-8 | 1,811 | 3.03125 | 3 | [] | no_license | # encoding: ascii-8bit
require 'cosmos'
require 'cosmos/interfaces/protocols/protocol'
require 'cosmos/packets/binary_accessor'
module Cosmos
# Protocol which fills the checksum field of a CCSDS packet with an
# 8 bit, XOR CRC
class XorChecksumProtocolRaw < Protocol
# @param checksum_byte_offset [Integer] T... | true |
aabe0ee28dcd75fc6564c35c32acd1fe18c61bbd | Ruby | Ido-Efrati/bytemap | /app/models/location.rb | UTF-8 | 1,566 | 2.75 | 3 | [] | no_license | class Location < ActiveRecord::Base
has_many :offerings, dependent: :destroy
has_many :subscriptions
#get a locaion id if the location already exists in the location table. Otherwise, creates the location
#@param - given a location object that may not been already saved
#return the location id
def self.get_or_c... | true |
1c0703e5e7cfe5d441cff28ecf68302833a3cc8b | Ruby | SSBinks/betsy | /test/models/category_test.rb | UTF-8 | 1,076 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class CategoryTest < ActiveSupport::TestCase
test "Category can't have an empty name" do
category = Category.new
assert_not category.valid?
assert_not category.save
assert_includes category.errors, :name
end
test "Category is valid if it has a name" do
categories.each d... | true |
796cd980c00965fb8b902db2b8638568840500ec | Ruby | lokialice/LearnRuby | /IFELSE.rb | UTF-8 | 646 | 4.03125 | 4 | [] | no_license | x=1
if x > 2
puts "x is greater than 2"
elsif x <= 2 and x!=0
puts "x is 1"
else
puts "I can't guess the number"
end
#Ruby if modifier
$debug=1
print "debug\n" if $debug
#Ruby unless statement
y=1
unless x > 2
puts "x is less than 2"
else
puts "x is greater than 2"
end
#Ruby unless modifier
$var = 1
prin... | true |
6bca635775c6f6654a9fd04741056553d189110c | Ruby | cc-giraud/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 1,089 | 2.578125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
fa41795dd7d015c7ba0136495c948ca12face228 | Ruby | erikasland/RubyProblems | /nth_prime.rb | UTF-8 | 537 | 4.5625 | 5 | [] | no_license | require "prime"
def find_prime(nth)
Prime.take(nth).last
# NOTE TO SELF: .take(nth) prints all prime numbers within the Prime class (list of prime numbers) and .last returns the last prime number of the returned list.
end
puts('nth_prime(1) == 2: ' + (nth_prime(1) == 2).to_s)
puts('nth_pri... | true |
56bbdf577bf815c68a97543bf3c0d984c6e44313 | Ruby | dgrawunder/fm | /app/cli/interactions/delete_entity_interaction.rb | UTF-8 | 1,050 | 2.78125 | 3 | [
"MIT"
] | permissive | module FmCli
class DeleteEntityInteraction < FmCli::EntityInteraction
def run(id, entity_identifier)
entity_name = entity_name(entity_identifier)
printable_entity_name = printable_entity_name(entity_identifier)
begin
entity = find_entity_use_case_class(entity_name).new(id).run
... | true |
2ecfad82947d154f6a1d32aeb3ef31290466f970 | Ruby | jeremylightsmith/facilitationpatterns | /spec/extensions/array_spec.rb | UTF-8 | 351 | 2.59375 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper'
describe Array do
describe "to_hash" do
it "should convert itself to a hash" do
[[1,2],[3,4]].to_hash.should == {1 => 2, 3 => 4}
end
it "should allow sub arrays" do
[[1,[2,3,4]], [[5], [6, [7,8]]]].to_hash.should == {1 => [2,3,4], [5] =>... | true |
0dfcda40a6b8e965bf79b5f7f49fea9a69fbbc18 | Ruby | codeprimate/video-library | /lib/tpb.rb | UTF-8 | 3,654 | 2.578125 | 3 | [] | no_license | module Tpb
require 'rubygems'
require 'scrapi'
require 'open-uri'
require 'uri'
TPB_URL = "http://thepiratebay.org"
class Search
def initialize(search_string=nil)
@cached_html = {}
search(search_string) if search_string
end
def search(search_string)
search_url = TPB_... | true |
4f96a26fe5e5f5e6f0b63027c652910776d6fc3e | Ruby | longboardcat/appload | /lib/appload/runner.rb | UTF-8 | 2,365 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'awesome_print'
require 'colored'
require 'pliney'
require 'yaml'
module Appload
class Runner
attr_accessor :options
def self.start
new.run
end
def run
puts "Appload #{Appload::VERSION}"
@options = Appload::Options.new.options
Pliney::IPA.from_path(options[:ipa_path... | true |
d9873e55daa826d953a626985590e25a3c8cbcb1 | Ruby | lizvdk/learn-to-program | /ch8_arrays_and_iterators/toc_revisited.rb | UTF-8 | 258 | 3.078125 | 3 | [] | no_license | #toc revisited
title = "Table of Contents"
info = [["Chapter 1: Getting Started", "page 1"],
["Chapter 2: Numbers", "page 9", ],
["Chapter 3: Letters", "page 13"]]
puts title.center(50)
info.each do |ch, pg|
puts ch.ljust(30) + pg.rjust(20)
end
| true |
cda33d81659e6347f2f988d1720023e0caf3fbc2 | Ruby | dylanmckay/rails-euchre | /app/services/create_game_state.rb | UTF-8 | 864 | 3.0625 | 3 | [
"MIT"
] | permissive | class CreateGameState
def initialize(game_model)
@game_model = game_model
end
def call
create_initial_state
apply_operations
@game_state
end
private
def create_initial_state
@player_states = make_player_states(@game_model.players)
dealer_state = find_player_from_model(@game_model... | true |
cfa07c52cd37c227c309c96709461ccc3fa9c0a2 | Ruby | orange-cloudfoundry/helm-kubectl-boshrelease | /src/action/vendor/gems/bcrypt-3.1.13/spec/bcrypt/engine_spec.rb | UTF-8 | 11,210 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain",
"Apache-2.0"
] | permissive | require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
describe "The BCrypt engine" do
specify "should calculate the optimal cost factor to fit in a specific time" do
first = BCrypt::Engine.calibrate(100)
second = BCrypt::Engine.calibrate(400)
expect(second).to be > first
end
... | true |
30d56160a95ef72755d2d9995718917dbb6fd612 | Ruby | bfolder/orange_web | /controllers/user_controller.rb | UTF-8 | 5,954 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative '../models/user'
# User controlling & routing
module UserController
def self.included(app)
## Routes ##
app.get '/user/signin' do
redirect '/' if logged_in?
erb :signin
end
app.get '/user/logout' do
session[:user] = nil
session[:flash] = "You have logged out ... | true |
51204e190b4e88cacd7cbdccfb0a7bc074183a29 | Ruby | CynthiaLiu0805/Scala-Ruby-Clojure-Prolog | /h10/h10.rb | UTF-8 | 1,017 | 3.328125 | 3 | [] | no_license | Pair = Struct.new(:fst,:snd)
def summingPairs(xs, sum)
the_pairs1 = []
the_pairs2 = []
the_pairs = []
len = xs.length
reader, writer = IO.pipe
fork do
for i in 0..(len-1)
for j in (i+1)..(len/2)
if xs[i] + xs[j] <= sum
writer.puts(Pair.new(xs[i],xs[j]))
end
... | true |
b922c2e8af5263ed9887910646335bdb17bf2eab | Ruby | nathantross/labs_wk1d1 | /reverse_string.rb | UTF-8 | 271 | 3.625 | 4 | [] | no_license | puts "Enter a string to reverse: "
string_to_rev = gets.chomp
# try dual assignment a, b = b, a
i = 0
while i < string_to_rev.length/2
temp = string_to_rev[-1*(i+1)]
string_to_rev[-1*(i+1)] = string_to_rev[i]
string_to_rev[i] = temp
i += 1
end
puts string_to_rev
| true |
ec14a5ad6707f73b23c2e03996aede1ee259a21a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/26f7b1460ced4d6cb0688ad5bba2cbda.rb | UTF-8 | 263 | 3.328125 | 3 | [] | no_license | #!/usr/bin/env ruby
# Exercism 3
# RNA Transcription
# This program computes the RNA complete to a DNA nucleotide strand
class Complement
def self.of_dna(seq)
seq.tr('CGTA', 'GCAU')
end
def self.of_rna(seq)
seq.tr('GCAU', 'CGTA')
end
end
| true |
52d27fce65887fac8bfcfa4f9cf8bc84c3ed76df | Ruby | shadowfox3735/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 443 | 3.90625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(array)
array.collect{|x| badge_maker(x)}
end
def assign_rooms(attendees)
attendees.each_with_index.map do |name, index|
"Hello, #{name}! You'll be assigned to room #{index+1}!"
end
end
def printer(attendees... | true |
19f9189029a1ca71fd67c629ee73e33777f059ab | Ruby | puppetlabs-toy-chest/lock_manager | /lib/lock_manager/connection.rb | UTF-8 | 630 | 2.6875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class LockManager
class Connection
attr_reader :options
def self.connection_class(type)
case type.to_s
when 'redis'
require 'lock_manager/redis_connection'
LockManager::RedisConnection
else
raise ArgumentError, "Unknown connection type: #{type}"
end
end
... | true |
40fc6b011d95a24d72a0dc33b4182d5137a9dc58 | Ruby | supermomonga/fizzbuzz | /ruby/basic.rb | UTF-8 | 131 | 3.25 | 3 | [] | no_license | (1..100).each do |n|
puts case 0
when n % 15 then :FizzBuzz
when n % 3 then :Fizz
when n % 5 then :Buzz
else n
end
end
| true |
4f2b532ed55dfb34f20b02b97f9399748b07d70b | Ruby | gigosa/udonarium | /src/src_bcdice/diceBot/Gorilla.rb | UTF-8 | 1,291 | 2.921875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
class Gorilla < DiceBot
setPrefixes(['G.*'])
def initialize
#$isDebug = true
super()
end
def gameName
'ゴリラTRPG'
end
def gameType
"Gorilla"
end
def getHelpMessage
return <<MESSAGETEXT
2D6ロール時のゴリティカル自動判定を行います。
G = 2D6のショートカット
例) G>=7 : 2D6して7以上なら成功
MES... | true |
7f1619ca4c14b78b2e4e852cb12e9379596afe67 | Ruby | fskinner/rails-sample | /spec/models/rent_spec.rb | UTF-8 | 2,973 | 2.53125 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
require 'spec_helper'
describe Rent do
subject { FactoryGirl.create :rent }
it { should validate_presence_of :initial_value }
describe '#accept_rent' do
context 'given a rent' do
it 'should create a date' do
subject.accept_rent
subject.date.should_not be_n... | true |
66305e92285f3e8df0fc78d56fbbe4d12005fc49 | Ruby | IamGlowingThresher/redmine_igabot | /bad_vote.rb | UTF-8 | 411 | 2.96875 | 3 | [] | no_license | require 'time'
STUB_DAYS_BEING_BAD = 22
class BadVote
def time_correct?(j)
true unless ((Time.now - Time.strptime(j['created_on'], '%Y-%m-%d')).to_i / (60 * 60 * 24)) > STUB_DAYS_BEING_BAD
end
def initialize(j)
j['details'].each do |d|
if d['name'] == 'vote' && d['new_value'] == '0' && time_corre... | true |
05ac479672f4a51923ca0abd710b28f6a740b67c | Ruby | hopesgit/Whether-Sweater | /app/services/weather_service.rb | UTF-8 | 508 | 2.5625 | 3 | [] | no_license | class WeatherService
def self.fetch_weather_for_location(lat, long)
response = conn.get('/data/2.5/onecall') do |request|
request.params[:lat] = lat
request.params[:lon] = long
request.params[:exclude] = "minutely,alerts"
request.params[:units] = "imperial"
end
JSON.parse(response... | true |
6a35477a5233cd84f7b5d1ec53e89c1e09c1e7b2 | Ruby | shostakovich/Codingkatas | /spec/poterKata_spec.rb | UTF-8 | 875 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Basket" do
it "price is 0 if its empty" do
basket = Basket.new
basket.get_price.should eql(0.00)
end
it "should add a book" do
basket = Basket.new
book = Book.new 1
basket.add book
end
it "should apply discount ... | true |
90673029d16508788473e2f08ae711eecb375e9d | Ruby | UpAndAtThem/object_oriented_programming_examples | /basics_inheritance/only_pass_year.rb | UTF-8 | 453 | 3.828125 | 4 | [] | no_license | # Using the following code, allow Truck to accept a second argument upon instantiation.
# Name the parameter bed_type and implement the modification so that Car
# continues to only accept one argument.
class Vehicle
attr_reader :year
def initialize(year)
@year = year
end
end
class Truck < Vehicle
attr_... | true |
77b8e2ee86c35b8ba02f598bbac56fca9a6850e6 | Ruby | alxx/SSD1306-ruby | /lib/SSD1306/cursor.rb | UTF-8 | 878 | 3.234375 | 3 | [
"MIT"
] | permissive | module SSD1306
class Cursor
attr_accessor :size, :x_pos, :y_pos
def initialize
@size = 1
@x_pos = 0
@y_pos = 0
end
def reset
reset_pos
reset_size
end
def reset_pos
@x_pos = 0
@y_pos = 0
end
def reset_size
@size = 1
end
def in... | true |
25408789eb6335c6b05082653dfe86378c778803 | Ruby | farisca/stud-servis | /app/controllers/application_controller.rb | UTF-8 | 2,364 | 2.65625 | 3 | [] | no_license | class AuthToken
def self.encode(payload, exp=24.hours.from_now)
payload[:exp] = exp.to_i
JWT.encode(payload, Rails.application.secrets.secret_key_base)
end
def self.decode(token)
payload = JWT.decode(token, Rails.application.secrets.secret_key_base)[0]
DecodedAuthToken.new(payload)
rescue
nil # It... | true |
b6ae6a322e767a43674c51cfd054d9a8093368c2 | Ruby | olofenglund96/advent-of-code | /2018/6_2.rb | UTF-8 | 528 | 3.3125 | 3 | [] | no_license | arr = File.open('inputs/6').to_a
$coords = []
max_y = 0
max_x = 0
arr.each do |a|
os = {}
coords_temp = a.delete!(' ').split(",")
os['x'] = coords_temp[0].to_i
os['y'] = coords_temp[1].to_i
if os['x'] > max_x
max_x = os['x']
end
if os['y'] > max_y
max_y = os['y']
end
$coords.push(os)
end
po... | true |
5d64de2f71bba22d8efe886c79ccee57fd8323bc | Ruby | amatsukixgithub/atcoder | /ABC/ABC132/132B.rb | UTF-8 | 189 | 2.953125 | 3 | [] | no_license | N=gets.chomp.to_i
P=gets.chomp.split.map(&:to_i)
c=0
(N-2).times do |i|
if ((P[i] < P[i+1]) && (P[i+1]< P[i+2])) || ((P[i] > P[i+1]) && (P[i+1]> P[i+2])) then
c+=1
end
end
puts c
| true |
71b0b7b1df8a16c379965db071e3a88db06f508e | Ruby | bendyorke/checklist | /bin/check | UTF-8 | 2,588 | 3.03125 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'optparse'
require_relative '../lib/list.rb'
require_relative '../lib/task.rb'
module Check
COLORS = {
due: "%{$fg[yellow]%}",
overdue: "%{$fg[red]%}",
none: "%{$reset_color%}"
}
def list
puts file
puts List.new(file).data.sort_by { |task| task.time }
end
de... | true |
5f3c61d0dc7b6343fc6afc9814b4ac57962d3eb7 | Ruby | horiuchi67/ruby_lessons | /4/4-9-2.rb | UTF-8 | 78 | 3 | 3 | [] | no_license | a = []
10.upto(14) {|n| a << n }
a
a = []
14.downto(10) { |n| a << n}
a | true |
e228c87c48628aa36e85d7095f2e9bdd1e33708d | Ruby | T-LG/projet_thp4 | /lib/01_temperature.rb | UTF-8 | 68 | 2.921875 | 3 | [] | no_license | def ftoc(temp)
(temp-32)*5/9.0
end
def ctof(num)
num*9/5.0+32
end | true |
81af98b4fc35b2f7c23de68f837b327e983cad36 | Ruby | Sabyasachig/ruby_hotel_booking | /user.rb | UTF-8 | 184 | 2.828125 | 3 | [] | no_license | class User
attr_accessor :email, :first_name, :last_name
def initialize(email, first_name, last_name)
@email, @first_name, @last_name = email, first_name, last_name
end
end
| true |
ef74662ffeb9dd5fbbcee7d2a07b96938b3452c9 | Ruby | buty4649/atcoder | /abc298/b/main.rb | UTF-8 | 374 | 3.125 | 3 | [] | no_license | # frozen_string_literal: true
n = gets.to_i
a = n.times.map { gets.split.map(&:to_i) }
b = n.times.map { gets.split.map(&:to_i) }
def check(n, a, b)
n.times do |i|
n.times do |j|
return false if a[i][j] == 1 && b[i][j] != 1
end
end
true
end
4.times do
if check(n, a, b)
puts 'Yes'
exit
... | true |
126a45fb36a589e275cc6127f2717a38ad5d26cd | Ruby | indykiss/ranking_scraper | /lib/scraper/cli.rb | UTF-8 | 1,028 | 3.65625 | 4 | [
"MIT"
] | permissive | class ScraperModule::CLI
def call
welcome
print_books
answer
end
def welcome
puts "Welcome to book scraper!"
puts "We have the following books..."
end
def print_books
ScraperModule::Scraper.scraping_page
ScraperModule::Book.all.each_with_index do |book, i|
puts "... | true |
027d8ee7fc7ae7fe0d3fbd28ecfdebfb122a8b76 | Ruby | difasel/QuintaSemanaMiercoles | /DestripandoTwitter.rb | UTF-8 | 2,258 | 2.984375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class TwitterScrapper
def initialize(url)
@url = url
@doc = Nokogiri::HTML(File.open(@url))
end
def extract_username
profile_name = @doc.search('.ProfileHeaderCard-name > a')
name = profile_name.first.inner_text
"Username: #{name}"
end
def extract_... | true |
769269b335f7fa8ff731901534626ca675f5a979 | Ruby | j8th/TicTacToe | /spec/ai_spec.rb | UTF-8 | 5,419 | 3.390625 | 3 | [] | no_license |
require 'players/ai'
require 'board'
require 'rules'
require 'game'
require 'mocks/mockui'
require 'ui/console'
describe AI do
# describe '#get_random_move' do
# it 'Should return a random integer between 0 and 8.' do
# ai = AI.new('Bender')
# board = Board.new
# seen_numbers = []
# f... | true |
6ac109ea3e6fdc446df36e52dcd60e611991dd85 | Ruby | collins-williams/lexer | /legacy_test/unitTest7.rb | UTF-8 | 642 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby -w
# this is a test that overlapping rules can be resolved by priorities
#
require "./lexerDriver.rb"
ld = LexerDriver.new()
result = ld.add_rules_from_file("./test7_rule_file")
#this is a test of having rules that contain character classes and escaped chars
parse = true
state = 0
err_string = "success... | true |
cbec8a15fa47598796d858e1731e518a488afb05 | Ruby | Lwyrup/ToyProblems | /013-pokemon.rb | UTF-8 | 2,946 | 2.703125 | 3 | [] | no_license | # n- f- w- e- g-
# n- 1 1 1 1 1
# f- 1 .5 .5 1 2
# w-
# e-
# g-
types = ["normal","fire","water","electric","grass","ice","fighting","poison","ground","flying","psychic",
"bug","rock","ghost","dragon","dark","steel","fairy"]
dmg_chart = {
"normal"=>{"normal"=>1},
"fire"=>{
"normal"=>1 , "fire"=>0.5, ... | true |
de43306dfa93c21921eb28ad8b72d4fa7e1148f8 | Ruby | cordis-dev/cf-rubocop-performance-test | /times_map.rb | UTF-8 | 32 | 2.546875 | 3 | [] | no_license | 9.times.map do |i|
i.to_s
end
| true |
b8144edc906627e2a097957380afa044896415bd | Ruby | Ruxton/DirtyMUD | /lib/dirtymud/room.rb | UTF-8 | 1,941 | 3.0625 | 3 | [] | no_license | module Dirtymud
class Room
attr_accessor :id, :description, :players, :exits, :server, :items
def initialize(attrs)
@players = []
@exits = {}
@items = []
attrs.each do |k, v|
self.send("#{k}=", v)
end
end
def enter(player)
player.room = self
player... | true |
2c003617efe18e5c7129478b78a289a5e3b11fce | Ruby | abargnesi/brute | /bin/brute | UTF-8 | 222 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'brute'
cmd = Brute::Command.new
result = cmd.run_command
while result[:exit_code].zero?
cmd.mutate
result = cmd.run_command
end
puts "Exited #{result[:exit_code]}"
puts result[:output]
| true |
afd7b7d06848c65ad758c2633154ece6e0ef88ba | Ruby | demir-delic/BCW-labs | /arrays-lab-1/tests.spec | UTF-8 | 3,676 | 3.09375 | 3 | [] | no_license | test.tests = ()=> {
describe('Test Data', ()=> {
it('Exists', () => {
assert.isDefined(test.data);
});
it('Is An Array', () => {
assert.isArray(test.data);
});
it('Contains 10 Contacts', () => {
assert.isTrue(test.data.length === 10);
... | true |
bca2b3da229522c8608146f85bb694fd6b06682c | Ruby | jlsrvr/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 1,060 | 3.109375 | 3 | [] | no_license | require 'open-uri'
require 'json'
class GamesController < ApplicationController
def new
counter = 0
@letters = []
alphabet = ('A'..'Z').to_a
until counter >= 10
@letters << alphabet.sample(1)
counter += 1
end
@letters
end
def score
grid = params[:letters].split(//)
@a... | true |
75307dc4e3eff4bef5d0a17866609adc42733da2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/fd843b67cf154295a8c479dc1daa1260.rb | UTF-8 | 289 | 3.1875 | 3 | [] | no_license | class Raindrops
def self.prime_to_sound
{3 => "Pling",
5 => "Plang",
7 => "Plong"}
end
def self.convert number
sound = ""
prime_to_sound.each_pair do |prime, s|
sound << s if number % prime == 0
end
sound.empty? ? number.to_s : sound
end
end
| true |
94d8ceb2bf7faede9bb5065787cebef246ec1f66 | Ruby | ignacy/s1-e2 | /lib/commits_state.rb | UTF-8 | 1,110 | 2.859375 | 3 | [] | no_license | class CommitsState
attr_accessor :state, :user
# commits
BEGINNER = 1
JOURNEYMAN = 20
MASTER_COMMITER = 50
def initialize(user)
@user = user
end
def next
return if @user.badges[:commits].include? "MASTER_COMMITER"
if beginner?
@user.badges[:commits] << "BEGINNER"
ret... | true |
1f346b4d08a8b1f25022ee61328186c872db71f7 | Ruby | RadiusNetworks/radius-spec | /benchmarks/cover_vs_include.rb | UTF-8 | 3,019 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Run from the command line: bundle exec ruby benchmarks/cover_vs_include.rb
require_relative 'bm_setup'
display_benchmark_header
INT_RANGE = (0..15).freeze
INT_VAR = 10
section "Integer ranges" do |bench|
bench.report('range#cover?') do
INT_RANGE.cover?(INT_VAR)
end
bench.r... | true |
886360ff2403ddae95af6a8b5fb0090cee3aa13f | Ruby | Laurencarne/OO-Auto-Shop-london-web-career-042219 | /app/models/car_owner.rb | UTF-8 | 539 | 3.3125 | 3 | [] | no_license | class CarOwner
@@all = []
attr_reader :name
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def owners_car
# Get a list of all cars said owner has
Car.all.select{|car_info| car_info.owner == self}
end
def owners_mechanic
# Get a list of mechanic... | true |
2b4da5ab24e59c2a3c48d10eb3a3ad1ed786bc2c | Ruby | seomoz/plines | /lib/plines/job.rb | UTF-8 | 1,131 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'forwardable'
require 'plines/indifferent_hash'
module Plines
NotAHashError = Class.new(TypeError)
# An instance of a Step: a step class paired with some data for the job.
Job = Struct.new(:klass, :data) do
extend Forwardable
attr_reader :dependencies, :dependents
def_delegators :klass, :qle... | true |
e0beed9f4fd2bbcfd9c621d0af4e37e6cb0a3c81 | Ruby | kitlangton/pairity | /lib/pairity/cli.rb | UTF-8 | 8,331 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'highline/import'
require 'terminal-table'
require 'rainbow'
require 'yaml'
module Pairity
class CLI
def initialize
@matrix = AdjacencyMatrix.new
@sync = GoogleSync.new(@matrix)
@generator = PairGenerator.new(@matrix)
@renderer = PairRenderer.new(@matrix)
load_google
end... | true |
8fc0848179170f1664f7ccc705f28fc4fd07702b | Ruby | mattopps/phase-0 | /week5/calculate-mode/my_mode_solution.rb | UTF-8 | 5,242 | 4.0625 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge with Kaybi DiAngelo.
# I spent [1] hour pairing on this challenge. Then some more time later refactoring even more.
# 0. Pseudocode
# What is the input? - Input an array of numbers or strings.
# What is the output? (i.e. What should the code retur... | true |
8a0876bc37e84ddb2300ea96ee9a4fbfc4d4c009 | Ruby | ksheurs/algorithms | /exercises/sentence_reverse.rb | UTF-8 | 693 | 4.28125 | 4 | [] | no_license | # Reverse the words in a given sentence.
class SentenceReverse
attr_reader :sentence
def initialize(sentence)
@sentence = sentence
end
def reverse
words = []
i = 0
start = 0
while i < sentence.length
if sentence[i] == " "
words << se... | true |
bc1b4181caa9a3e767fb91deabb0d6c86b0d2c0a | Ruby | andrewalisa/advent-of-code-2019 | /day13.rb | UTF-8 | 1,596 | 3.4375 | 3 | [] | no_license | require_relative 'utils/utils'
require 'pry-nav'
require 'io/console'
require 'set'
TILES = {
0 => :empty,
1 => :wall,
2 => :block,
3 => :paddle,
4 => :ball,
}
VIZ = {
empty: ' ',
wall: 'X',
block: 'B',
paddle: 'P',
ball: 'O',
}
puts "Part 1"
class ScreenWriter
def initialize
@buffer = []
... | true |
a8cd5e646d54d86fc79d63a06150bad7dfb59d1e | Ruby | mahsaNajafzadeh/RUDRA | /src/main/java/xpr/testEscrow.rb | UTF-8 | 877 | 2.875 | 3 | [] | no_license | class Account < ApplicationRecord
belongs_to :user
validates_numericality_of :balance , greater_than_or_equal_to: a
def self.withdraw(account, amount)
puts "Withdrawing #{amount} on account #{account.id}"
return false unless self.amount_valid?(amount)
acquire_escrow(account, balance, a, GE)
... | true |
5b8b411dc55d853a25cbe221ba87f7b4e36cecc7 | Ruby | louis-delon/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 609 | 3.40625 | 3 | [] | no_license | class GamesController < ApplicationController
def new
@letters = []
10.times do
@letters << ("A".."Z").to_a.sample
end
# The new action will be used to display a new random grid and a form. The form will be submitted (with POST) to the score action.
end
def score
raise
@word = param... | true |
db9489a4705107da662cbde187515ab3f4c54413 | Ruby | mels065/learn_ruby | /06_timer/timer.rb | UTF-8 | 197 | 3.046875 | 3 | [] | no_license | class Timer
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
"%02d:%02d:%02d" % [
@seconds / 3600,
@seconds / 60 % 60,
@seconds % 60
]
end
end
| true |
46b548934bd491f6cdb7fa1465843068fd9fa385 | Ruby | 99Anastasia99/Currency | /lib/staging_mail_interceptor.rb | UTF-8 | 639 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
class StagingMailInterceptor
ALLOWED_DOMAINS = ENV["ALLOWED_DOMAINS"].split.freeze
MAIL_DOMAIN_REGEXP = /^.*@(.*)$/
class << self
def delivering_email(message)
unless deliver?(message)
message.perform_deliveries = false
Rails.logger.debug "Interceptor prev... | true |
a551286dfd79cc3cb73ff018edf2d1de7ea5a452 | Ruby | phsoares-ita/leetcode | /solutions/575_distribute_candies/spec/solution_spec.rb | UTF-8 | 547 | 3.03125 | 3 | [] | no_license | require 'spec_helper'
require 'byebug'
# @param {Integer[]} candy_type
# @return {Integer}
def distribute_candies(candy_type)
unique_candy_types = candy_type.each_with_index.to_h.keys
[unique_candy_types.length, candy_type.length / 2].min
end
describe 'solution' do
it { expect(distribute_candies([1,2])).to eq 1... | true |
59fded9cf27d6d3a7fdbe0180eb7e0937ffe1a1e | Ruby | jbgo/introvert | /test/test.rb | UTF-8 | 260 | 2.8125 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), 'test_helper')
class TraceTest
def sos(a,b)
a*a + b*b
end
class Inner
def huh(c,d)
c + d - (d - c)
end
end
end
Introvert.trace do
c = TraceTest.new
c.sos(3,4)
d = TraceTest::Inner.new
d.huh(5,6)
end
| true |
f1e30a8c9c27ed7bb3d3abf9981aec0068c70284 | Ruby | pyromaniac/mongoid_orderable | /lib/mongoid/orderable/generator/movable.rb | UTF-8 | 1,950 | 2.609375 | 3 | [
"MIT"
] | permissive | module Mongoid
module Orderable
module Generator
module Movable
def generate_movable_helpers(column_name)
generate_move_to_helpers(column_name)
generate_insert_at_helpers(column_name)
generate_shorthand_helpers(column_name)
end
protected
def g... | true |
72eda9462eae12d51fd1920b2181bb83ca87638b | Ruby | hashimoto-atsunori/MyAppRails | /vendor/bundle/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/style/if_unless_modifier.rb | UTF-8 | 2,819 | 2.578125 | 3 | [
"CC-BY-NC-4.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# Checks for if and unless statements that would fit on one line
# if written as a modifier if/unless. The maximum line length is
# configured in the `Metrics/LineLength` cop. The tab size is configured
# in the `Indenta... | true |
697e4c6cd57040348d44742d586a74589b8d12c3 | Ruby | chyld/io | /app/models/book.rb | UTF-8 | 511 | 2.53125 | 3 | [] | no_license | class Book < ActiveRecord::Base
attr_accessible :name
has_and_belongs_to_many :tags
def self.persist(data = {})
return nil if !data.is_a?(Hash)
id = Scrub.str(data[:id], '', squish:true)
name = Scrub.str(data[:name], 'book', minify:true)
tag_ids = data[:tag_ids].is_a?(Array) ? data[:tag_ids] : [... | true |
38577dc7f911f44f8b5c439d9c8e4f22a86fe374 | Ruby | drewwilliams5280/backend_module_0_capstone | /day_4/exercises/ex3.rb | UTF-8 | 1,637 | 4.625 | 5 | [] | no_license | def add(a, b)
puts "ADDING #{a} + #{b}"
return a + b
end
def subtract(a, b)
puts "SUBTRACTING #{a} - #{b}"
return a - b
end
def multiply(a, b)
puts "MULTIPLYING #{a} * #{b}"
return a * b
end
def divide(a, b)
puts "DIVIDING #{a} / #{b}"
return a / b
end
puts "Let's do some math with just functions!"... | true |
afc9b88a7bddbb81c88faa6d1897b31f88655d86 | Ruby | RHesketh/boombox | /test/unit/lib/boombox/mp3/parser/seekable_buffer_test.rb | UTF-8 | 4,379 | 2.640625 | 3 | [
"Unlicense"
] | permissive | require "./test/test_helper"
module Boombox
module MP3
describe Parser::SeekableBuffer do
describe "#initialize(io_stream)" do
before do
mock_io = ("IO")
@buffer = Parser::SeekableBuffer.new(mock_io)
end
it "Sets the frame_marker to 0 by default" do
as... | true |
dbe24a189d050d00fe97e4cf4254db49912ef2dc | Ruby | thypes/dragon-gigapet | /Dragon Gigapet/lib/energy.rb | UTF-8 | 1,242 | 3.1875 | 3 | [] | no_license | class Energy
attr_reader :value_energy
MAX_ENERGY = 100
HIGH_ENERGY = 85
GOOD_ENERGY = 70
MEDIUM_ENERGY = 50
FARE_ENERGY = 30
LOW_ENERGY = 15
IME_STEP_ENERGY = -10
TIME_INCREASE_ENERGY= -15
def initialize
@value_energy = rand(LOW_ENERGY..MAX_ENERGY)
end
def st... | true |
563ee4deef791116d3343aecc8f2edcbdb854ec5 | Ruby | zchen15/nupack_drawing | /drawing-hg/meltplot/MeltParser.rb | UTF-8 | 1,840 | 3.265625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Parser of melt data, first hack version, written by JSB and MBP.
prefix = ARGV[0]
tempStart = (ARGV[1]).to_f
tempIncrement = (ARGV[2]).to_f
tempEnd = (ARGV[3]).to_f
outputFile = ARGV[4]
temperatures = Array.new
temp = tempStart
nTemps = 0
while temp <= tempEnd
temperatures << temp
temp += te... | true |
fc2629c8cf10a20bb85214300c321c108bdc27d8 | Ruby | alu0100498820/prct11 | /lib/matrix_dd_lpp_t16/matriz.rb | UTF-8 | 601 | 3.046875 | 3 | [
"MIT"
] | permissive | require "./lib/matrix_dd_lpp_t16/fraccion.rb"
module MatrixDdLppT16
#Clase abstracta Matriz
class Matriz
#Variable que lee el numero de filas y columnas de la matriz.
attr_reader :filas, :columnas
#Variable que guarda la posicion
attr_accessor :pos
#Constructor de la clase Matriz... | true |
fbffe82e19587ca159edab41d1510110e3c42de2 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/1d54a38eadde45ac9f510ca8adcf2a20.rb | UTF-8 | 484 | 3.671875 | 4 | [] | no_license | class Hamming
def self.compute(*strands)
new(*strands).compute
end
attr_reader :strands
def initialize(*strands)
@strands = strands
end
def compute
distance = 0
shortest_strand.split(//).each_with_index do |letter, index|
distance += 1 unless letter == longest_strand[index]
end... | true |
b1ec57360f93490ed6b1c9c06cf26a305cbb362c | Ruby | cloudaper/liquid-icu-filter | /lib/liquid-icu-filter.rb | UTF-8 | 466 | 2.703125 | 3 | [] | no_license | require 'liquid'
require 'message_format'
module Icu
# Convert the first letter of an input string to upcase and keep the rest
def upcase_first(input)
input.to_s.sub(/\S/, &:upcase)
end
#def icu(path, icu_args, locale = 'en')
# MessageFormat.new(path, locale).format(Liqaml.extract_hash(icu_args))
#e... | true |
b3c9c3cc6f510a2e7cabf6e0cfebbbe7322d04a1 | Ruby | ipuchkov/images_grubber | /lib/file_saver.rb | UTF-8 | 322 | 2.609375 | 3 | [] | no_license | require 'celluloid/current'
require 'open-uri'
class FileSaver
include Celluloid
def save(name, url)
data = get(url)
write(name, data) if data
end
def write(name, data)
File.open(name, 'w') { |f| f.write(data); f.close }
end
def get(url)
begin
open(url)
rescue
end
end
en... | true |
594a3bf90aaa82efad14badd34e392fff7a502ec | Ruby | compsciacademy/fulltime-program-2021-Q2 | /Week02/Day08/working_dir/users/tests.rb | UTF-8 | 1,019 | 3.140625 | 3 | [] | no_license | require './user.rb'
require './my_test'
def setup
name = "PassUser"
@user = User.new(name)
@user.email = "pass@email.com"
end
setup
def test_user_name
description = "users should have a name"
actual = @user.name
expected = "PassUser"
puts MyTest.run(description, actual, exp... | true |
1130ce1bac286e70ae4bf1f39a3cb7f850f01c1d | Ruby | Kirtiparihar24/toy_simulator | /robot.rb | UTF-8 | 1,697 | 3.53125 | 4 | [] | no_license | class Robot
SEQUENCE = %w[west north east south]
attr_accessor :position, :max_unit
def initialize(max_unit)
@max_unit = max_unit
end
# Save position of toy robot
# Return nil if not value not given in format PLACE X,Y,DIRECTION
def position=(cmd)
coordinates_arr = cmd.gsub(/place/, "").split("... | true |
0b6bc53627960392d6153b008835f393c6fcf8cf | Ruby | grant-mc/LaunchSchool-RB101-Programming-Foundations | /Lesson_4/Loops_2/stop_counting.rb | UTF-8 | 42 | 2.6875 | 3 | [] | no_license | 5.times do |i|
break if i == 3
p i
end | true |
e79c32f4b02a4566ad5a00dddcb7e7d160851da8 | Ruby | TalCohen/CSHWebPacket | /db/renew.rb | UTF-8 | 1,297 | 2.875 | 3 | [] | no_license | require_relative 'packet_ldap'
def renew
Signature.destroy_all
Upperclassman.destroy_all
create_upperclassmen
update_onfloor_freshmen
end
def create_upperclassmen
# Gets an array of the upperclassmen
packet_ldap = PacketLdap::Ldap.new
upperclassmen = packet_ldap.find_upperclassmen
admin_uuid = Fil... | true |
645a476d8b649c7390e187fe79df4ecabb5155f9 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/teamwork.rb | UTF-8 | 4,439 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class Teamwork < MicrosoftGraph::Models::Entity
include MicrosoftKiotaAbstractions::Parsable
##
# The deleted team.
@... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.