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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
09fd6e11c358817d28f9322e7c3514afe9a6532f | Ruby | Seanbon0611/hacker-rank-algos | /diagonal-difference/diagonal_difference.rb | UTF-8 | 515 | 3.828125 | 4 | [] | no_license |
my_array = [[1,3,9], [7,4,2], [5,2,4]]
def diagonalDifference(arr)
left_diag_sum = 0
right_diag_sum = 0
arr.each_with_index do |ar, i|
#iterates through each array within nested array and gets the value assigned to that index
left_diag_sum += ar[i]
#does the same but when you add the '-' in fro... | true |
e8eaad1c5369d3258c0c7b5be9488a6f0c298d7d | Ruby | zarasimasu/my-home-kakeibo | /spec/models/variablecost_spec.rb | UTF-8 | 1,585 | 2.6875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Variablecost, type: :model do
before do
@variablecost = build(:variablecost)
end
describe "バリデーション" do
it "すべての項目が入力されていれば登録できる" do
expect(@variablecost).to be_valid
end
it "備考が入力されていなくても登録できる" do
@variablecost.description = ""
expect(@va... | true |
244988f479dac83edecb468cecacdd2775d2b0da | Ruby | oTnTh/rgd | /test/test_line_1.rb | UTF-8 | 457 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | # coding: utf-8
m = RGD::Image.create_truecolor(11, 11)
m.filled_rectangle(0, 0, 10, 10, 0xFFFFFF)
m.thickness = 3
m.line(5, 0, 5, 11, 0x0)
m.line(0, 5, 11, 5, 0x0)
m.line(0, 0, 11, 11, 0x0)
m.thickness = 1
m.line(5, 0, 5, 11, 0xFF0000)
m.line(0, 5, 11, 5, 0xFF0000)
m.line(0, 0, 11, 11, 0xFF0000)
bas... | true |
f77e67b943b4048f135a7b04e593b2ba16709f13 | Ruby | yhirano55/trace_location | /lib/trace_location/generator/log.rb | UTF-8 | 1,728 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'fileutils'
module TraceLocation
module Generator
class Log < Base # :nodoc:
EVENTS = { call: 'C', return: 'R' }.freeze
INDENT_SPACES = 2
INDENT_STRING = ' '
def initialize(events, return_value, options)
super
@current_dir = ::TraceL... | true |
87cd55441b95d47a0043871b4fa02f196ec56758 | Ruby | worldismiao/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 571 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
names = ["Edsger", "Ada", "Charles", "Alan", "Grace", "Linus", "Matz"]
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(names)
names.collect { |name|
badge_maker(name) }
end
def assign_rooms(names)
names.enum_for(:each_with_index).collect{|name, in... | true |
4b7a71d92ed4115c9f7e26a20ee24b2a1b7e38b0 | Ruby | JelF/memery | /benchmark.rb | UTF-8 | 670 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "bundler/setup"
Bundler.setup
require "benchmark"
require "benchmark/ips"
require "benchmark/memory"
puts "```ruby"
puts File.read(__FILE__)
puts "```"
puts
puts "### Output"
puts
puts "```"
require_relative "lib/memery"
class Foo
class << self
include Memery
def ba... | true |
545d0b9c6d1776c0186dd2ed5a5a5de97919acb5 | Ruby | nadavmatalon/battleships | /lib/player.rb | UTF-8 | 140 | 3.046875 | 3 | [
"MIT"
] | permissive | class Player
attr_accessor :board
attr_accessor :name
def initialize(name, board = Board.new)
@name = name
@board = board
end
end | true |
0d082d38656515c3766077279035a13eda0cbe3e | Ruby | sharath666/wd-june | /ruby/find_highest.rb | UTF-8 | 432 | 3.796875 | 4 | [] | no_license | =begin
Given an array in such a way that the elements stored in array are in increasing order initially and then after reaching to a peak element , elements stored are in decreasing order. Find the highest element.
Input:
2
11
1 2 3 4 5 6 5 4 3 2 1
9
1 3 4 5 7 8 9 5 2
Output:
6
9
=end
array = [1, 2, 3, 4, 5, 6, 5,... | true |
316ff1f17e597f6d119f50a619246a91e5b9b85f | Ruby | t-tonchim/hack_demo | /main.rb | UTF-8 | 584 | 2.609375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'mysql2'
get '/' do
@title = 'main'
@content = 'main_content'
@users = @user || [User.new(1, "user1"), User.new(2, "user2")]
erb :index
end
get '/new' do
@title = 'new'
@content = 'new_content'
erb :new
end
post '/create' do
@user = User.new(params... | true |
b62fc6723fda11003f9deeecdc5869522ae982e3 | Ruby | hockey2249/pig_latin | /lib/word.rb | UTF-8 | 834 | 3.65625 | 4 | [] | no_license | class Word
def initialize(original_word)
@original_word = original_word
@word_array = original_word.chars.to_a
end
def original_word
return @original_word.downcase
end
def piglatinize
if @word_array[0] == "a" || @word_array[0] == "e" || @word_array[0] == "i" || @word_array[0] == "o" || @word_array[0] =... | true |
a6ed124f3227b65aa792fec6714e0d694076cffc | Ruby | safiyc/sphinx-riddles | /app.rb | UTF-8 | 396 | 2.546875 | 3 | [] | no_license | require('sinatra')
require('sinatra/reloader')
require('pry')
also_reload('lib/**/*.rb')
require ('./lib/riddles')
get('/') do
erb(:input)
end
post('/output') do
@ans1 = params.fetch("question1")
@ans2 = params.fetch("question2")
@ans3 = params.fetch("question3")
riddle = Riddle.new(@ans1, @... | true |
f9ca2ebc43dab5986b0e27cd22975b3aeed6f114 | Ruby | NadinColes/WD100 | /June-3/only-in-America.rb | UTF-8 | 344 | 4.40625 | 4 | [] | no_license | #!/usr/bin/env ruby
=begin
Create a function that takes a string and adds the phrase “Only in America!” to the end of it.
=end
def only_in_america(phrase)
phrase + " Only in America!"
# "#{phrase}...Only in America"
end
puts "Enter a sentence and end it with punctuation:"
user_phrase = gets.chomp
puts only_in_... | true |
1dd03c15818a291a8ea12f77bf3cfadf4fc6f519 | Ruby | tegon/ht-rails | /1/challenges/about_hashes.rb | UTF-8 | 2,706 | 3.625 | 4 | [] | no_license | require_relative "challenge"
challenge "Create a hash with the keys :name and :age" do
hash = { name: 'John', age: 32 }
expect { hash.keys == [:name, :age] }
end
challenge "Add a new hash item named :skills, which points to an",
"an array with the items :ruby, :rails, and :javascript" do
hash = { ski... | true |
5a6d4238693584ceb846bc1f1e9b28cb00617543 | Ruby | wakeful-deployment/wake | /libexec/wake-raise-error | UTF-8 | 252 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative '../share/wake/run'
def create
a
end
def a
stack
end
def stack
trace
end
def trace
run! "ls /crap"
end
def error
create # will travel down to trace: error => create => a => stack => trace
end
error
| true |
21bcc26d15808b283b31f5f981ea98502f8c4d18 | Ruby | bratta/gem_uppity | /lib/gem_uppity/upper.rb | UTF-8 | 4,500 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# This code works but it needs some love to make it robust.
# It handles 90% of use cases but needs tests. There's also
# probably better ways to do some of the things, such as
# getting the latest version of a particular gem. Help me
# help you and submit a PR if you see any way to impro... | true |
a71ef8c9ec02796d92a6aed1485fdfa826281066 | Ruby | JoaoGabriel0511/Vagas | /fullstack-web/blogBack/app/controllers/api/v1/posts_controller.rb | UTF-8 | 1,961 | 2.640625 | 3 | [] | no_license | require 'date'
module Api
module V1
class PostsController < ApplicationController
before_action :set_post, only: [:show, :update, :destroy]
def index
posts = Post.order('created_at DESC');
render json: {status: 'SUCCESS', message:'Posts carregados', data:posts},status: :ok
end
... | true |
3bb541081c0e30df66fdd15c62f95f5830ee3ac8 | Ruby | ozolsmodris/appium-workshop | /features/config/filter.rb | UTF-8 | 1,240 | 3.328125 | 3 | [] | no_license | require 'yaml'
class Filter
def initialize(type)
config = YAML.load_file('features/config/filters.yml')[type]
@name = config['name']
@category = config['category']
@sub_categories = []
@parameters = []
config['sub_categories'].each do |sub_cat|
temp_hash = {'title' => sub_cat['sub_cat... | true |
01c3bf4d2acaa9cc23e2186f6c6398724cddba6b | Ruby | tmschndr/kickerapp | /app/models/team.rb | UTF-8 | 1,376 | 2.515625 | 3 | [] | no_license | class Team < ActiveRecord::Base
# attr_accessible :title, :body
has_many :match_scores
has_many :matches, :through => :match_scores
has_and_belongs_to_many :users
delegate :wins, :to => :match_scores
delegate :loses, :to => :match_scores
scope :ranked, order("quote DESC, number_of_wins DESC")
#scope :... | true |
c3988913e450fb0c513f450a5754688618585f43 | Ruby | Steve0320/muse3-api | /app/models/media_group.rb | UTF-8 | 1,131 | 2.546875 | 3 | [] | no_license | # This class represents "groupings" of media files. This is something
# of an abstract notion, since this project supports many different
# media types in the same format. One can think of a grouping as something
# like an album, or tv show. Single items (such as movies) also belong to
# a group, but are the only child... | true |
84a8ab1321981d0426a5cb3a07ef900074c2fa14 | Ruby | cameronjtong/day_planner | /day_planner.rb | UTF-8 | 863 | 3.046875 | 3 | [] | no_license | require "yaml/store"
require_relative "command"
require_relative "task_repository"
class DayPlanner
class CustomError < StandardError
end
def initialize(test_inputs = nil)
@test_inputs = test_inputs
end
def main
system "clear"
loop do
TaskRepository.persist do |lists|
display_tas... | true |
1d685529449553337253a5847e3308b152795c8f | Ruby | sagsh018/Ruby_projects | /Strings_part_1.rb | UTF-8 | 13,533 | 4.84375 | 5 | [] | no_license | # Create a String
# ================
# lets see some of the examples related to the string
puts "Hi there, I'm a string"
puts "I can also include characters and numbers : @ # $ ! 5 7 8"
# we can assign string to variables
name = "Sagar"
l_name = "sharma"
puts name, l_name # Notice that we can print the variables ... | true |
5ced213c6f5b34cf3330e27a5ac2b2bb4eee5531 | Ruby | sharpParadise/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 885 | 4.0625 | 4 | [] | no_license | #write your code here
=begin
Rule 1: If a word begins with a vowel sound,
add an "ay" sound to the end of the word.
#
# Rule 2: If a word begins with a consonant sound,
move it to the end of the word, and then add an "ay"
sound to the end of the word.
#
=end
def translate word
split = word.split(" ")
latin = "... | true |
b9a65ec510157e113a1872278d6b87ef4a83f174 | Ruby | MBO/euler | /euler048.rb | UTF-8 | 446 | 3.75 | 4 | [] | no_license | #!/usr/bin/env ruby1.9
#***************************************************************************
# The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
#
# Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
#***************************************************************************
sum... | true |
33c54c2e936edd4b700992c0ebea30a5e1d28e16 | Ruby | hopsoft/kvn | /lib/kvn/lexer.rb | UTF-8 | 445 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Kvn
class Lexer < Lex::Lexer
tokens(
:KEY,
:VALUE,
:PAIRDELIM,
:PARTDELIM
)
rule :KEY, /\w+(?=:)/
rule :VALUE, /[\w\s.\-]+(?=;)/
rule :PAIRDELIM, /;\s*/
rule :PARTDELIM, /:/
error do |lexer, token|
message = "Illegal cha... | true |
268449e14500519eae085f93c0c305c07b474193 | Ruby | riccardocontri/codebreaker | /features/step_definitions/codebreaker_steps.rb | UTF-8 | 779 | 2.625 | 3 | [] | no_license | # encoding: utf-8
class Uscita
def puts(msg)
messaggi << msg
end
def messaggi
@messaggi ||= []
end
end
def uscita
@uscita ||= Uscita.new
end
Dato /^che non sto ancora giocando$/ do
end
Quando /^inizio una nuova partita$/ do
Codebreaker::Partita.new(uscita).inizia
end
Allora /^dovrei vedere "... | true |
231c21726531277264773b816add08080b7a6b11 | Ruby | vanlep/tests-ruby | /lib/04_simon_says.rb | UTF-8 | 618 | 3.921875 | 4 | [] | no_license | def echo(a)
return "#{a}"
end
puts echo(gets.chomp.to_s)
def shout(a)
return a.upcase
end
puts shout(gets.chomp.to_s)
def repeat(c, n = 2)
return ("#{c} " * n).strip
end
puts repeat(gets.chomp.to_s)
def start_of_word(word, number)
str = "#{word}"
return str[0,number]
end
puts start_of_word(gets.chomp.to_s, g... | true |
1be2b2988076e1a1b80acd4d0e50e0e482e19ef7 | Ruby | iulspop/intro_to_ruby_book_exercises | /methods_chap_3/say.rb | UTF-8 | 68 | 3.046875 | 3 | [] | no_license | def say(words = 'hello')
puts words + '.'
end
say
say "hi" "red" | true |
d2dc8163ff856819e71b2c4126184c99f45afb01 | Ruby | pocke/mighty_json | /benchmarks/large.rb | UTF-8 | 2,034 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
# Usage:
# # The json is result of RuboCop in Readmine project
# # https://drive.google.com/file/d/0B0yU5j3W2zM9WW53b01jaWhFZHc/view?usp=sharing
# $ ruby large.rb json
#
# Result:
# user system total real
# StrongJSON 11.140000 ... | true |
e7db3e91370b7dd30b20b5e3f09a58ad0369619c | Ruby | sporkmonger/gourmet | /lib/gourmet/utility/type_check.rb | UTF-8 | 2,285 | 3.015625 | 3 | [
"MIT"
] | permissive | # ++
# Gourmet, Copyright (c) 2008-2009 Bob Aman
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge,... | true |
98386cf0632c9a017ec84e71dd352b0263afd382 | Ruby | hawkk9/sangoku | /app/domain/battle/before/skills/konran_kosaku.rb | UTF-8 | 961 | 2.6875 | 3 | [] | no_license | module Battle
module Before
module Skills
class KonranKosaku
MAX_HIT_PERCENT = 50
def initialize(user, opponent_user)
@user = user
@opponent_user = opponent_user
@messages = []
end
def handle
# 発動判定
@opponent_user.to_disable... | true |
26654d5dc6e3c4659765827d4589010f221287c4 | Ruby | sizsan/ruby-challenges | /32_interesting_number.rb | UTF-8 | 948 | 4.78125 | 5 | [] | no_license | # Interesting number
# An interesting number is one with at least 3 digits,
# in which the digits are either incrementing or decrementing.
# Examples:
# interesting_number(789) => true
# interesting_number(321) => true
# interesting_number(798) => false
# interesting_number(6) => false
# interesting_number(23) => fal... | true |
4b5c360e6e7998830a66aa2d1f375981e0f2de6f | Ruby | archhere/App-Academy-Homework-archana-kannan | /lib/heap.rb | UTF-8 | 2,954 | 3.53125 | 4 | [] | no_license | require 'byebug'
class BinaryMinHeap
attr_reader :store, :prc
def initialize(store = [],&prc)
@store = store
end
def count
@store.length
end
def extract
root_node = @store[0]
if count > 1
@store[0] = @store.pop
self.class.heapify_down(@store,0,count,&prc)
else
retu... | true |
020c0b4e5fd72f1694960149d7573dd284106962 | Ruby | trivett/BEWD-NYC | /jonathan_serrano/class4/array2.rb | UTF-8 | 305 | 3.046875 | 3 | [] | no_license | countries =[ {"names" => "sweden", "languages" => ["swedish"]},
{"names" => "india", "languages" => ["hindi"]},
{"names" => "japan", "languages" => ["japanese"]}]
countries.each do |country|
puts "languagesspoken in #{ country["name"]}"
country["languages"].each do |l|
puts l.capitalize
end
end
| true |
9b05b4b60602e08eff7d80a9cd4614fbbee19290 | Ruby | monicamow/input_output | /ex2.rb | UTF-8 | 333 | 2.75 | 3 | [] | no_license | require 'open-uri'
url = 'http://ruby.bastardsbook.com/files/fundamentals/hamlet.txt'
local_hamlet = 'hamlet.txt'
hamlet = open(url).read
contents = File.open(local_hamlet, 'w')
contents.write hamlet
File.open(local_hamlet) do |hamlet|
hamlet.readlines.each_with_index do |line, index|
p line if index % 42 == 41
... | true |
a7beac81eb5b28b288cfaa0875ca0e7c0632cf6c | Ruby | AnguillaJaponica/Ruby_Library_For_Contests | /ABC/ABC126/A.rb | UTF-8 | 77 | 3.15625 | 3 | [] | no_license | n, k = gets.split.map(&:to_i)
s = gets.chomp
s[k-1] = s[k-1].downcase
puts s | true |
393654562f5e3eda6d0cb42d632e53622dd2924c | Ruby | nagyist/rally-apps-Perforce-To-Rally-Connector | /lib/obfuscate.rb | UTF-8 | 1,687 | 3.5 | 4 | [
"MIT"
] | permissive | # Copyright 2002-2012 Rally Software Development Corp. All Rights Reserved.
require "base64"
# This really basic algorithm obfuscates but does not encrypt strings
# I want to use the same XML field for both regular and @encoded passwords
#Thanks to Erika for the idea about adding some text at the beginning of the @e... | true |
4f9003c9b6b0076aa311ba7af5537ef125233594 | Ruby | Axentro/axentro-rb-util | /lib/crypto/keys/public_key.rb | UTF-8 | 894 | 2.71875 | 3 | [
"MIT"
] | permissive | module Crypto::Keys
class PublicKey
attr_reader :network
def initialize(public_key_hex, network = MAINNET)
@public_key_hex = public_key_hex
@network = network
raise AxentroError, "invalid public key: #{@public_key_hex}" unless is_valid?
end
def s... | true |
60ecd86b0eee63063baf1c3c311b8a6db97a74a2 | Ruby | sisbas/Ruby | /mukemmelSayilar.rb | UTF-8 | 322 | 3.171875 | 3 | [] | no_license | dizi = Array.new
def Topla(n)
gecici = 0
for x in n
gecici = gecici + x
end
return gecici
end
for x in 5..1000
if x % 2 == 0 then
geciciDizi = Array.new
for y in 1..x/2+1
if x % y == 0 then
geciciDizi.push(y)
end
end
else next
end
if Topla(geciciDizi) == x then
dizi.push(x)
end
end
dizi
... | true |
cb924fc2e460c5192903b325b5573280753683b5 | Ruby | Stearnzy/backend_mod_1_prework | /day_7/10_speckled_frogs.rb | UTF-8 | 829 | 3.890625 | 4 | [] | no_license | # Change this value for any number of speckled frogs!
num_frogs = 10
require 'humanize'
while num_frogs > 2 do
puts "#{num_frogs.humanize.capitalize} speckled frogs sat on a log"
puts "eating some most delicious bugs."
puts "One jumped in the pool where it's nice and cool,"
puts "then there were #{(num_frogs... | true |
f7f2c8ea36bbfba37cc531c29ab024ef8f6b47ad | Ruby | jstotz/bigfile | /src/ruby/munge.rb | UTF-8 | 70 | 2.609375 | 3 | [] | no_license | while gets do
puts $_.split(',').map {|i| i.to_i ** 2}.join(',')
end | true |
209e33fa550ebf4ee8bc81aab6a528e773cd7744 | Ruby | lipanski/ansible-custom-modules-demo | /library/my_ruby_module.rb | UTF-8 | 312 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "json"
params = {}
arguments = File.read(ARGV[0])
arguments.split(" ").each do |argument|
key, value = argument.split("=")
next unless key && value
params[key] = value
end
# This is how you fetch parameters
params["name"]
puts ({ changed: true, params: params }).to_json
| true |
afc180e70569e2314a466c9a6c3e28eb1a6044e6 | Ruby | acnjr2010/busca_dinamica | /app/models/anime.rb | UTF-8 | 700 | 2.609375 | 3 | [] | no_license | class Anime < ApplicationRecord
scope :anime_name, lambda { |parameter| where("name like ?", "%#{parameter}%")}
scope :anime_year, lambda { |parameter| where("year like ?", "%#{parameter}%")}
scope :anime_episodes, lambda { |parameter| where("episodes like ?", "%#{parameter}%")}
scope :anime_manga, lambda {|paramet... | true |
604083993b81188036094a76633c89c88f479320 | Ruby | googleapis/google-api-ruby-client | /generated/google-apis-chat_v1/lib/google/apis/chat_v1/classes.rb | UTF-8 | 196,026 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | true |
a4d0c8b6866a82cb0f2e40c8c387bcc50236078c | Ruby | andydlindsay/mar29-2021 | /w08d05/03_loops.rb | UTF-8 | 657 | 3.71875 | 4 | [] | no_license | i = 0
# loop do
# i += 1
# puts 'hello there', i
# # if i > 10
# # break
# # end
# break if i > 10
# end
# while i < 10 do
# i += 1
# puts "hello #{i}"
# end
# until i > 10 do
# i += 1
# puts "hello #{i}"
# end
goats = ['Stephen', 'Goaty', 'Billy', 'Phillipe', 'Goatie McGoatFace', 'Zanthor']... | true |
37ae9dbe5f42f83c185ad0dbc23c59dcae5f5cfe | Ruby | Koehd896/sinatra-basic-forms-lab-online-web-sp-000 | /models/puppy.rb | UTF-8 | 262 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # since we are not using ActiveRecord in this lab, you write a bare Ruby model (like you did in MOD1)
class Puppy
attr_accessor :name, :breed, :age
def initialize(name:, age:, breed:)
@name, @age, @breed = name, age, breed
end
end
| true |
daa4c40a60b88f75330210ecb69d5eeacaade61e | Ruby | dimus/tuskit | /app/models/story.rb | UTF-8 | 1,386 | 2.5625 | 3 | [
"MIT"
] | permissive | class Story < ActiveRecord::Base
belongs_to :iteration
has_many :agile_tasks
has_many :implementations
has_many :features, :through => :implementations
validates_presence_of :name
def project
iteration.project
end
def active?
!self.agile_tasks.select {|t| t.active?}.blank?
end
def co... | true |
9ab1a4b7a55aa7a7ad4fffef4986942d9edad715 | Ruby | calabash/ios-smoke-test-app | /CalSmokeApp/features/step_definitions/drag_and_drop_steps.rb | UTF-8 | 2,507 | 2.78125 | 3 | [
"MIT"
] | permissive | module CalSmokeApp
module DragAndDrop
class Color
attr_reader :red, :green, :blue
def initialize(red, green, blue)
@red = red
@green = green
@blue = blue
end
def to_s
"#<Color #{red}, #{green}, #{blue}>"
end
def inspect
to_s
end... | true |
28ec0312d70fb6a55d8b8dd063309518b480d093 | Ruby | CyberSource/cybersource-rest-samples-ruby | /lib/SampleApiClient/Masking/Masking.rb | UTF-8 | 798 | 2.84375 | 3 | [] | no_license | require 'json'
class Masking
# Masking function
def maskPayload(reqJson)
if !reqJson.to_s.empty?
res=""
jsonStr = JSON.parse(reqJson)
filter_parameters = ["expirationMonth","expirationYear","email","firstName","lastName","phoneNumber","number","securityCode","type"]
filter_parameters.eac... | true |
fbb1df9e7455cffca409e05fa382d09d6cdb179a | Ruby | southpawgeek/perlweeklychallenge-club | /challenge-133/abigail/ruby/ch-2.rb | UTF-8 | 823 | 3.875 | 4 | [] | no_license | #!/usr/bin/ruby
#
# See ../README.md
#
#
# Run as: ruby ch-2.rb
#
$small_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
def factorize (num)
factors = []
$small_primes . each do
| prime |
while num % prime == 0 do
factors . push(prime)
num /= prime
end
... | true |
2d9f6b19ac3717761555eedd605c4e5d96811d79 | Ruby | akmalkhadir/advanced-hashes-hashketball-london-web-091718 | /hashketball.rb | UTF-8 | 5,832 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
# Write your code here!
def game_hash
game = {
home: {
team_name: "Brooklyn Nets",
colors:["Black", "White"],
players: {
"Alan Anderson" => {
number: 0,
shoe: 16,
points: 22,
re... | true |
a30046a602a022d80ba7dea87a6835830b1658ce | Ruby | jcoene/loggy | /app/models/event.rb | UTF-8 | 1,820 | 2.71875 | 3 | [] | no_license | class Event < ActiveRecord::Base
attr_accessor :raw, :time, :event, :source, :dest, :spell
attr_protected :amount, :overkill, :resisted, :blocked, :absorbed, :critical, :glancing, :crushing
def to_s; @raw; end
def parse(str)
r = str.split(",")
time, event = r[0].split(" ")
@raw = str
@time = Tim... | true |
253577d482617817a081ef0767a830a67b822086 | Ruby | hilaryml/sql-library-lab-v-000 | /lib/querying.rb | UTF-8 | 1,317 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"SELECT books.title, books.year FROM books
JOIN series
ON books.series_id = series.id
WHERE series.id = 1
ORDER BY books.year;"
end
def select_name_and_motto_of_char_with_longest_motto
"SELECT characters.name, characters.motto FROM characters
ORDER... | true |
e1e069c94554d344d3608b29fcad1ac1c53267d5 | Ruby | jasonronalddavis/collections_practice-online-web-sp-000 | /collections_practice.rb | UTF-8 | 664 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort.reverse
end
def sort_array_char_count(array)
array.sort_by {|x| x.length}
end
def swap_elements(array)
array[1],array[2] = array[2],array[1]
array
end
def reverse_array(array)
array[0],array[2] = array[2],a... | true |
55de97e13ae0fddd4578ddbfe5d4f581eb469acf | Ruby | Mahern-13/ruby-object-attributes-lab-bootcamp-prep-000 | /lib/person.rb | UTF-8 | 228 | 2.890625 | 3 | [] | no_license | class Person
def name(name)
@name = name
end
def name
@name
end
def name=(new_name)
@name = new_name
end
def job(job)
@job = job
end
def job
@job
end
def job=(new_job)
@job = new_job
end
end
| true |
1f0961b2c6b0715bb6032be012e96e979858ce8e | Ruby | GSI-HPC/sys-chef-cookbook | /libraries/pamupdate_profile.rb | UTF-8 | 2,303 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | class PamUpdate
class Profile
include Comparable
attr_reader :fields
def <=>(another)
priority = another.fields()[:Priority] <=> fields()[:Priority]
if priority == 0
fields()[:Name] <=> another.fields()[:Name]
else
priority
end
end
private
attr_read... | true |
596ff72bfb4a832f90e5cd96a2dac957132c388c | Ruby | yagitoshiro/lokka-ferret | /lib/yahoo_parser.rb | UTF-8 | 702 | 2.640625 | 3 | [] | no_license | require 'uri'
require 'open-uri'
require 'rexml/document'
class Yahoo_Parser
include ::Ferret_Parser
def initialize(yahoo_id)
@yahoo_id = yahoo_id
@yahoo_url = 'http://jlp.yahooapis.jp/MAService/V1/parse?'
end
def parse(str)
url = @yahoo_url + "appid=#{@yahoo_id}&sentence=#{URI.encode(str)}&resul... | true |
b4cd124433138d6ed87d49f1a0e3f970dd9f136e | Ruby | Kamitotomi/ruby-studying | /lib/method_open.rb | UTF-8 | 1,362 | 3.84375 | 4 | [] | no_license | # メソッドの公開レベル
# public(デフォルト)
# class User
# def hello
# 'Hello!'
# end
# end
#
# user = User.new
# publicなので外部から呼び出し可能
# puts user.hello
# privateメソッド
# class User
# private
# def hello
# 'Hello!'
# end
# end
# user = User.new
# privateなので外部から呼び出しできない
# puts user.hello
# pri... | true |
099d6daa912f8b41e17366f8778c3e47a9be7ae2 | Ruby | ruxpin/weibo-search | /weibo-search.rb | UTF-8 | 2,317 | 2.625 | 3 | [] | no_license | #encoding: utf-8
require 'optparse'
require_relative 'lib/sina'
require_relative 'lib/tencent'
options = {}
begin
option_parser = OptionParser.new do |opts|
# 命令行工具的帮助信息
opts.banner = " 微博搜索信息更新工具,Created By Rux\n"
# Option 为initdb,不带argument,用于将switch默认设置成true或false
# 第一项是Short ... | true |
08f8331bde51f9ce90f4ee4966b896a10901cda0 | Ruby | FougereBle/thp-ruby-exercices | /exo_21.rb | UTF-8 | 708 | 3.75 | 4 | [] | no_license | # Le programme doit demander à l'utilisateur le nombre d'étage que doit faire la pyramide.
# Le programme affiche ensuite N lignes (nb étages) formant la pyramide.
# Pour chaque lignes, le programme doit afficher X espaces et Y dièses.
# X correspond au nombre de ligne moins 1 et se décrémente à chaque lignes.
# Y corr... | true |
9bf755a810b4f0d5a0dc783517e174facbc739b4 | Ruby | HaroonMohammadomar/RB101 | /lesson_4/methods_and_more_methods_practice/practice_problem_5.rb | UTF-8 | 189 | 3 | 3 | [] | no_license | hash = { a: 'ant', b: 'bear' }
p hash.shift
# // Removes a key-value pair from hsh and returns it as the two-item array [ key, value ], or the hash’s default value if the hash is empty.
| true |
b382d8fe913ef4168bee6fa7d8867bf3a8bb2628 | Ruby | ddk376/memory_match | /human_player.rb | UTF-8 | 574 | 3.640625 | 4 | [] | no_license | class HumanPlayer
attr_reader :num_of_matches, :board_size
def initialize(num_of_matches, board_size)
@num_of_matches = num_of_matches
@board_size = board_size
end
def prompt
puts "Guess a row and a column integer value (separated by commas)"
get_input
end
def get_input
input = gets.ch... | true |
3862431f5ef209cf9b6bee62a348a2f32bd2d74b | Ruby | metamorph/Scrummy | /lib/model.rb | UTF-8 | 2,883 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'date'
# The model.
module Scrummy
class Sprint
class Builder
def initialize(name)
@sprint = Sprint.new(name)
end
def build(&block)
instance_eval &block
return @sprint
end
#
# Setup the sprint schedule.
# All dates are specified as strings, and will be parsed by +Date.parse+.
# +sta... | true |
d732cc6c202fbbd47d734222e314e2f28cd5de35 | Ruby | florent-augier/RUBY | /MINI_JEUX/even.rb | UTF-8 | 381 | 3.765625 | 4 | [] | no_license | array = [15,468,78,44,64,12]
puts array.map(&:even?)
puts ""
puts array.map(&:odd?)
puts ""
puts array
puts ""
def odd(array)
array.map {|number| number % 2 != 0 ? number : nil}.reject(&:nil?)
end
def even(array)
array.map {|number| number % 2 == 0 ? number : nil}.reject(&:nil?)
end
def perf... | true |
e2468f6e10f656472f3ddadd4cfb2048dfe5e480 | Ruby | rbirky1/cmsc433-ruby-wiki | /wiki_v3.rb | UTF-8 | 6,089 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Name: wiki.rb
# Author: Rachael Birky
# Description: This is a webcrawler that find relationships
# between arbitrary topics on Wikipedia
require 'open-uri'
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
def get_html_contents(url)
url_string="... | true |
e878fef5313e939892ed1db94029ee10ffe003d2 | Ruby | christianlarwood/ruby_small_problems | /1.fundamentals_exercises/medium_1.rb/rotation_pt3.rb | UTF-8 | 1,478 | 4.8125 | 5 | [] | no_license | =begin
If you take a number like 735291, and rotate it to the left, you get 352917. If you now keep the first digit fixed in place, and rotate the remaining digits, you get 329175. Keep the first 2 digits fixed in place and rotate again to 321759. Keep the first 3 digits fixed in place and rotate again to get 321597. F... | true |
a64761a9e684356bfa6ab28f3aa1fd89ed0f3d4a | Ruby | Franerial/Thinknetica_Ruby_Base-Railway | /lesson_2/task_2.rb | UTF-8 | 260 | 3.390625 | 3 | [] | no_license | puts "Введите длину основания треугольника"
a = gets.chomp.to_f
puts "Введите длину высоты треугольника"
h = gets.chomp.to_f
puts "Площадь треугольника равна #{0.5 * a * h}" | true |
8c1d94d8a2443510fd8406df2c7dfece68fc0504 | Ruby | bnadav/scraper | /app/models/page_scraper.rb | UTF-8 | 852 | 3.15625 | 3 | [] | no_license | require 'open-uri'
class PageScraper
# Tags to consider
TAGS = ['h1', 'h2', 'h3', 'a']
# #call return value is instance of this struct
# <tt>status</tt> +:ok+ or +:error+
# <tt>error_msg</tt> description of error message
# <tt>content</tt> content hash. Keys are: h1,h2,h3
Result = Struct.new(:status, :e... | true |
6540d9ad977c27229f147a21c7a20b4ddb1b4397 | Ruby | SeanSith/dotfiles | /local/bin/ec2 | UTF-8 | 2,963 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'bundler/inline'
require 'getoptlong'
require 'openssl'
gemfile do
source 'https://rubygems.org'
gem 'aws-sdk-ec2'
gem 'ox'
end
class Instance
attr_reader :name, :project, :stages, :roles, :state, :id, :public_ip_address,
:private_ip_address, :key
def initialize(instance)
... | true |
f2cd6c69b8ba53c3d90cd52b72be8380edbb3533 | Ruby | kylesallette/night_writer | /lib/night_writer.rb | UTF-8 | 1,378 | 3.703125 | 4 | [] | no_license | require 'pry'
require_relative 'eng_to_braille_library'
class NightWriter
attr_reader :input,
:output,
:text,
:data
def initialize
@input = ARGV[0]
@output = ARGV[1]
@library = EngToBrailleLibrary.new
@text = text
@data = []
end
def read_file
... | true |
5248cee8ac0b195d2fd4d84af254605392c06994 | Ruby | philw214/pw_project1 | /flashcards/lib/card.rb | UTF-8 | 178 | 2.53125 | 3 | [] | no_license | class Card < ActiveRecord::Base
belongs_to :category
validates :question, presence: true
validates :answer, presence: true
def to_s
return "#{id}. " + question
end
end
| true |
0fb5622a52b9ca6d7c193de27749a441ea035117 | Ruby | StarPerfect/cross_check | /test/season_statistics_test.rb | UTF-8 | 4,813 | 2.765625 | 3 | [] | no_license | require './test/test_helper'
class SeasonStatisticsTest < Minitest::Test
def setup
files = {
games: './test/dummy_data/dummy_game.csv',
teams: './test/dummy_data/dummy_team_info.csv',
game_teams: './test/dummy_data/dummy_game_teams_stats.csv'
}
@stat_tracker = StatTracker.from_csv(file... | true |
2b33b3f3a857304f4b02ac690b27ea0e6b8b3f5a | Ruby | crest-cassia/xsub | /lib/template.rb | UTF-8 | 459 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'erb'
module Xsub
module Template
class Namespace
def initialize(hash)
singleton_class = class << self; self; end
hash.each do |key,val|
singleton_class.send(:define_method, key) { val }
end
end
def get_binding
binding
end
end
... | true |
21987a10a059334ab202ac3033561b04f9b890ca | Ruby | vzharkov/overseer | /lib/command.rb | UTF-8 | 196 | 3.0625 | 3 | [] | no_license | class Command
attr_reader :name, :who, :title, :when_time
def initialize(name, who, title, when_time)
@name = name
@who = who
@title = title
@when_time = when_time
end
end
| true |
174db19490d9191e1a3fd2bf8d9314d0e6f38fae | Ruby | gavri/unlikely | /random_variable.rb | UTF-8 | 1,697 | 2.921875 | 3 | [] | no_license | class RandomVariable
PointMass = Struct.new("PointMass", :outcome, :probability)
def initialize(pmf)
@pmf = pmf
end
def self.build_from_raw(arg)
raw_frequencies = arg.values
total_number_of_parts = raw_frequencies.reduce(:+)
new(arg.each_with_object({}) {|(outcome, number_of_parts), acc| acc[... | true |
9819c10abec2e5abef30b428859bc2deb374c011 | Ruby | skillslate/ruby-aws | /samples/mturk/simple_survey/SimpleSurvey.rb | UTF-8 | 3,304 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# Copyright:: Copyright (c) 2007 Amazon Technologies, Inc.
# License:: Apache License, Version 2.0
begin ; require 'rubygems' ; rescue LoadError ; end
# The Simple Survey sample application will create a HIT asking a worker to indicate their
# political party preferences.
#
# mturk.properties m... | true |
e5003d75d04b3395bcc749307173576afb2a88d7 | Ruby | xgsarnold/github_profile_copy | /test/models/user_test.rb | UTF-8 | 587 | 2.546875 | 3 | [] | no_license | require 'test_helper'
require 'byebug'
# Begin Monkey Patch
class User
attr_reader :user
def initialize(name:)
@user = get_response(:name)
end
def get_response(user)
mock_user = File.read("./test/fixtures/user.json")
@response = JSON.parse(mock_user)
end
end
# End Monkey Patch
class UserTest <... | true |
ae393ee695b281728df4e68ebbba3515276bf36c | Ruby | chef/chef_secrets | /lib/veil/credential_collection/base.rb | UTF-8 | 8,143 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require "veil/cipher"
require "veil/credential"
require "veil/hasher"
require "forwardable"
module Veil
class CredentialCollection
class Base
class << self
def create(hash = {})
new(hash)
end
end
extend Forwardable
attr_reader :credentials, :hasher, :version, :... | true |
01503c6e0d418c8231688f5a87a580ebdb50c152 | Ruby | ttreit-archive/LRTHW | /Ex31_story_test.rb | UTF-8 | 628 | 3.8125 | 4 | [] | no_license | ### Write a choose your own adventure story Ex 31
### Functions for each section
def prompt
print "* "
end
def hline_top
puts "_________________________________________________________"
end
def hline_bottom
puts "---------------------------------------------------------"
end
def intro
puts "As you gain conscio... | true |
099b6dd83b52b9e7e7abd0f6bb3e234572faec7c | Ruby | apt-install-tree/itsa-me-mario | /exo_02.rb | UTF-8 | 172 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env ruby
puts "Bonjour, monde !\nEt avec une voix sexy, ça donne : Bonjour, monde !"
# Pas de retour á la ligne á la fin d'un print alors qu'avec un puts, si | true |
e0c1939ccd9f4cd41a806456c2053b28769d2a65 | Ruby | ozzman84/funny_2107 | /spec/open_mic_spec.rb | UTF-8 | 1,160 | 3.203125 | 3 | [] | no_license | require './lib/open_mic'
require './lib/user'
require './lib/joke'
RSpec.describe OpenMic do
before(:each) do
@open_mic = OpenMic.new({location: "Comedy Works", date: "11-20-18"})
@user_1 = User.new("Sal")
@user_2 = User.new("Ali")
@joke_1 = Joke.new(22, "Why did the strawberry cross the road?"... | true |
ea077ee4f25e01dc8f5bb6c55d1a3d168f476a8c | Ruby | HISMalawi/Demographics-Data-Exchange | /vendor/bundle/ruby/2.5.0/gems/net-ping-2.0.8/test/test_net_ping_udp.rb | UTF-8 | 3,117 | 2.6875 | 3 | [
"Artistic-2.0"
] | permissive | ########################################################################
# test_net_ping_udp.rb
#
# Test case for the Net::Ping::UDP class. This should be run via the
# 'test' or 'test:udp' Rake tasks.
#
# If someone could provide me a host where a udp ping actually
# works (with a service check), I would appreciate it... | true |
d2d8939270e5b79d734406cd19156c86b74cdca7 | Ruby | xero-gateway/xero_gateway | /lib/xero_gateway/gateway.rb | UTF-8 | 34,230 | 2.59375 | 3 | [
"ISC"
] | permissive | module XeroGateway
class Gateway
include Http
include Dates
attr_accessor :client, :xero_url, :payroll_url, :logger
extend Forwardable
def_delegators :client, :request_token, :access_token, :authorize_from_request, :authorize_from_access, :expires_at, :authorization_expires_at
#
# The ... | true |
6e1bed6598ec2a10112e7c361cb0d0b163512460 | Ruby | LeeTigges/LS_ruby | /rb100/ch6/flow_control_exercises.rb | UTF-8 | 798 | 4.46875 | 4 | [] | no_license | def long_string_caps(a)
if a.length > 10
a.upcase
else
a
end
end
puts long_string_caps('joseph f smith ' + 'was here')
puts long_string_caps('this is a long string')
puts 'Type in a number between 0 and 100:'
num = gets.chomp.to_i
if num >= 0 && num < 50
puts 'Your number is between 0 and 50.'
elsif ... | true |
1317bcdc05df722d0813d32bfd8f7fa6a46e1a28 | Ruby | srikaanthtb/oystercard | /lib/oystercard.rb | UTF-8 | 808 | 3.34375 | 3 | [] | no_license | require_relative 'journey'
class Oystercard
attr_reader :balance, :journey, :journey_history
MAX_BALANCE = 90
MIN_FARE = 1
def initialize
@balance = 0
@journey = Journey.new
@journey_history = []
end
def top_up(value)
fail "Top up limit of #{MAX_BALANCE} exceeded" if value > MAX_BALANCE
... | true |
f3ba2cd8f555a5c663041fa50c1ed835a991b3a6 | Ruby | Tom-Hayes/Markus | /spec/models/submission_rule_spec.rb | UTF-8 | 24,288 | 2.515625 | 3 | [
"MIT"
] | permissive | describe SubmissionRule do
context 'A newly initialized submission rule' do
it 'belongs to an assignment' do
is_expected.to belong_to(:assignment)
end
end
context '#calculate_collection_time' do
let(:assignment) { create(:assignment) }
it 'should return something other than nil at the end'... | true |
4b1ab779af5b9212b2538abef9b89b9c9d765920 | Ruby | dobbytc/aisredis | /lib/aisParser.rb | UTF-8 | 716 | 3.171875 | 3 | [] | no_license |
class AisParser
def initialize()
@@patSentence = /^[0-9]{10}\.[0-9]{9}!AIVDM,\d,\d,\d?,[A-B],.*/
@@patMessage = /^[0-9]{10}\.[0-9]{9},\d,[A-B],.*/
end
def isSentence?(sentence)
if sentence.match(@@patSentence) then
#looks like we have an ais sentence
left, aivdm = sentence.split('!')
... | true |
7a104809d0d2f52c388be9d566503d370c4a092d | Ruby | olozzalap/blackjack_sinatra | /public/blackjack_oo_engine.rb | UTF-8 | 235 | 2.84375 | 3 | [] | no_license | require blackjack_oo_classes.rb
puts "How many decks do you want to play Blackjack with?"
print "> "
num_of_decks = gets.chomp.to_i
game_cards = Cards.new(num_of_decks)
player = Player.new
dealer = Dealer.new
until player. | true |
59acbb7e2d8497c9ffc4038824050098c95a021a | Ruby | kinaphar/AtCoder | /ABC/ABC223/d.rb | UTF-8 | 44 | 2.609375 | 3 | [] | no_license | n,m = gets.chomp.split(" ")
puts n
puts m
| true |
fe5961460daa5e0f851e31273ca20114a146d394 | Ruby | Na0ki/mikutter-cli | /model/config.rb | UTF-8 | 1,503 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'diva'
require 'highline'
require_relative './depends'
# Model for .mikutter.yml
class Config < Diva::Model
field.string :slug, required: true
field.has :depends, Depends
field.string :name, required: true
field.string :version, required: true
field.string :author, r... | true |
5de4f6f1f293ee04e5b00cddb5e370346888f0de | Ruby | isildonmez/code_wars | /enumerable_magic.rb | UTF-8 | 811 | 3.609375 | 4 | [] | no_license | # https://www.codewars.com/kata/enumerable-magic-number-7-find-a-matching-item/solutions/ruby
def find(list, &block)
list.each { |var| return var if block.call(var)}
nil
end
def find_2(list, &block)
list.find(&block)
end
def find_3(list, &block)
list.detect(&block)
end
# `detect` and `find` are two names f... | true |
dd637ad5499cac7b80a005490acbdece8e1d31fc | Ruby | Macaroni2629/Launch-School | /101_programming_foundations/RB101_109_small_problems/09_easy/10_grocery_list.rb | UTF-8 | 722 | 4.40625 | 4 | [] | no_license | # Grocery List
# Write a method which takes a grocery list (array) of fruits with quantities and converts it into an array of the correct number of each fruit.
# Example:
def buy_fruit(array)
final_array = []
array.each do |subarray|
subarray[1].times do |_|
final_array << subarray[0]
end
end
fina... | true |
6cd598425458681257a1e01b8e6e28970d91e865 | Ruby | knoxknox/dev-labs | /async/jruby_jvm_futures.rb | UTF-8 | 928 | 2.953125 | 3 | [] | no_license | java_import java.util.concurrent.CompletableFuture
# 1
future = CompletableFuture.supply_async { 'Hello' }
# 2
future = CompletableFuture.supply_async { 'Hello' }.
then_apply { |x| "#{x} world" }.then_apply { |x| x.size }
# 3
future = CompletableFuture.supply_async { 'Hello' }.
then_apply { |x| "#{x} world" }.th... | true |
603b287ebea1d46b59af5a86af205ea7d64ce03c | Ruby | barr-code/great-circle-distance | /spec/distance_calculator_spec.rb | UTF-8 | 2,242 | 3.40625 | 3 | [] | no_license | require 'distance_calculator'
describe DistanceCalculator do
let(:calculator){DistanceCalculator.new(-6.2592576, 53.3381985)}
it "#extract_customer_data returns an array of data" do
customer_data = calculator.extract_customer_data("test_examples.txt")
expect(customer_data.is_a?(Array)).to be true
end
... | true |
4dd56248f130b82f627d6dc527e71913fe63c257 | Ruby | Sujimichi/Spector | /spector.rb | UTF-8 | 2,531 | 2.953125 | 3 | [] | no_license | class Spector
#require File.expand_path("../../config/environment", __FILE__)
attr_accessor :files, :data
def initialize
@paths = {:spec => 'rb', :features => 'feature' } #key is folder name in rails root, value is file extention for that test type
@files = {}
end
def go
list :features
list :... | true |
a109f042a97bfc2a09b935dea88f1140f9c4c45f | Ruby | chocochino/ruby-inter | /final-project/main.rb | UTF-8 | 3,237 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'sinatra'
require './controllers/customer_controller.rb'
require './models/customer.rb'
require './controllers/item_controller.rb'
require './models/item.rb'
require './controllers/category_controller.rb'
require './models/category.rb'
require './controllers/order_controller.rb'
require './models/order.rb'
requ... | true |
710f937dd7ed6727487d9e991862988456318add | Ruby | zhaoxl/nest_job | /app/models/bill.rb | UTF-8 | 635 | 2.578125 | 3 | [] | no_license | class Bill < ActiveRecord::Base
belongs_to :account
ACTION_TYPE_RECHARGE = 0 #充值
ACTION_TYPE_CONSUME = 1 #消费
#充值
def self.recharge(account, money)
available_gold = account.available_gold
after_alance = available_gold + money
bill = account.bills.build(
from_account_id: nil,
... | true |
a3d788044f2f08a1e8dcb37917a9fe48231c1c01 | Ruby | puppetlabs/showoff | /lib/showoff/compiler/notes.rb | UTF-8 | 2,955 | 2.609375 | 3 | [
"MIT"
] | permissive | # adds presenter notes processing to the compiler
class Showoff::Compiler::Notes
# Generate the presenter notes sections, including personal notes
#
# @param doc [Nokogiri::HTML::DocumentFragment]
# The slide document
#
# @param profile [String]
# The markdown engine profile to use when rendering... | true |
65af77e9e09256301bfc947e800c3218fe457ea8 | Ruby | pipt/image_validator | /lib/image_validator.rb | UTF-8 | 796 | 2.859375 | 3 | [] | no_license | require 'stringio'
module ImageValidator
def valid?(file)
file = thing_to_io(file)
check_image_magick_is_available
IO.popen("identify - >/dev/null 2>&1", "wb") do |identify|
some_content_has_been_read = false
while blk = file.read(1024**2)
identify << blk
some_content_has_been... | true |
ea2af38d4d63c148fc16eb97ffce61b5d8a6bc66 | Ruby | heldtogether/train-scheduler | /spec/exact_path_length_checker_spec.rb | UTF-8 | 1,492 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'graph'
require 'exact_path_length_checker'
RSpec.describe ExactPathLengthChecker do
it "accepts paths that are the exact length" do
graph = Graph.new
checker = ExactPathLengthChecker.new(graph, 1)
expect(checker.valid_path? ['A', 'B']).to eq true
end
it "doesn't accept paths that are not the ex... | true |
5010aee95181bdb1bc6879b29c45d89a75f5e31d | Ruby | hmans/pants | /app/services/user_fetcher.rb | UTF-8 | 2,166 | 2.53125 | 3 | [
"MIT"
] | permissive | class UserFetcher < Service
attr_reader :url, :uri, :opts, :response, :data
class InvalidData < RuntimeError ; end
# The following attributes will be copied from user JSON responses
# into local Post instances.
#
ACCESSIBLE_JSON_ATTRIBUTES = %w{
display_name
domain
locale
url
}
def pe... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.