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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c43ae866d298ee162d7f28f96d427c0da15b5401 | Ruby | Zozeh/calendrier | /app.rb | UTF-8 | 573 | 2.875 | 3 | [] | no_license | require 'pry'
class User
attr_accessor :email
@@user_count = 0
def initialize (email_to_save)
@email = email_to_save
# @name = name_to_save
@@user_list = []
# user_list[@@user_count]=@name
# user_count += 1
end
# def update_name (name_n... | true |
adf00a1f82f873fd2840528ec7ad92cc2492e5c8 | Ruby | cedric-joaquin/prime-ruby-onl01-seng-pt-050420 | /prime.rb | UTF-8 | 202 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(int)
int.positive? ? multiples = (2...int).to_a : multiples = (int+1..1).to_a
multiples.delete(0)
return false if int == 1
!multiples.any? do |num|
int % num == 0
end
end | true |
d68b9f5d61afc8b3646cb4cbc652ea16032f8000 | Ruby | shanbhardwaj/faceted-search | /app/models/retailer_ledger.rb | UTF-8 | 3,362 | 2.6875 | 3 | [] | no_license | class RetailerLedger < ActiveRecord::Base
belongs_to :wine
belongs_to :retailer
# searchable do
# # string :store do
# # :retailer_type
# # end
# latlon (:location) { Sunspot::Util::Coordinates.new(lat, lng) }
# end
searchable do
text(:wine_name, :boost => 5) { wine.wine_name unless wine... | true |
16bdb7d2dddf54574250f01642882c15d8f4cfb9 | Ruby | eknovoa/Programming_Foundations | /Small_Problems/easy_8/madlibs.rb | UTF-8 | 1,138 | 4.40625 | 4 | [] | no_license | =begin
Problem
-create a simple mad-lib program that prompts for a noun, an adverb, and an adjective and injects those into a story
that you create
-madlibs are a simple game where you create a story template with blanks for words. You, or another player,
then construct a list of words and place them into the story, c... | true |
fd468268f39b44ed5a4e1c5127cd46a7a5a04cc8 | Ruby | almirpask/Ruby-sudoku | /ruby_sudoku.rb | UTF-8 | 1,313 | 2.65625 | 3 | [] | no_license | matrix = [
[[],7,[],2,[],3,[],9,[]],
[9,[],[],[],[],[],[],[],8],
[[],[],[],4,[],5,[],[],[]],
[5,[],9,[],[],[],8,[],4],
[[],[],[],[],[],[],[],[],[]],
[4,[],2,[],[],[],7,[],5],
[[],[],[],5,[],6,[],[],[]],
[1,[],[],[],[],[],[],[],2],
[[],6,[],7,[],8,[],3,[]],
]
options = [1,2,3,4,5,6,7,8,9]
matrix.each... | true |
0c912138cede337922164ce7af01c93ffdec94ef | Ruby | JaneEdwMcN/MediaRanker | /app/models/work.rb | UTF-8 | 923 | 2.625 | 3 | [] | no_license | class Work < ApplicationRecord
has_many :votes, dependent: :destroy
validates :title, presence: true, uniqueness: { scope: :category, message: "can only occur once per category" }
validates :creator, presence: true
validates :publication_year, presence: true, numericality: { only_integer: true, greater_than: 0... | true |
75b95ccd13e366c9d21ca1aad918ab456f614d89 | Ruby | nathanmousa/programming-univbasics-4-intro-to-hashes-lab-uci-online-web9-pt-093019 | /intro_to_ruby_hashes_lab.rb | UTF-8 | 418 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
new_hash = {}
end
def my_hash
my_hash = { font_size: 10 }
end
def pioneer
my_hash = { :name => "Grace Hopper" }
end
def id_generator
my_hash = { :id => 4 }
end
def my_hash_creator(key, value)
new = {}
new[key] = value
new
end
def read_from_hash(hash, key)
hash[key]
end
def update_coun... | true |
85d1a5488d2dd156d9938c2ffc7cc3a21cfeab9f | Ruby | brinkar/rubycsp | /test/test_process.rb | UTF-8 | 1,480 | 2.796875 | 3 | [] | no_license | require 'test/unit'
require "csp"
class ChannelTestCase < Test::Unit::TestCase
def test_create_and_run
pd = CSP::Process.define :test do |n|
n + 1
end
assert_raise RuntimeError do
CSP::Process.define :test do |n|
n + 1
end
end
p1 = CSP::Process.new pd, 10
assert (not p1.finished?)... | true |
7e360e96642617934c700ed6e6286c24f5e067a6 | Ruby | DFE-Digital/apply-for-teacher-training | /config/initializers/hesa_disabilities.rb | UTF-8 | 3,345 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module HesaChanges
YEAR_2023 = 2023
end
module HesaDisabilityValues
NONE = 'No known disability'.freeze
MULTIPLE = 'Multiple disabilities'.freeze
LEARNING = 'A specific learning difficulty such as dyslexia, dyspraxia or AD(H)D'.freeze
SOCIAL_OR_COMMUNICATION = "A social/communication impairment such as Asper... | true |
4fed7c7da9705402f411f795b71e767a1ef5c5f0 | Ruby | toddkcarlson/algorithms-bloc | /searching/binary_search_recursive.rb | UTF-8 | 539 | 3.46875 | 3 | [] | no_license | def binary_search(collection, value)
low = 0
high = collection.length - 1
if low <= high
mid = (low + high) / 2
if collection[mid] == value
return value
elsif mid == 0
return "not found"
elsif collection[mid] > value
high = mid - 1
collection.delete_if { |i| i > collect... | true |
8937a244ea3c3dec3c5667c3f5c1ce1eff5d02aa | Ruby | furoshiki/tkm-kj-rcw | /recipe_data.rb | UTF-8 | 824 | 3 | 3 | [] | no_license | class RecipeData
DATA = [
{
id: 1,
name: 'オムライス',
user_name: 'hoge',
discription: '卵を焼いてごはんにのせる'
},
{
id: 2,
name: '親子丼',
user_name: 'kou',
discription: '鶏肉を焼いて卵でとじてごはんにのせる'
},
{
id: 3,
name: '杏仁豆腐',
user_name: 'piyo',
d... | true |
254363c939609f6552124d786d0edcfe1df654f3 | Ruby | VincenzoLaSpesa/evolution-of-trees | /script/benchmark_torneo.rb | UTF-8 | 1,594 | 2.890625 | 3 | [] | no_license | module Enumerable
def sum
self.inject(0){|accum, i| accum + i }
end
def mean
self.sum/self.length.to_f
end
def sample_variance
m = self.mean
sum = self.inject(0){|accum, i| accum +(i-m)**2 }
sum/(self.length - 1).to_f
end
def standard_deviation
return Math.sqrt(self.s... | true |
e2ed00f8afd49a969dee8fbd4afe2e8046d1dc07 | Ruby | jsw2a/Intro-to-Programming | /exercises/9_exercise.rb | UTF-8 | 173 | 3.421875 | 3 | [] | no_license | h = {a:1, b:2, c:3, d:4}
# 1
p h[:b]
#2
h[:e] = 5
p h
#4
h.each do |key, value|
if value < 3.5
puts value.to_s + " less than 3.5"
h.delete(key)
end
end
p h
| true |
c1c7160e405d8e274e876abbd609b292b74fd9a1 | Ruby | jimfoltz/scripts | /find-su.rb | UTF-8 | 610 | 2.84375 | 3 | [] | no_license | # find-su.rb - find and print SketchUp executables on Windows
#
QUOTE = ARGV.delete("-q")
def walk(path, depth, max_depth)
begin
children = Dir.children(path)
rescue => e
#warn e
return
end
if children.include?("SketchUp.exe")
print '"' if QUOTE
print "#{path}"
print '"'... | true |
215f5e310394f9d1fdf2b8beb43660133919726f | Ruby | vidarh/filters | /lib/hokstad-filters/rubyhighlighter.rb | UTF-8 | 684 | 2.59375 | 3 | [] | no_license |
require 'hokstad-filters/filter'
require 'syntax/convertors/html'
class HighlightFilter < Filter
def initialize n = nil
super
@d = ""
@c = nil
@cur = nil
end
def filter line, tag
if !@cur && !tag
pass(line,tag)
return
end
if tag != @cur
do_flush if @cur
if ... | true |
74ec0b18dcfb5ea6f8c044f9fe241bad6f765791 | Ruby | gs-kl/w2-ageist | /ageist-case.rb | UTF-8 | 331 | 3.34375 | 3 | [] | no_license | age = (0..110).to_a.sample
print "Age is #{age}. Age range: "
if age < 1
print "baby"
elsif age < 10
print "child"
elsif age < 12
print "tween"
elsif age < 19
print "teenager"
elsif age < 39
print "adult"
elsif age < 65
print "middle-aged"
elsif age < 100
print "senior"
elsif age < 110
print "record-bre... | true |
d0039f914167aa0935dc79640ee4ca7a3169e5de | Ruby | sarahharrs/ruby-objects-belong-to-lab-online-web-pt-061019 | /lib/song.rb | UTF-8 | 162 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :title, :artist
def initialize(title)
@title = title
end
end
seven_eleven = Song.new ("7/11")
seven_eleven.artist = beyonce
| true |
b713d19943fd2e3be0d0e3a938d4971bfdb3eece | Ruby | Pnlpz/Actividad15 | /1.rb | UTF-8 | 538 | 3.25 | 3 | [] | no_license | # Crear un método que reciba dos strings, este método creará un archivo index.html y
# pondrá como párrafo cada uno de los strings recibidos.
# Crear un método similar al anterior, que además pueda recibir un arreglo. Si el
# arreglo no está vacío, agregar debajo de los párrafos una lista ordenada con cada
# uno de los... | true |
12fd9e09552bc59a08dfc14289c02768d8c7cf8c | Ruby | meddle0x53/reacto | /lib/reacto/operations/drop.rb | UTF-8 | 897 | 2.765625 | 3 | [] | no_license | require 'reacto/constants'
require 'reacto/subscriptions/operation_subscription'
module Reacto
module Operations
class Drop
def initialize(how_many_to_drop, offset = NO_VALUE)
if how_many_to_drop < 0
raise ArgumentError.new('Attempt to drop negative size!')
end
@how_many_... | true |
2f7dee48a4247b25008c5514ee0f8da86134fe3d | Ruby | yvettecook/TwitterTotals | /twitter_totals/app/models/user.rb | UTF-8 | 1,578 | 2.84375 | 3 | [] | no_license | require 'twitter'
require_relative './concerns/twitter_client'
class User < ActiveRecord::Base
include TwitterClient
after_create :on_creation
def twitter_client
@twitter_client ||= self.twitter
end
def twitter_user
@twitter_user ||= twitter_client.user(self.name)
end
def fullname
twitte... | true |
c12ec9fce91f8db693c66574083e567aa92eb289 | Ruby | w11th/ruby_scripts | /last_logins/parse_last_logins | UTF-8 | 1,883 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env ruby -w
require 'yaml'
require 'time'
data_dir = (ARGV[0] || 'data')
raise "couldn't find directory #{data_dir}" unless File.directory?(data_dir)
Dir.chdir(data_dir)
processed_dir = 'processed'
Dir.mkdir(processed_dir) unless File.directory?('processed')
DAY_INDEX = {}
NOW = Time.now
%w(Mon Tue Wed T... | true |
c5ce12d859e35a2e3724c1cee84796e658f47c73 | Ruby | Victor-Hechel/DSII | /bim1/exercicios01.rb | UTF-8 | 1,088 | 3.9375 | 4 | [] | no_license | =begin
exercício 01
numeros = gets.chomp.split(" ")
resultado = 0
i = 0
while i < numeros.size
resultado = resultado + numeros[i].to_i
i = i + 1
end
puts resultado
=end
=begin
exercício 02
numeros = gets.chomp.split(" ")
i = 0
resultado = numeros[0];
while i < numeros.size
if resultado < numeros[i]
resu... | true |
8725a5f82c3a5c810718c289385f54b75ad92063 | Ruby | gulnara/algo_practice | /patterns/dfs/sum_all_paths.rb | UTF-8 | 1,459 | 4.09375 | 4 | [] | no_license | # Given a binary tree where each node can only have a digit (0-9) value, each root-to-leaf path will represent a number. Find the total sum of all the numbers represented by all paths.
class TreeNode
attr_accessor :value, :left, :right
def initialize(value, left=nil, right=nil)
@value = value
@left = left
@... | true |
775b89bfc3f654850c115ca6acc2fa48f7451a00 | Ruby | johnmeehan/EuclideanDistance | /euclidean.rb | UTF-8 | 655 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env ruby
class EuclideanDistance
def initialize(vector1, vector2)
@v1 = vector1
@v2 = vector2
end
def calculate
sum = 0
@v1.zip(@v2).each do |v1, v2|
component = (v1 - v2)**2
sum += component
end
Math.sqrt(sum)
end
end
# limerick = [52.661418, -8.550537]
# dubli... | true |
6cf8b84c0e2de2055f055c05441e7507ddf715b5 | Ruby | vincedevendra/exercism-ruby | /ruby/trinary/trinary.rb | UTF-8 | 292 | 3.53125 | 4 | [] | no_license | class Trinary
INVALID = 0
def initialize(num_string)
@num_string = num_string
end
def to_decimal
return INVALID if @num_string =~ /\D/
result = 0
@num_string.chars.reverse.each_with_index do |char, i|
result += char.to_i * 3**i
end
result
end
end
| true |
e89769a6599ef3dacbb23cbc4f7d754ccc1cd6e7 | Ruby | mnishiguchi/masa_yelp | /lib/yelp/client.rb | UTF-8 | 3,026 | 2.65625 | 3 | [
"MIT"
] | permissive | require "singleton"
module Yelp
class Client
include Singleton
attr_reader :configuration
API_HOST = "https://api.yelp.com".freeze
TOKEN_PATH = "/oauth2/token".freeze
BUSINESSES_PATH = "/v3/businesses/search".freeze
BUSINESS_PATH = ->(id) { "/v3/businesses/#{id}" }
BUSINESS_REVIEWS_PATH ... | true |
ccef2317a14058d44a47cde4110ed14e90a54aef | Ruby | Shaphen/a-A_Classwork | /Week_One/D2/shaphen_rspec_exercise_1_repeat/lib/part_1.rb | UTF-8 | 524 | 4 | 4 | [] | no_license | def average (num1, num2)
(num1 + num2) / 2.0
end
def average_array (arr)
added = arr.inject(0.0) { |acc, num| acc + num }
added / arr.length
end
def repeat (str, num)
new_str = ""
num.times { new_str += str }
new_str
end
def yell (str)
str.upcase + "!"
end
def alternating_case (sen... | true |
c42a12be36bb7af7cad2d079983f98eade425b3e | Ruby | marfarma/repo_man | /app/models/scm.rb | UTF-8 | 971 | 2.59375 | 3 | [
"MIT"
] | permissive | class Scm
SUPPORTED_SCM = %w(git svn)
def self.create(scm_type, path)
case scm_type
when 'svn'
!File.exist?("#{SITE['svn_root']}/#{path}") && system("sudo #{SITE['svn_script']} #{path}")
when 'git'
!File.exist?("#{SITE['git_root']}/#{path}.git") && system("sudo #{SITE['git_script']} #{path}... | true |
1a62f7bd43c8398a761a8b13f2f1bb28ef7e6f94 | Ruby | afleisch/Grokkie | /db/seeds.rb | UTF-8 | 6,863 | 2.6875 | 3 | [] | no_license | users = []
category = []
skill = []
roadmap = []
resources = []
# users << User.create(username: 'mbetts7', email: 'mbetts7@gmail.com', password: 'password', password_confirmation: 'password')
# users << User.create(username: 'Finn789', email: 'FinnMurray@rhyta.com', password: 'password', password_confirmation: 'passw... | true |
854a706d76105b22cb0eb0b1fea4888df2a0b7c7 | Ruby | kg-coderta/atcoder | /abc/117.rb | UTF-8 | 190 | 3.25 | 3 | [] | no_license | A
a,b = gets.split.map(&:to_f)
p a/b
B
a = gets.to_i
b = gets.split.map(&:to_i).sort
sum = 0
for num in 0..a-2 do
sum += b[num]
end
if sum > b[-1]
puts "Yes"
else
puts "No"
end
C
D
| true |
ad9012cc95edd430cc1ac5415e125f45c5ed6a4e | Ruby | PCiobanita/OOP_Zoo | /mammals/bat.rb | UTF-8 | 459 | 3.21875 | 3 | [] | no_license | require_relative '../animal_types/mammals'
class Bat < Mammal
def eat
puts 'i drink blood dont ask me why. My dad is dracula or so he thinks'
end
def speak
puts 'i dont realy speak'
end
def traits
puts 'I dont see but send sound which reflects back, i lissen to it and thats how i know my obsta... | true |
ba9658a27e6e8c0e6e2d1bc82a357ae332285aa9 | Ruby | Asadhjafri/ruby-enumerables-generalized-map-and-reduce-lab-nyc-web-030920 | /lib/my_code.rb | UTF-8 | 365 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map(source)
own_map = []
i = 0
while i < source.length
own_map.push(yield(source[i]))
i += 1
end
own_map
end
def reduce(source, starting_point = nil)
if starting_point
total = starting_point
i = 0
else
total = source[0]
i = 1
end
while i < source.length
total = yield(... | true |
35503ba68a50732cbf9c7f463313c2c83b3d15a5 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/e06f6daa912b45d892ac94e529fd685f.rb | UTF-8 | 329 | 3.21875 | 3 | [] | no_license | class Raindrops
def self.convert(input)
result = ''
return input.to_s unless (input % 3 === 0 || input % 5 === 0 || input % 7 === 0)
if (input % 3 === 0)
result << 'Pling'
end
if (input % 5 === 0)
result << 'Plang'
end
if (input % 7 === 0)
result << 'Plong'
end
return result
e... | true |
0e02a24a2604e4ab60550e8c7835937e2af56b8b | Ruby | justinpaulson/advent-of-code-2019 | /day_4.rb | UTF-8 | 1,041 | 3.1875 | 3 | [] | no_license | first_point = 125730
second_point = 579381
def passes_dup_test(num)
nums = num.to_s.split('')
smallest = nums[0]
nums.drop(1).each do |n|
return true if n == smallest
smallest = n
end
false
end
def passes_seq_test(num)
nums = num.to_s.split('')
smallest = nums[0]
nums.each do |n|
return fa... | true |
839fdf79346f1858f55fb3e921337ba33afd4e0c | Ruby | hugomtr/morpion_POO | /lib/game.rb | UTF-8 | 2,736 | 3.3125 | 3 | [] | no_license | #c'est le jeu. Elle initialise tout, lance une partie
#(qui se termine avec une victoire ou un nul), permet de jouer un tour, de chercher si la partie est finie, etc.
require 'bundler'
Bundler.require
require_relative 'board'
require_relative 'player'
require_relative 'show'
class Game
attr_accessor :board, :pla... | true |
4041b40c31bcb4e0fa684da3504347c049bc1300 | Ruby | AJDot/Launch_School_Files | /Exercises/Ruby_Basics/Loops_2/catch_the_number.rb | UTF-8 | 233 | 3.921875 | 4 | [] | no_license | # Modify the following code so that the loop stops if number is between 0 and 10.
# loop do
# number = rand(100)
# puts number
# end
# ANSWER
loop do
number = rand(100)
puts number
break if number < 10 && number > 0
end
| true |
566464a2d1ee8c0886d214a43ae2a01faaf304c1 | Ruby | Gansito144/competitive-programming | /online-judges/hackerrank/fibonacci-modified.rb | UTF-8 | 236 | 3.4375 | 3 | [] | no_license | ##########
# * Author: Ulises Mendez Martinez
# * Mail: ulisesmdzmtz@gmail.com
# * Solution: DP to calculate fibonacci
##########
a, b, n = gets.strip.split(/\s+/).map(&:to_i)
fib = [a,b]
for i in 2...n
fib[i] = fib[i-1] * fib[i-1] + fib[i-2]
end
puts fib[n-1]
| true |
0f1beebfca4fec92e9623a01322595a94dc43781 | Ruby | pedz/Raptor | /lib/json_common.rb | UTF-8 | 3,474 | 2.546875 | 3 | [] | no_license | module JsonCommon
# Sends the item, which may be an array, as json but also calls
# async_fetch on either the item or (in the case item is an
# array) each element of item.
def json_send(item, cache_options = { }, json_options = { })
if item.is_a?(Array) || item.is_a?(Combined::AssociationProxy)
time_... | true |
4f8ea5a2d73d9c7b3f0a90d7f6d6bb91ff80781c | Ruby | gjmorale/lets_web | /lets/test/models/product_test.rb | UTF-8 | 3,002 | 3.015625 | 3 | [] | no_license | require 'test_helper'
class ProductTest < ActiveSupport::TestCase
def setup
@product = Product.new(name: "Piscola Coca-Normal", description: "Pisco + Coca Normal con Hielo", min_age: 18, grants_admission: 0, admission_level: 1)
end
test "should be valid" do
@product.name = "12345abc"
@product.descrip... | true |
7abde20fd75de6e6b0636bdf4921a631dfa7571f | Ruby | slijtan/practice_problems | /coursera/algorithms_1/week4/scc.rb | UTF-8 | 2,031 | 3.234375 | 3 | [] | no_license | require "benchmark"
input = ARGV[0]
$adj_list = Hash.new {|h, k| h[k] = [[], []]} #zero element is adjacency list, first element is reverse adjacency list
time = Benchmark.realtime do
File.open(input) do |f|
while i = f.gets
values = i.split(" ").map(&:to_i)
if values[1]
$adj_list[values[0]... | true |
02c649b94e0ff2c15b09c8b969b0daf12e52c932 | Ruby | IgorLeonenko/calories_calc | /app/models/product.rb | UTF-8 | 1,060 | 2.671875 | 3 | [] | no_license | class Product < ActiveRecord::Base
TYPES = %w(fat protein carbohydrate)
validates :name, :calories_per_hundred_grams,
:product_type, presence: { message: "Должно быть заполнено" }
validates :calories_per_hundred_grams, numericality: { message: "Только цифры" }
validates :product_type, inclusion: { ... | true |
9b12fc423b8e9887d373b36cbb79a25d427fcc94 | Ruby | therealadam/Sketches | /mongo_record/mongo_engine.rb | UTF-8 | 2,148 | 2.65625 | 3 | [] | no_license | require 'rubygems'
$LOAD_PATH << "/Users/adam/dev/sources/ruby/arel/lib"
require 'arel'
require 'mongo'
require 'pp'
# Not entirely sure if I should define this myself
Column = Struct.new(:name)
class MongoEngine
# ==================
# = Mongo-specific =
# ==================
def db
@conn ||= Mongo::... | true |
42a49fd6b62273ca92d9fbd1d7030dc6425df938 | Ruby | stephsen/lrthw | /ex6.rb | UTF-8 | 931 | 4.09375 | 4 | [] | no_license | #affect numeric value to types_of_people variable
types_of_people = 10
#affect string value to x variable
x = "There are #{types_of_people} types of people."
#affect string value to binary variable
binary = "binary"#
#affect string value to do_not variable
do_not = "don't"
#affect string value and variable binary to y ... | true |
2e301af4c0d04e7c67e52239ff564c7e20707f4a | Ruby | sabtain93/rb_101_small_problems | /easy_9/06.rb | UTF-8 | 1,635 | 4.625 | 5 | [] | no_license | =begin
# Problem:
- Input: a string
- may be an empty string
- words constitute any substring of non-space characters
- words are separated by exactly one space
- Output: an array
- each element is a word from the input string + ' ' and the length of the word (a number)
- an empty string returns... | true |
fcb053e0149386665f41aa4be33eae72a3139f8b | Ruby | takada-at/cudan | /lib/cudan/logger.rb | UTF-8 | 210 | 2.75 | 3 | [] | no_license | class Cudan::Logger
@@level = 7
def self::setlevel level
@@level = level
end
def self::log(message, level=7)
if level <= @@level
puts message
end
end
end
| true |
e75bbec5b2ed704c1016ebd261b04ed7bce59708 | Ruby | kkurcz/rails-wallet | /test/models/transaction_test.rb | UTF-8 | 3,498 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class TransactionTest < ActiveSupport::TestCase
def setup
@wallet = wallets(:kev_household_wallet)
@sender_wallet = wallets(:kev_household_wallet)
@receiver_wallet = wallets(:sara_business_wallet)
# .yml file for transactions didn't work due to sender and receiver wallet so wro... | true |
c5b57c71bef66391b896957162801d45ed9357e8 | Ruby | TuftsUniversity/tufts-election | /app/models/state.rb | UTF-8 | 415 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
class State
attr_reader :name, :history, :bibliography
@states = {}
def initialize(attrs = {})
@name = attrs.fetch(:name)
@history = attrs.fetch(:history, '')
@bibliography = attrs.fetch(:bibliography, '')
end
def self.register(state_attrs)
@states[state_attrs.... | true |
19ce702985683126be4a890d08eb115fb482706b | Ruby | ssy23ssy/ssrlikelion | /app/models/post.rb | UTF-8 | 2,603 | 2.96875 | 3 | [] | no_license | class Post < ApplicationRecord
has_many :comments, dependent: :destroy
belongs_to :user
self.per_page = 5
# 최신순 정렬
# def self.recent
# order(created_at: :desc)
# end
scope :recent, -> { order(created_at: :desc) }
# 다음 게시글 아이디
def self.get_next_post(current_id)
where("id > ?", current_id).fi... | true |
4163484602546b3b6f946826f1199de4c2bc5c3e | Ruby | IDme/before_filters | /spec/before_filters_spec.rb | UTF-8 | 765 | 3.234375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class TestClass
extend BeforeFilters
attr_accessor :first_name
attr_accessor :last_name
# first arg is method to be called, second is array of methods that will have the before_filter ran
# prior to calling the first arg
before_filter :set_first_name, :only => [:set_last_name]
d... | true |
6642157b037a5c5d5ed329596f998f9969ffd589 | Ruby | wemrekurt/Ruby | /odev9/alpha.rb | UTF-8 | 989 | 3.796875 | 4 | [] | no_license | require 'stemmify'
class WordCounter
# Veriler sınıfa alınır
def initialize text,stop,range
@range = range
@text = File.read text
@stop = File.readlines stop
end
# Metindeki boşluklar ve stp'deki kelimeler temizlenir
def clear
s = @stop.map { |v| v.gsub /[\n\t]/,''}
@text.split... | true |
87e700ea1d40bb58892258e4c81a68febdf47782 | Ruby | benrodenhaeuser/exercises | /ruby_exercises/02_Reading_Documentation/02.rb | UTF-8 | 530 | 3.84375 | 4 | [] | no_license | # use Array#insert to insert 5, 6 and 7 between c and d in array below:
# signature of insert: insert(index,obj...) -> ary
# so we need to put the index where we want to insert as the first argument to insert
# second argument will be the number we want to insert
# and the method call will change the original array
a... | true |
1402d7c8de7b8f74f8c9b8da59d32fe4fc11938d | Ruby | fuzzyalej/fabes | /lib/fabes/experiment.rb | UTF-8 | 1,450 | 2.8125 | 3 | [
"MIT"
] | permissive | module Fabes
class Experiment
attr_accessor :name, :description, :alternatives
def initialize(name, *alternatives)
@name = name
@alternatives = alternatives.map do |alternative|
Fabes::Alternative.new alternative
end
save
end
def self.find_or_create(name, *alternative... | true |
c50f5539fa3ef21010e48a43a5a508e2b4da9f1d | Ruby | tcaddy/ror_playground | /app/models/artist.rb | UTF-8 | 2,179 | 2.59375 | 3 | [] | no_license | # Artist model
class Artist < ActiveRecord::Base
has_many :albums, dependent: :destroy
validates :name, presence: true, uniqueness: true
scope :created_in_last_minute, -> { where('created_at >=?', Time.now.advance(minutes: -1)) }
scope :over_1_day_old, -> { where('created_at <= ? and updated_at <= ?', Time.now... | true |
a67e407ad6a0e0e731fc0a62d6eba839e6913bd7 | Ruby | tarikkdiry/SSW215 | /A02/rational.rb | UTF-8 | 822 | 4.125 | 4 | [] | no_license | #Tarik Kdiry and Oscar Tavara
#I pledge my honor that I have abided by the Stevens Honor System. Tarik Kdiry
puts "Give me your first numerator!"
num1 = gets.to_f
puts "Give me your first denominator!"
den1 = gets.to_f
puts "Give me your second numerator!"
num2 = gets.to_f
puts "Give me your second denominator!"
den... | true |
665f02cc9df4837bb18712b38f12cba656012e3f | Ruby | nerab/cardgame | /lib/cardgame/cards/trump.rb | UTF-8 | 542 | 3.125 | 3 | [] | no_license | module CardGame
module Cards
class Trump < Card
# When playing a trump card, it's the player who decides which suit it has, so that the next player has to follow it
attr_accessor :suit
def initialize(rank, score)
super(rank, score)
end
def trump?
true
end
... | true |
bc07f4c02206de7adc32ccb7db60ff81e6227cc1 | Ruby | francescoagati/php-vm-rspec-php-objects | /spec/php-rspec/php-rspec_spec.rb | UTF-8 | 472 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'php_vm'
describe 'test class' do
before(:each) do
@class_code = '
class HelloClass {
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
'
end
it "test for class instance property" do
... | true |
af31318166d59fafb2e25e84436f94b33a4c6cc1 | Ruby | chelseaworrel/mastermind_2.0 | /mastermind_test_2.0.rb | UTF-8 | 3,463 | 3.15625 | 3 | [] | no_license | gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'game'
require_relative 'output'
class BoardTest < Minitest::Test
def test_it_outputs_an_array
board = Board.new
result = board.create_secret
assert_equal Array, board.create_secret.class
end
def test_it_returns_... | true |
78fbef50fc5ad8dae0e50cfd547a1f903a93badc | Ruby | pulibrary/figgy | /app/models/event.rb | UTF-8 | 1,245 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Events track preservation fixity check activities.
# Multiple current Events will correspond to a given PreservationObject if that preservation object has both metadata and binary files.
class Event < Valkyrie::Resource
SUCCESS = "SUCCESS"
FAILURE = "FAILURE"
REPAIRING = "REPAIRIN... | true |
d6ed8871bc204c03ffb328ed907b666980cb1e05 | Ruby | A-Flo/FizzBuzzWithTest | /hw4_flore1an.rb | UTF-8 | 983 | 3.796875 | 4 | [] | no_license | #!/usr/bin/env ruby
# hw_4 FizzBuzz ruby
# Author: Audra Flores
# Created: 21March2016
# Modified: 25March2016
# Changes: made array, fixed getters and setters, and string override
class FizzBuzz
def initialize(x=0)
self.int_num =x
end
def to_s
"The number is #@int_num and the string is #@str_fb"
e... | true |
8822cc48b9c580ca9bc3c569d9fe67f05a052854 | Ruby | takayak/RubyPractice | /practice/18-1drill.rb | UTF-8 | 397 | 3.765625 | 4 | [] | no_license | # puts "hello"[0]
# puts "hello"[-1]
while true do
puts "英単語を入力してください"
input = gets.chomp
ans = input.end_with?("y")
if ans
puts "yです!正解"
puts "================================================"
else
puts "この英単語はyで終わる単語ではありません。"
puts "================================================"
end
... | true |
6237bfe5a5e7df6942608087a1d1f4ef062f1a4b | Ruby | ravisraval/AlgoPractice | /count_pal_substrings.rb | UTF-8 | 1,039 | 3.875 | 4 | [] | no_license | require 'set'
def count(s)
res = Set.new
s.chars.each_with_index do |ch, idx|
left_idx = idx
right_idx = idx
until left_idx == 0 && right_idx == s.length - 1
substring = s[left_idx..right_idx]
if substring == substring.reverse
res << substring
# check left
unless l... | true |
bfe5310ee6b34436354b3ab11932258f05e378e6 | Ruby | sarahclintonbaker/contactlist | /contact_database.rb | UTF-8 | 1,416 | 3.109375 | 3 | [] | no_license | require 'csv'
class ContactDatabase
class << self
def initialize
@contact_list = []
CSV.readlines('contacts.csv').each do |contact|
phone_numbers = []
name = contact[0]
email = contact[1]
contact[2..-1].each do |phone|
parts = phone.split(":")
t... | true |
836361e9cb5e5f411d14c1b3733bd3d3fd429ade | Ruby | luthfianto/spoj | /ACPC10A.rb | UTF-8 | 225 | 3 | 3 | [] | no_license | while (baris=gets.split.map(&:to_i)) != [0,0,0]
if baris[1] - baris [0] == baris[2] - baris [1] then
print "AP ", baris[2] + (baris[1] - baris[0]), "\n"
else
print "GP ", baris[2] * (baris[1] / baris[0]), "\n"
end
end
| true |
f748d367d51cbda3ece9b740aed61afed2a02c64 | Ruby | seidelmaycon/mars-rovers-ruby | /lib/direction/east.rb | UTF-8 | 211 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
class East < Direction
def to_forward(current_location)
x = current_location[0]
y = current_location[1]
[x.to_i + 1.to_i, y.to_i]
end
def to_s
'E'
end
end
| true |
eb294178dfc46e1471a54700265916813363c69b | Ruby | andrewsong90/PickMeUp | /app/helpers/events_helper.rb | UTF-8 | 1,791 | 2.828125 | 3 | [] | no_license | module EventsHelper
def display_text(pmu)
if pmu.is_driving?
return "<strong>" + pmu.owner.name + "</strong>" + " is driving. "
elsif pmu.is_cab_sharing?
return pmu.owner.name + " is organizing a cab sharing. "
elsif pmu.car_sharing == true and pmu.cab_sharing == true
return pmu.owner.na... | true |
9c95cf8fd36dd0aee4ed7d5dea8bd940d35e89d2 | Ruby | Em-Arce/StockTradingApp | /app/models/trade.rb | UTF-8 | 1,157 | 2.875 | 3 | [] | no_license | class Trade < ApplicationRecord
belongs_to :stock
belongs_to :user
TYPES = %w(buy sell)
validates_numericality_of :quantity, only_integer: true
validates :direction, :inclusion => {:in => TYPES}
def get_total_quantity(current_user)
self.trades = User.find(current_user.id)
#binding.pry
self.tra... | true |
54cb1b289ce88875dae74864e769c017accced46 | Ruby | Albin-Willman/advent | /2017/5/task.rb | UTF-8 | 817 | 3.734375 | 4 | [] | no_license |
class InstructionParser
attr_accessor :steps, :index, :manipulation_computer
def initialize(manipulation_computer)
@manipulation_computer = manipulation_computer
end
def run(input)
steps = 0
@index = 0
input = input.clone
loop do
step(input)
... | true |
48082e3e594c6573dc3837a690eb1e3ce570e00e | Ruby | jortenberg/wdi_project_two | /starter_code/seeds.rb | UTF-8 | 951 | 2.5625 | 3 | [] | no_license | require 'pry'
require_relative './db/connection'
require_relative './lib/category'
require_relative './lib/contact'
Category.delete_all
Contact.delete_all
friends = Category.create(name: "friends")
family = Category.create(name: "family")
Contact.create(name: "Nancy Kaufer", age: 30, address: "20 Pine Street, Woodme... | true |
bb967f8d62a011d2a06b53b9a544ca29f79c2738 | Ruby | Takokaro/beachef | /test/models/dish_type_test.rb | UTF-8 | 957 | 2.5625 | 3 | [] | no_license | # == Schema Information
#
# Table name: dish_types
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
# updated_at :datetime not null
#
require 'test_helper'
class DishTypeTest < ActiveSupport::TestCase
# valid... | true |
53587adf17e9f2de033bbb0763ddae1838f526e3 | Ruby | amirsalaar/blog-on-rails | /db/seeds.rb | UTF-8 | 1,563 | 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 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 |
d6df02e683cb6dd022501d65f8313d454521d8ef | Ruby | Dimcha/boatyard | /lib/boatyard/route.rb | UTF-8 | 304 | 3.203125 | 3 | [
"MIT"
] | permissive | class Route
attr_reader :from, :to, :distance
attr_accessor :visited
def initialize(from, to, distance = 0)
@from = from
@to = to
@distance = distance
@visited = false
end
def connected_routes(routes)
routes.select { |route| route.from == to && !route.visited }
end
end
| true |
b61b73aa3354d7741c45aca1c782583756343091 | Ruby | globewalldesk/Mastermind | /test/test_game.rb | UTF-8 | 3,421 | 3.1875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../lib/game'
require_relative '../helpers/helper'
include Helper
class GameTest < Minitest::Test
def test_initializes_game_hash_when_blank
gamehash = Game.new
assert_kind_of(Game, gamehash)
end
# Does the gamehash have a codelength of 3? Sets a policy.
def... | true |
a59aff985e9de7605494280d3e24196453b2670a | Ruby | environmental/dry-initializer | /lib/dry/initializer/mixin.rb | UTF-8 | 1,599 | 2.625 | 3 | [
"MIT"
] | permissive | module Dry::Initializer
# Class-level DSL for the initializer
module Mixin
# Declares a plain argument
#
# @param [#to_sym] name
#
# @option options [Object] :default The default value
# @option options [#call] :type The type constraings via `dry-types`
# @option options [Boolean] ... | true |
81a8478a2fdbac62db11d478b055537d33a22ee3 | Ruby | remyamavila/knife-cookbook-readme | /lib/knife_cookbook_readme/readme.rb | UTF-8 | 1,333 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | module KnifeCookbookReadme
DEFAULT_CONSTRAINT = ">= 0.0.0".freeze
class Readme
def initialize(metadata)
@metadata = metadata
end
def title
"#{@metadata.name.capitalize} Cookbook"
end
def description
@metadata.description
end
def platforms
@metadata.platforms.m... | true |
a99531377503c20e8b943f762e401b13a1b178e4 | Ruby | tnordloh/toll_free | /spec/find_words_spec.rb | UTF-8 | 444 | 2.796875 | 3 | [] | no_license | require "minitest/autorun"
require_relative "../lib/toll_free/find_words"
describe TollFree::FindWords do
it "can find subwords from the dictionary" do
findwords = TollFree::FindWords.new("23")
findwords.possibilities.must_equal(%w[ad ae be ce ])
end
it "can turn list of words into strings" do
find... | true |
a1c4fd045f27a24560fcf0fc1b89c8f18a96b681 | Ruby | seoanezonjic/sys_bio_lab_scripts | /create_metric_table.rb | UTF-8 | 1,062 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
metric_file = ARGV[0]
fixCols = ARGV[1].split(',')
output = ARGV[2]
name_tag = fixCols.shift
fixColNumber = fixCols.length
hash = {}
varTags = []
File.open(ARGV[0]).each do |line|
line.chomp!
fields = line.split("\t")
name = fields.shift
fixFields = fields[0..fixColNumber-1]
varFields = fiel... | true |
69ba3e32646689ede50d085442874782c664b2f5 | Ruby | dorianwolf/sinatra_songs_wall | /app/actions.rb | UTF-8 | 2,537 | 2.5625 | 3 | [] | no_license | # Homepage (Root path)
helpers do
def current_user
if session[:id] and user = User.find(session[:id])
user
end
end
def get_comments(id)
output = []
all_reviews = Review.all.order(updated_at: :desc)
output = all_reviews.where song_id: id
end
def not_reviewed(user_id, song_id)
no_... | true |
b2e1e1c0b228eb297df7e254e3c92c24fab0e924 | Ruby | LaunchPadLab/decanter | /spec/decanter/parser/boolean_parser_spec.rb | UTF-8 | 1,452 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'BooleanParser' do
let(:parser) { Decanter::Parser::BooleanParser }
describe '#parse' do
trues = [
['number', 1],
['string', 1],
['boolean', true],
['string', 'true'],
['string', 'True'],
['string', 'truE']
]
falses = [
['numb... | true |
f9bceaca7f34e24f7482943e3af0e701244e9486 | Ruby | ssteeg-mdsol/openapi3-generator | /gems/gems/prawn-2.2.2/lib/prawn/utilities.rb | UTF-8 | 994 | 2.859375 | 3 | [
"GPL-3.0-only",
"GPL-2.0-only",
"Ruby",
"Apache-2.0"
] | permissive | # utilities.rb : General-purpose utility classes which don't fit anywhere else
#
# Copyright August 2012, Alex Dowad. All Rights Reserved.
#
# This is free software. Please see the LICENSE and COPYING files for details.
require 'thread'
module Prawn
# Throughout the Prawn codebase, repeated calculations which can b... | true |
8d9926dfe6a67a9d3e93820a98307b48c2eb3261 | Ruby | mikelikesbikes/advent-of-code-2020 | /day-16/day_spec.rb | UTF-8 | 778 | 2.8125 | 3 | [] | no_license | require "rspec"
require_relative "./day"
describe "day" do
let(:input) do
parse_input(<<~INPUT)
class: 1-3 or 5-7
row: 6-11 or 33-44
seat: 13-40 or 45-50
your ticket:
7,1,14
nearby tickets:
7,3,47
40,4,50
55,2,20
38,6,12
INPUT
end
let(:actual... | true |
fd4c85f83dff471f5b845736cbaa56072628e084 | Ruby | ddippolito/vedeu | /lib/vedeu/support/queue.rb | UTF-8 | 382 | 2.703125 | 3 | [
"MIT"
] | permissive | module Vedeu
module Queue
extend self
def dequeue
store.pop
end
def enqueue(result)
store.unshift(result)
end
def enqueued?
store.size > 0
end
def size
store.size
end
def clear
store.clear
end
def view
store.inspect
end
... | true |
7e9a43e358000207d4777b338b47b6593eac99f8 | Ruby | CargoSquare/cargo_square | /lib/phone_number_handler.rb | UTF-8 | 297 | 2.90625 | 3 | [] | no_license | module PhoneNumberHandler
def self.format_phone_number(phone_number)
# Purify
phone_number = self.pure_phone_number(phone_number)
# TODO format phone number
return phone_number
end
def self.pure_phone_number(phone_number)
return phone_number.gsub(/[^0-9]/, '')
end
end
| true |
3fa11b7e04f94bd6e9d375d9db284b6c557444ad | Ruby | shts/keyakifeed2-api | /create_members.rb | UTF-8 | 2,907 | 2.671875 | 3 | [] | no_license | # URLにアクセスするためのライブラリを読み込む
require 'open-uri'
# HTMLをパースするためのライブラリを読み込む
require 'nokogiri'
require_relative 'app'
require_relative 'useragent'
Max = 34
BaseUrl = "http://www.keyakizaka46.com"
# http://www.keyakizaka46.com/mob/arti/artiShw.php?cd=01
BaseProfileUrl = "http://www.keyakizaka46.com/mob/arti/artiShw.php?c... | true |
f8cd704e7974fc435b08c2ff9c98445b27a77482 | Ruby | ShockingBlue/lywMDDToolChain | /SourceCodeGeneration/code_logic_tree.rb | UTF-8 | 1,304 | 2.625 | 3 | [
"MIT"
] | permissive | require './statement_ast'
require './cpp_code_generator'
# Logic Tree is more likely a AST for method
# It relies on Code generator to tranlate into realy language like C/C++/Python/PlanUML/lywSTM...
# TODO: creat_cpp_structure_node/CppOperation will be replaced by some other method
# for a generic Laugu... | true |
da384c4619629ed91912a9e91e7f6ee10ff4f16f | Ruby | wonda-tea-coffee/yukicoder | /83.rb | UTF-8 | 91 | 3.109375 | 3 | [] | no_license | n = gets.chomp.to_i
if n % 2 == 0
puts '1' * (n/2)
else
puts '7' + '1' * ((n-3)/2)
end | true |
2cdad405cc47fa2845749147ecf994289b001338 | Ruby | CodingDojoDallas/ruby_dec_16 | /Smith_Ben/Assignments/Ruby/OOP/practice/requireAnimal/mammal.rb | UTF-8 | 156 | 3.359375 | 3 | [] | no_license |
class Mammal
attr_accessor :alive
def initialize
@alive = true
puts "I am alive!"
self
end
def breathe
puts 'Inhale and exhale'
self
end
end | true |
97eebec5a9e3bd99dfb3abddcf2935a0cce6d6fd | Ruby | gja/musterb | /lib/musterb/object_extractor.rb | UTF-8 | 269 | 2.953125 | 3 | [
"MIT"
] | permissive | class Musterb::ObjectExtractor
attr_reader :parent, :value
def initialize(value, parent)
@value = value
@parent = parent
end
def [](symbol)
if @value.respond_to? symbol
@value.send(symbol)
else
@parent[symbol]
end
end
end | true |
58a0338f93e24d1fd388ffe8cea585a1949b2e3b | Ruby | 128keaton/siriproxy-minecraft-server-checker | /lib/siriproxy-MCS.rb | UTF-8 | 1,871 | 2.6875 | 3 | [] | no_license | require 'cora'
require 'siri_objects'
require 'pp'
require 'sockit'
#######
# This is a "hello world" style plugin. It simply intercepts the phrase "test siri proxy" and responds
# with a message about the proxy being up and running (along with a couple other core features). This
# is good base code for other plugins.
... | true |
8dd47c9d61c3d3b0fa810ad146d8716b6eac4d3f | Ruby | bcoffin9/odin-ruby | /substrings.rb | UTF-8 | 872 | 3.734375 | 4 | [] | no_license | DICTIONARY = ["superior", "magical", "quick", "remarkable", "skyrocket", "stressed", "judgemental", "authoritative", "condescending", "wicked", "corrupting", "aggressive", "easy", "genuine", "realiable", "honest", "secure", "blissful", "gratified", "jovial", "world", "liberated", "thrilled", "pleased", "bright", "upbea... | true |
7d6e57913edb936381dc0514b790f070b78b589a | Ruby | eyi1/Property-Listings-App | /app/controllers/sub_controllers/users_controller.rb | UTF-8 | 2,230 | 2.5625 | 3 | [] | no_license | require 'rack-flash'
class UsersController < ApplicationController
use Rack::Flash
get '/users/:id' do
authenticate_user
@user = User.find_by_id(params[:id])
erb :'/users/index'
end
get '/users/:id/properties' do
authenticate_user
@user = User.find_by_id(param... | true |
5379ca5916a67da7e5c1af378814707ff4b52f33 | Ruby | ahk/surrender | /spec/task_spec.rb | UTF-8 | 2,603 | 2.859375 | 3 | [] | no_license | require File.dirname(__FILE__) + '/spec_helper'
describe Surrender::Task do
before :each do
@task = Surrender::Task.new sooner_time, later_time, 'text'
@ripe_msg = Surrender::Message::Reminder.new("reminder", 600)
@ripe_msg.ticks = 600 # ripen the message
end
it "creates multiple tasks from YAML"... | true |
91054a1c1ddcbdf76eec8c54601965943054ceb9 | Ruby | olleolleolle/cxxproject | /lib/cxxproject/buildingblocks/has_dependencies_mixin.rb | UTF-8 | 2,585 | 2.671875 | 3 | [
"BSD-2-Clause"
] | permissive | module Cxxproject
module HasDependencies
def dependencies
@dependencies ||= []
end
def helper_dependencies
@helper_dependencies ||= []
end
def convert_named_values_to_string(values)
values.map { |v| v.instance_of?(String) ? v : v.name }
end
def set_dependencies(deps)
... | true |
8430e50169d89441ead2f390c650ee5c384c68e9 | Ruby | jonleung/switchr | /app/models/device.rb | UTF-8 | 1,167 | 2.625 | 3 | [] | no_license | class Device < ActiveRecord::Base
has_many :certs
has_many :users, :through => :certs
@@r = Random.new
def set_defaults(first_char)
begin
code = first_char + @@r.rand(10000000...99999999).to_s
end while Device.find_by_code(code).present?
self.code = code
self.desired_state ... | true |
411ad47e768b78ed754f6e24b8c78c70b26aea41 | Ruby | k3ntako/super-tic-tac-toe | /spec/lib/medium_strategy_spec.rb | UTF-8 | 6,386 | 3.109375 | 3 | [] | no_license | require_relative '../../lib/medium_strategy'
RSpec.describe MediumStrategy do
let(:medium_strategy) { MediumStrategy.new }
describe 'get_move' do
it 'should return middle if available' do
board = Board.new(width: 3)
expect(medium_strategy.get_move(board: board)).to eq 5
end
it 'should ret... | true |
1fa8513666f3e51a2a73ce956f996dac13e74da5 | Ruby | kat-star/blood-oath-relations-sf-web-091619 | /app/models/cult.rb | UTF-8 | 1,628 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cult
attr_reader :name, :location, :founding_year, :slogan, :age
attr_accessor :follower, :age
@@all = []
def initialize(name, location, founding_year, slogan)
@name = name
@location = location
@founding_year = founding_year
@slogan = slogan
self.class.all << self
end
def recrui... | true |
556026174496ea2fb0e97bc7cc3208dfeba5eced | Ruby | misson20000/ldjam-discord-bot | /genericbot.rb | UTF-8 | 2,548 | 2.84375 | 3 | [] | no_license | require "discordrb"
bot = Discordrb::Commands::CommandBot.new token: "<insert token here>", client_id: <insert client id here>, prefix: "!"
puts "Invite URL is #{bot.invite_url}"
class JamEvent
def initialize(channels, json)
@@named_events||= {}
@channels = channels
@title = json["title"]
@tim... | true |
efd508943769ec071cbd52f4b092ac9d77b219d0 | Ruby | Narscor/ltp | /ltp_chapter7/ltp7_grandma.rb | UTF-8 | 883 | 4.28125 | 4 | [] | no_license | # Chris Pine's Learn to Program book (p. 49), Chapter 7 Exercise
# Deaf Grandma
puts "HELLO SONNY! GREET GRANDMA 'HAPPY GRANDMA\'S DAY!'"
while true
said = gets.chomp
if said == 'BYE'
puts 'BYE SONNY!'
break
end
if said != said.upcase
puts 'HUH?! SPEAK UP, SONNY!'
else
random_year = 1... | true |
8818b334b6073b82e95e01a5edc34e71297baf2c | Ruby | ljtinney/reverse-each-word-pca-001 | /reverse_each_word.rb | UTF-8 | 283 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence1)
words_array = sentence1.split(" ")
fresh_array = []
fresh_array = words_array.collect {|word| word.reverse }
fresh_array.join(" ")
end
# First solve it using .each
# Then utilize the same method using .collect to see the difference. | true |
18051c3e282c7aeb3963fb579efbee4d98a650a9 | Ruby | Rahul-Krishnan/challenges | /guessing_game/code.rb | UTF-8 | 723 | 4.15625 | 4 | [] | no_license | require 'pry'
#Ask for difficulty
puts "Welcome to the Guessing Game! Would you like this to be EASY or HARD?"
print "> "
difficulty = gets.chomp.downcase
#error check
while difficulty!="easy" && difficulty!="hard" do
puts "Please give me a real answer!"
difficulty = gets.chomp.downcase
end
#set difficulty
if di... | true |
85b633aaabc213c327c8b731ee4f1d155975b0de | Ruby | chef/artifactory-client | /lib/artifactory/resources/certificate.rb | UTF-8 | 2,636 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | module Artifactory
class Resource::Certificate < Resource::Base
class << self
#
# Get a list of all certificates in the system.
#
# @param [Hash] options
# the list of options
#
# @option options [Artifactory::Client] :client
# the client object to make the requ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.