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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
028e49bd329ab3f18f8f23c537e417e688281a33 | Ruby | gijs/popHealth | /app/models/user.rb | UTF-8 | 3,977 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'uniq_validator'
class User < MongoBase
include ActiveModel::Conversion
add_delegate :password, :protect
add_delegate :username
add_delegate :first_name
add_delegate :last_name
add_delegate :email
add_delegate :company
add_delegate :company_url
add_delegate :registry_id
add_delegate :r... | true |
501d37c2461fd8996512a3183ca8e800e8079612 | Ruby | ezmac/gatling_talk | /lotek/uri_stats.rb | UTF-8 | 3,317 | 2.609375 | 3 | [] | no_license | require './log_parse'
require 'pry'
require 'colorize'
# Parse the command line
src_access_log=""
options = {}
begin
opts = OptionParser.new
opts.banner = "Usage: #{$PROGRAM_NAME} [options] ..."
opts.separator ''
opts.separator 'Options:'
opts.on('-s src_access_log',
'--src_access_log src_access_lo... | true |
e97d95286c86497e13ae9790c7adf3f7f6df7e31 | Ruby | vdmgolub/kloudless-ruby | /lib/kloudless/http.rb | UTF-8 | 3,021 | 2.65625 | 3 | [
"MIT"
] | permissive | require "net/http"
require "json"
module Kloudless
# Net::HTTP wrapper
class HTTP
# Public: Headers global to all requests
def self.headers
@headers ||= {}
end
def self.request(method, path, params: {}, data: {}, headers: {},
parse_request: true, parse_response: true)
... | true |
db7a5d0cb1653844e027fd14a7bc6a4e0eaf8f65 | Ruby | ylluminarious/comp_science_ecot | /bubble_sort/main.rb | UTF-8 | 1,207 | 4.3125 | 4 | [] | no_license | def bubble_sort(array, length)
# The loop that iteratively goes through the array and sorts it
array.each do |element|
# Some pretty self-explanatory variables
current_element = array.index(element)
next_element = current_element + 1
# The first check is to make sure that the current element... | true |
b17b1a73f75b8e49ee402afdc3e10b0cef2e2cde | Ruby | hivehand/util | /jj | UTF-8 | 443 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby -w
# Pretty-print JSON input from a file, or stdin.
require 'json'
# To do (maybe):
# - Add an option to insert a splitting line between the prettifications of
# multiple sources. (Easy.)
# - Add an option to convert multiple sources into a single array.
# (Trickier, but doable.)
inp... | true |
f8ecfca9054b9bab0224e5c5a1dfccf33495122f | Ruby | Daniel-Muriano/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 201 | 3.359375 | 3 | [] | no_license | def add (a,b)
a+b
end
def subtract(a,b)
a-b
end
def sum(a)
b=a.length
i=0
c=0
while (i<b)
c=c+a[i]
i=i+1
end
c
end
def multiply (a,b)
a*b
end
| true |
e615a89a616d712aaa8f7c8351415beb196bfd02 | Ruby | grinchrb/grinch | /lib/cinch/rubyext/module.rb | UTF-8 | 601 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Extensions to Ruby's Module class.
class Module
# Like `attr_reader`, but for defining a synchronized attribute
# reader.
#
# @api private
def synced_attr_reader(attribute)
undef_method(attribute)
define_method(attribute) do
attr(attribute)
end
define_me... | true |
cbbf03b9688aa631282c5f0581ae60d66a419ac8 | Ruby | mikewagner/ledes_parser | /spec/ledes/parser_spec.rb | UTF-8 | 3,336 | 2.6875 | 3 | [] | no_license | require 'helper'
require 'ledes/parser'
require 'ledes/exceptions'
describe Ledes::Parser do
describe ".new" do
end
describe "#contents" do
let(:file) { fixture(:ledes) }
context "from file" do
before do
@parser = Ledes::Parser.new( file )
end
it "should return contents a... | true |
e468e175d7ae4e5691c4f7bd93cb8d18cba0af47 | Ruby | JamesDawson/TheDivisionGearBrain | /lib/inventory.rb | UTF-8 | 2,538 | 3.078125 | 3 | [] | no_license | require 'oj'
class Inventory
attr_reader :statistics, :required_items, :items, :vests, :masks, :kneepads, :backpacks, :gloves, :holsters
def initialize(data_file)
@statistics = ['firearms', 'stamina', 'electronics', 'armor']
@required_items = ['vests','masks','kneepads','backpacks','gloves','holsters']
... | true |
9904e6cafc7202265ebafc5b861ad63eabd38b2f | Ruby | shoutm/ScoreUpGolf | /app/controllers/service/player_service_controller.rb | UTF-8 | 2,141 | 2.515625 | 3 | [] | no_license | class Service::PlayerServiceController < ApplicationController
# == 概要
# 引数にplayer_idが指定されていた場合、playerが所属するコンペにおけるスコアを全て取得する
# 引数のcompetition_idが指定されていた場合、引数のcompetition_idとログイン中のユーザ情報からplayerを特定し、所属するコンペにおけるスコアを取得する
#
# == 引数
# 以下のどちらかの引数を指定
# player_id
# competition_id
#
# == 出力例
# [
# ... | true |
992e16f00ce0e04b374a604f3c1cdc2986f3face | Ruby | yangliyi/coursera-algorithmic-toolbox | /week5/assignments/4-dynprog-starter-files/knapsack/knapsnack.rb | UTF-8 | 676 | 3.28125 | 3 | [] | no_license | def optimal_weight(capacity, item_weights)
n = item_weights.size
item_weights.unshift(0)
values = Array.new(n+1)
values.map!{|i|i = Array.new(capacity+1, 0)}
for i in 1..n do
for w in 1..capacity do
values[i][w] = values[i-1][w]
if item_weights[i] <= w
val = values[i-1][w-(item_weight... | true |
51d5edd21b581d7c9341b520d212eb8328c12443 | Ruby | tatomolina/entrega1 | /caesar_cipher.rb | UTF-8 | 495 | 2.84375 | 3 | [] | no_license | require_relative './autenticador.rb'
require 'caesar_cipher'
require 'bcrypt'
class Caesar_cipher < Autenticador
attr_accessor :caesar
def initialize
end
def valido?(user_password, password)
return password_plano(user_password) == password
end
def password_plano(password)
return CaesarCipher::Caesar.new.de... | true |
8f72bb5daba3563d378ddd1616e7462379879448 | Ruby | johnofsydney/exercisms | /ruby/matrix/matrix.rb | UTF-8 | 426 | 3.328125 | 3 | [] | no_license | class Matrix
attr_reader :rows, :columns
def initialize input
@rows = input.each_line.map do
|r| r.split.map(&:to_i)
end
@columns = rows.transpose
end
end
# class Matrix
#
# def initialize input
# @input = input
# end
#
# def rows
# @input.scan(/.+/).map do
# |r|... | true |
cec445e9a654b7cfb2746238b8c38592038723bf | Ruby | AymanMagdy/Ruby | /Day1/2.rb | UTF-8 | 385 | 3.9375 | 4 | [] | no_license | #!/bin/usr/ruby -w
print <<"EOF"
2) Given two int values, return their sum. Unless the two values are the same, then
return double their sum.
EOF
puts "Enter 2 number: "
first_number = gets.chomp
second_number = gets.chomp
if first_number == second_number
puts (first_number.to_i() + second_number.to_i())... | true |
a467bf53b3c48fc67af708575c6c530ddc8ae352 | Ruby | dpmontooth/rb101 | /lesson_5/practice_8.rb | UTF-8 | 400 | 3.75 | 4 | [] | no_license | # use the each method to output all of the vowels from given strings
hsh = {
first: ['the', 'quick'], second: ['brown', 'fox'], third: ['jumped'],
fourth: ['over', 'the', 'lazy', 'dog']
}
vowels_reference = %w(a e i o u A E I O U) # vowel reference array
char_dump =[]
hsh.each do |_, word|
char_dump << word.jo... | true |
ba018f9aa6a42564eafb95caff7a7d356cf3c3f9 | Ruby | alsemyonov/vk | /lib/vk/api/board/methods/get_topics.rb | UTF-8 | 4,067 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'vk/api/methods'
module Vk
module API
class Board < Vk::Schema::Namespace
module Methods
# Returns a list of topics on a community's discussion board.
class GetTopics < Schema::Method
# @!group Properties
self.open = true
... | true |
f111310179d28c6130556a8c1abd2d6cf721b797 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/1358.number-of-substrings-containing-all-three-characters.rb | UTF-8 | 1,191 | 3.703125 | 4 | [] | no_license | #
# @lc app=leetcode id=1358 lang=ruby
#
# [1358] Number of Substrings Containing All Three Characters
#
# https://leetcode.com/problems/number-of-substrings-containing-all-three-characters/description/
#
# algorithms
# Medium (58.32%)
# Total Accepted: 12.9K
# Total Submissions: 22.1K
# Testcase Example: '"abcabc"... | true |
3c03b966070557e4d621e547147dc91b28a7e11d | Ruby | mekowalski/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 1,337 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
def initialize(path = "./db/mp3s")
importer = MusicImporter.new(path)
importer.import
end
def call
puts "Initializing Music Library"
puts "Select an Option"
reply = nil
until reply == "exit"
reply= gets.strip
case reply
when "list songs"
... | true |
05b8a6dad0e74ebd7c35f63fe77c2102b45951b9 | Ruby | tiluser/bloccit | /app/helpers/users_helper.rb | UTF-8 | 464 | 2.65625 | 3 | [] | no_license | module UsersHelper
def user_has_posts?
if @user.posts.count > 0
true
else
false
end
end
def user_has_favorited_posts?
favorited_count = 0
@user.posts.each do |post|
if current_user.favorite_for(post)
favorited_... | true |
5092c98f48c40920324298a036330a75638a1626 | Ruby | Harkame/M2 | /meta_programmation/project/TPOtherLanguages/ruby/inspector/inspector.rb | UTF-8 | 4,009 | 4.03125 | 4 | [] | no_license | # Author : Louis Daviaud
# This module is used to format output
module Util
@@lineSeparator = "-----------------------"
def self.get_line_separator
@@lineSeparator
end
end
# Class who inspect other object
class Inspector
# This method is called to inspect an object
# It call inspect_instance
# @param ... | true |
966f4c17138724870b9106ce46e66d081168e5b1 | Ruby | at-huynguyen2/AT_Intern_Spring_2017_Huy_Nguyen | /exercise_day_08/exercise_03.rb | UTF-8 | 257 | 3.515625 | 4 | [] | no_license | require "pry"
require "benchmark"
#a = (1..n).collect {|i| i*i if i*i<n}
#a.compact!
def get_squares n
a = Array.new
(1..n).map do |i|
a.push(i*i) if i*i<n
end
return a
end
puts "input n: "
puts "Perfect square array is #{get_squares gets.to_i}"
| true |
1b6266ee736eb41691d121b6b4bf995de8f93679 | Ruby | cider-load-test/como_vamos | /vendor/plugins/make_permalink/spec/make_permalink_spec.rb | UTF-8 | 2,295 | 3 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require File.dirname(__FILE__) + "/spec_helper"
describe "MakePermalink" do
it "creates a permalink with just AlphaNumeric characters" do
t = NonAsciiPermalinks.new("foo*.,/\<>%&[]{}bar")
t.permalink.should == "1-foo-bar"
t = NonAsciiPermalinks.new("It's-a-me, Mario! ... | true |
ef496e5550f3c723b5921babfb93afe7016eb295 | Ruby | Arithmetics/chess | /chess.rb | UTF-8 | 23,330 | 3.578125 | 4 | [] | no_license | require 'yaml'
require 'colorize'
class Game
attr_accessor :pieces, :turn
def initialize
@turn = "white"
@pieces = []
row7 = [Rook,Knight,Bishop,Queen,King,Bishop,Knight,Rook]
row6 = [Pawn,Pawn,Pawn,Pawn,Pawn,Pawn,Pawn,Pawn]
row1 = [Pawn,Pawn,Pawn,Pawn,Pawn,Pawn,Pawn,Pawn]
row0 = [Rook,Kni... | true |
76d5a6dba0c3874094b55cc9de7bab431d4a5953 | Ruby | jiyaping/rigrate | /lib/rigrate/parser.rb | UTF-8 | 6,681 | 2.71875 | 3 | [] | no_license | # encoding : utf-8
module Rigrate
class Parser
include Migration
module TokenType
FROM = :FROM_TAG
TO = :TO_TAG
UNION = :UNION_TAG
JOIN = :JOIN_TAG
MINUS = :MINUS_TAG
ON = :ON_TAG
USING = :USING_TAG
RUBY_ST... | true |
1b6802a049b23466cd3ecbc474e6bf5edefae52c | Ruby | Rodrigoefo/DesafioCiclosP | /solo_pares.rb | UTF-8 | 258 | 3.5 | 4 | [] | no_license | ##Crea un programa llamado solo_pares.rb que muestre los primeros n números pares, donde n
##es ingresado por el usuario.
datos=ARGV[0].to_i
i=0
contador=0
while contador<datos
if i.even?
puts i
i+=1
contador+=1
else
i+=1
end
end
| true |
a50e462821bd1ff5babe2ce04f728efe2e326783 | Ruby | thorncp/raspi-simon | /button.rb | UTF-8 | 347 | 3.125 | 3 | [] | no_license | require "pi_piper"
class Button
attr_reader :pin_number
def initialize(pin_number)
@pin_number = pin_number
end
def pushed(&block)
PiPiper.after pin: pin_number, goes: :low do
block.call(self)
end
end
def released(&block)
PiPiper.after pin: pin_number, goes: :high do
block.ca... | true |
ff611effce1f61f72e367aaa7bbcaa9b9f152dd4 | Ruby | rubyunworks/ko | /lib/ko/context.rb | UTF-8 | 1,884 | 2.96875 | 3 | [
"ISC",
"Apache-2.0"
] | permissive | module KO
# DEPRECATE: Use Test module instead.
def self.contexts
Test.constexts
end
# DEPRECATE: Use Test module instead.
def self.context(label=nil, &block)
Test.context(label, &block)
end
# Context defines a system "state". A context might specify
# a set of requirments, database fixtures,... | true |
a71a7d24e761743cb93f70330f6af0564a89d8d5 | Ruby | irwanhub2016/dkatalis | /API/spec/api_spec.rb | UTF-8 | 2,570 | 2.65625 | 3 | [] | no_license | require 'api_base'
require_relative "../lib/json_comparison"
include JsonComparison
describe ApiBase do
before(:each) do
@url_target = "https://reqres.in/api/users/"
@request_method = "Get"
end
it 'Test API with two JSON data for static user id' do
result_json_1 = ApiBase.send_api(@url_target, @request... | true |
36adc9afa0789dcf648f2f05b8a8dfd0860d5551 | Ruby | Tshamp7/App_Academy_Classwork | /two_sum_bigO/two_sum.rb | UTF-8 | 902 | 3.8125 | 4 | [] | no_license | require 'byebug'
nums = [0, 1, 5, 7]
#the time complexity of this is O(n^2)
#O(1) constant space
def bad_two_sum?(arr, target)
arr.each_with_index do |num, i|
arr.each_with_index do |num2, j|
next if i == j
return true if num + num2 == target
end
end
false
end
#p bad_two_sum?(nums, 6) ... | true |
767c565c158c54065e5f1d1362c4e6b84bf030dd | Ruby | MrRogerino/phase-0-tracks | /ruby/shout.rb | UTF-8 | 608 | 3.890625 | 4 | [] | no_license | =begin
old code
module Shout
def self.yell_angrily(words)
words + "!!!" + " :("
end
def self.yell_happily(words)
words + " is awesome!" + ":^)"
end
end
=end
#mixin module
module Shout
def yell_angrily(words)
words + "!!!" + " :("
end
def yell_happily(words)
words +... | true |
a6bb8cfc36c1cd12ba0307dc06e0ee487ea5b117 | Ruby | jhnnyk/LS120 | /lesson_1/chap1_exercises.rb | UTF-8 | 189 | 3.375 | 3 | [] | no_license | # -----------
# Exercise 2
module Run
def run(speed)
puts "I run #{speed}!"
end
end
# ------------
# Exercise 1
class Runner
include Run
end
john = Runner.new
john.run("fast")
| true |
d8bbbfd51ed39b8c6ababf8b9297941a2caa6d78 | Ruby | jemadduxVault/Ruby | /helloworld.rb | UTF-8 | 204 | 2.921875 | 3 | [] | no_license | puts "Hello World!"
puts "Good-bye."
puts "I like" + "apple pie."
puts "I like " + "apple pie."
puts "blink " * 4
puts "12 " + "12"
puts "You're swell!"
puts 'You\'re swell!'
puts "You\'re swell!" | true |
18c10624dc3b3d6ae88495f2024fcc68c43ee3eb | Ruby | dhalverson/backend_module_0_capstone | /day_6/exercises/burrito.rb | UTF-8 | 774 | 4.09375 | 4 | [] | no_license | # Add the following methods to this burrito class and
# call the methods below the class:
# 1. add_topping
# 2. remove_topping
# 3. change_protein
class Burrito
attr_accessor :protein, :base, :toppings
def initialize(protein, base, toppings)
@protein = protein
@base = base
@toppings = toppings
... | true |
2f630205afc971ae51296c201a2cc6e11cfe23c2 | Ruby | lsantosc/metropoli | /test/models/test_city.rb | UTF-8 | 1,857 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'helper'
class TestCity < ActiveSupport::TestCase
test 'like method should find cities by name' do
assert_equal Metropoli::CityModel.like('Monterrey').count, 1
end
test 'like method should find cities with %' do
assert_equal Metropoli::CityModel.like('mo').count, 1
end
test 'like method... | true |
bee4d89234bbb3d548acb44be0a428bf8b9992a6 | Ruby | harhogefoo/AtCoder_Ruby | /ABC036/CCCC.rb | UTF-8 | 247 | 3.21875 | 3 | [] | no_license | n = gets.to_i
array = Array.new
n.times do |i|
array.push(gets.to_i)
end
sorted = array.sort
tbl = Hash.new
prev = -1
idx = -1
sorted.each do |num|
tbl[num] = (idx += 1) if num != prev
prev = num
end
array.each do |i|
puts tbl[i]
end
| true |
5a08a1679a5f8e8535b250168aa8eaf89ab2f84a | Ruby | Filmscore88/ruby-music-library-cli-online-web-ft-031119 | /lib/song.rb | UTF-8 | 963 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
extend Concerns::Findable
attr_accessor :name , :artist, :genre, :song_info
@@all=[]
def initialize(name, artist=nil, genre=nil)
@name=name
self.artist= artist if artist !=nil
self.genre= genre if genre !=nil
end
def self.all
@@all
end
def artist=(artist)
@artist=artist
@arti... | true |
86df02ea39b75e88b59a975c3c3a64e4d6541157 | Ruby | vit/tj | /templatejuggler.rb | UTF-8 | 4,776 | 2.75 | 3 | [] | no_license | # coding: UTF-8
%w[haml yaml].each {|r| require r}
def YAML.load_file( filepath )
File.open( filepath, "r:utf-8" ) do |f|
load( f )
end
end
class TemplateJuggler
# Экземпляр этого класса работает загрузчиком шаблонов, считая, что id шаблона соответствует именем файла
# (с подкаталогами) внутри заданного катал... | true |
8d9d19c445a6368d86a961b0110721465f174148 | Ruby | rmascarenhas/ooo | /Ruby/url_tracker/test/test_periodic.rb | UTF-8 | 1,422 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative 'test_helper'
class TestPeriodic < MiniTest::Unit::TestCase
def setup
@p = UrlTracker::Periodic.new
end
def teardown
@p.stop
end
def test_every_with_symbol_argument
assert_equal 60, @p.every(:minute) {}
end
def test_every_with_hour_symbol
assert_equal 60*60, @p.every(... | true |
8af70ae0ede2ce4305771b40d779d7838e66b337 | Ruby | ZsoltFabok/project_euler | /spec/project_euler/problems/problem_16_spec.rb | UTF-8 | 639 | 2.8125 | 3 | [] | no_license | require 'spec_helper'
describe Problems::Problem16 do
context "#calculate" do
let(:arrays) {double}
let(:number) {double}
subject(:problem) {Problems::Problem16.new(arrays, number)}
it "returns 26 as the sum of the digits of the number 2^15" do
expect(arrays).to receive(:sum).with([3,2,7,6,8]... | true |
baa43aa13e9504ade261ef89f8ae2448e7ed4e17 | Ruby | uehara-delta/triangle | /spec/triangle_spec.rb | UTF-8 | 1,046 | 3.015625 | 3 | [] | no_license | # coding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../triangle')
describe Triangle do
specify { expect(Triangle.guess(2, 3, 4)).to eq "不等辺三角形ですね!" }
specify { expect(Triangle.guess(2, 2, 1)).to eq "二等辺三角形ですね!" }
specify { expect(Triangle.guess(1, 1, 1)).to eq "正三角形ですね!" }
specify { expect(Tria... | true |
3e1309a48278ee4b2d326696eb4a3b69150cc0cd | Ruby | sds/slim-lint | /lib/slim_lint/sexp.rb | UTF-8 | 3,041 | 3.359375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module SlimLint
# Symbolic expression which represents tree-structured data.
#
# The main use of this particular implementation is to provide a single
# location for defining convenience helpers when operating on Sexps.
class Sexp < Array
# Stores the line number of the code... | true |
c67a5baaf1b407e3f3aa079d68c1f8266cedc538 | Ruby | dmitrokh/Ruby_on_Rails | /app/controllers/main_controller.rb | UTF-8 | 934 | 2.625 | 3 | [] | no_license | require_relative "../services/weather_service"
class MainController < ApplicationController
def callForm
render "main/index"
end
def index
cityToCheck = params[:city]
if City.all[cityToCheck.to_sym] == nil #no requested city exists in hash yet
@message = 'this city not... | true |
703e08a34e4ed702dd19044d5fc8f56bb7d99655 | Ruby | CartoDB/cartodb | /spec/models/carto/log_spec.rb | UTF-8 | 10,808 | 2.609375 | 3 | [
"LicenseRef-scancode-generic-cla",
"BSD-3-Clause"
] | permissive | require 'spec_helper_unit'
describe Carto::Log do
describe '#basic' do
it 'checks basic operations' do
type = Carto::Log::TYPE_DATA_IMPORT
text1 = 'test'
text2 = 'anothertest'
timestamp = Time.now.utc
log = Carto::Log.new({ type: type })
log.append(text1, false, timestamp)
... | true |
0af65633d5d2a1b2c13a85cf2f1fb8da33ffca0e | Ruby | bess/northwest-digital-archives | /vendor/plugins/blacklight/vendor/gems/rdoc-2.3.0/lib/rdoc/parser/f95.rb | UTF-8 | 57,112 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | require 'rdoc/parser'
##
# = Fortran95 RDoc Parser
#
# == Overview
#
# This parser parses Fortran95 files with suffixes "f90", "F90", "f95" and
# "F95". Fortran95 files are expected to be conformed to Fortran95 standards.
#
# == Rules
#
# Fundamental rules are same as that of the Ruby parser. But comment markers
# ar... | true |
91244929945fa64f0c18651c0277e89980ce5716 | Ruby | RemixZero/learn-ruby | /chap19.rb | UTF-8 | 886 | 4.53125 | 5 | [] | no_license | def cheese_and_crackers(cheese_count, boxes_of_crackers, cool=55) #yo this DEFINES a function
puts "you have #{cheese_count} cheeses!"
puts "you have #{boxes_of_crackers} boxes of crackers"
puts "you have #{cool} cools"
puts "man thats enough for a party!"
puts "get a blanket.\n"
end
puts "we can just give ... | true |
c4ca0ed5c7165e5d95b497f3f46f3d968d86a940 | Ruby | shuto0125/projecteuler | /problem5/index.rb | UTF-8 | 687 | 3.59375 | 4 | [] | no_license | my_prime = [ 1, 2 ]
i = 0
#20までの素数を出す
20.times do |i|
i += 1
if i % 2 != 0
i.times do |new_i|
if new_i != 1 && new_i % i != 0 && my_prime.include?(i) == false
my_prime.push(i)
end
end
end
end
p my_prime
target = 2520
loop do
target += 1
check_flug = false
# 2,3,5 で割れる数... | true |
68cf7fef37c65657c4fd269da3e16b06a80a359c | Ruby | Slouch07/RB101 | /Small_Problems/Easy_4/convert_string_to_number.rb | UTF-8 | 866 | 4.78125 | 5 | [] | no_license | # Convert a String to a Number! (REVIEW)
# A method that takes a String of digits, and returns the appropriate number as an integer.
# input - a string version of a number.
# output - an integer version of the input string
# separate individual charaters in the string. (array - .chars)
# iterate through each element ... | true |
4906fb6714988703af72121e224e44ea7f5ebb19 | Ruby | cvallianatos/Euler | /Names_scores.rb | UTF-8 | 1,473 | 3.828125 | 4 | [] | no_license | # Names scores
# Problem 22
# Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obta... | true |
5d6e6f117248b650873af4333204468b101c62ca | Ruby | tvaroglu/enigma | /spec/file_handler_spec.rb | UTF-8 | 1,690 | 2.828125 | 3 | [] | no_license | require_relative 'spec_helper'
RSpec.describe FileHandler do
before :each do
@message = 'hello world end'
@message_file = './lib/test_files/message.txt'
@encryption_file = './lib/test_files/encrypted.txt'
@key = '67929'
@date = '130621'
end
it 'can encrypt a message' do
allow($stdin).to ... | true |
0c64e9c6e24ef1d6dbcc26cf528fb3b6754f6c30 | Ruby | elorenn/Ironhack | /Week_1/Day_5/chess_validator/app.rb | UTF-8 | 4,750 | 3.46875 | 3 | [] | no_license | require_relative("lib/chesspiece.rb")
require_relative("lib/rook.rb")
require_relative("lib/king.rb")
require_relative("lib/knight.rb")
require_relative("lib/bishop.rb")
require_relative("lib/queen.rb")
require_relative("lib/pawn.rb")
require_relative("lib/board.rb")
black_rook_left = Rook.new(1, 8, "black")
black_... | true |
a80a1c78f48fd3bb7db767cfda6435dc0e73360d | Ruby | ResignationMedia/logstash-codec-uri | /lib/logstash/codecs/uri.rb | UTF-8 | 2,043 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
require "logstash/codecs/base"
require "logstash/util/charset"
require "uri"
# This codec will append a string to the message field
# of an event, either in the decoding or encoding methods
#
# This is only intended to be used as an example.
#
# input {
# stdin { codec => }
# }
#
# or
#
# output ... | true |
c1ca9b6405097d93e1b0a8b792ddab97cf03cbd1 | Ruby | justindelatorre/rb_130 | /small_problems/easy_testing/10_refutations.rb | UTF-8 | 312 | 2.90625 | 3 | [] | no_license | =begin
https://launchschool.com/exercises/4ac8e502
Write a test that will fail if 'xyz' is one of the elements in the Array list.
=end
require 'minitest/autorun'
class SampleTest < MiniTest::Test
def setup
@list = ['abc']
end
def test_refute
refute_equal(true, @list.include?('xyz'))
end
end
| true |
144a98b083e4b5deb7fe0a7e42ca9c23c8ccb997 | Ruby | AJFaraday/process_game | /lib/common_components/relative_positions.rb | UTF-8 | 1,800 | 2.96875 | 3 | [] | no_license | module CommonComponents
module RelativePositions
def closest_target
candidates = targets
if candidates.any?
candidates.sort! { |a, b| distance_to(a) <=> distance_to(b) }
candidates[0]
else
return nil
end
end
def touching?(target)
distance_to(target) ... | true |
780a144acaff89668f9ef3868a88c3ec756a3945 | Ruby | djmicros/tracknwin | /app/models/user.rb | UTF-8 | 1,715 | 2.53125 | 3 | [] | no_license | class User < ActiveRecord::Base
include Amistad::FriendModel
has_many :rides, dependent: :destroy
has_many :microposts, dependent: :destroy
attr_accessible :name, :email, :password, :password_confirmation, :gender, :birthdate, :team, :country
has_secure_password
before_save { |user| user.email = em... | true |
3f5873f9ca7ada53dadab29fe2b62e7173a15aff | Ruby | The-Beez-Kneez/AutomatedTesting | /lib/deck.rb | UTF-8 | 969 | 3.890625 | 4 | [] | no_license | # deck.rb
require_relative 'card'
class Deck
# Be able to be instantiated.
# Be created with 52 Card objects as attributes.
attr_reader :deck
def initialize
# FEEDBACK EDIT: COULD HAVE MADE VALUES AND SUITS INTO CONSTANTS AND REFERENCED--
values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
suits... | true |
2f4e48f3bc11e5434ede1588d8fbcf61a6316e4c | Ruby | ticho/tic-tac-toe | /lib/boardcase.rb | UTF-8 | 205 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
# one case on the boardgame, contains only its own status
class BoardCase
attr_accessor :status
def initialize
@status = ' '
end
def to_s
@status
end
end
| true |
bce82da8ed5f04f354aec1abf33470abd45602a5 | Ruby | srsvybes1/ruby-objects-has-many-through-lab-onl01-seng-pt-032320 | /lib/doctor.rb | UTF-8 | 495 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name, :appointment, :patient
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def new_appointment(date, patient)
Appointment.new(date, patient, self)
end
def appointments
Appointment.all.select do |appointment|
appointment.doctor ==... | true |
3a6cd3637568b6bc944f370cc17f81774c759e1f | Ruby | bullhornfixie/makers-challenge-chitter | /lib/users.rb | UTF-8 | 545 | 2.984375 | 3 | [] | no_license | require 'pg'
require_relative 'database_connection'
class Users
attr_reader :name
# makes instances accessible to others
# returns the information asked for about the object
if ENV['ENVIRONMENT'] == 'test'
DatabaseConnection.setup(dbname: 'chitter_test')
else
DatabaseConnection.setup(dbname: 'chit... | true |
19e30a38c4f9b23211e62ac6f88787577e98e26a | Ruby | Kighway/Engaged-Humanity-API | /db/seeds.rb | UTF-8 | 3,968 | 2.609375 | 3 | [] | no_license | #
# USERS
#
jenny = User.create({first_name: "Jenny", last_name: "Kats", username: "jennyk", email: "jenny@fake.com", profile_url: "../images/jenny.jpeg", password: "1234"})
kyle = User.create({first_name: "Kyle", last_name: "Tulod", username: "kylet", email: "kyle@fake.com", profile_url: "../images/dummy.jpeg", passw... | true |
8442e6e5cb9ccb4dc6b3574fdb918240752510aa | Ruby | Stanleyyork/dewey | /app/controllers/api/alexa_controller.rb | UTF-8 | 1,617 | 2.78125 | 3 | [] | no_license | class Api::AlexaController < ApplicationController
def show
title = params[:book_title]
@book = Book.find_by_title(title)
@book = Book.where("title LIKE ?", "%#{title}%").first if @book.nil?
@book = Book.where("title LIKE ?", "%#{title.capitalize}%").first if @book.nil?
@book = Book.where("title LIKE ?", "%#... | true |
05b4b3d6d0a0238361a0a6a46b84ae18f25418f9 | Ruby | Imhotep504/Ruby | /class.rb | UTF-8 | 699 | 3.578125 | 4 | [] | no_license | #!/usr/bin/ruby
o = Object.new
puts o.object_id
puts "'o' is of class: #{o.class}"
class Customer
def customer_id=(customer_id)
@customer_id = customer_id
end
def customer_id
@customer_id
end
attr_reader :city
attr_writer :city
attr_accessor :place
end
c = Customer.new... | true |
cd44f065dc84a55d544fb2b30781f5ac99634225 | Ruby | jordanmaguire/frontier_generators | /lib/frontier/association.rb | UTF-8 | 1,840 | 2.515625 | 3 | [] | no_license | require_relative "attribute.rb"
class Frontier::Association < Frontier::Attribute
include Frontier::ErrorReporter
attr_reader :attributes, :form_type
ID_REGEXP = /_id\z/
def initialize(model, name, properties)
super
# Convert:
# address_id -> address
# address -> address
@name = na... | true |
5d9fec704dd6ff5e01d8a09a2c0a2e8dd5c9a560 | Ruby | slickpk/testffl2_app | /test_sql.rb | UTF-8 | 309 | 2.703125 | 3 | [] | no_license | require 'rubygems'
require 'sqlite3'
db = SQLite3::Database.new('db/development.sqlite3')
results = db.execute("Select Abrv, Team from Abbrvs")
test1 = results[0][1].downcase
test2 = test1[0..test1.index(' ') - 1] + test1[test1.index(' ') + 1..test1.length]
puts test2
| true |
fb36c52b1be5acbf0467969f580b32c327ea1dc6 | Ruby | IalyRambe/ExercicesRuby_Projet | /exo_15.rb | UTF-8 | 154 | 3.4375 | 3 | [] | no_license | puts "Bonjour, c'est quand ton année de naissance ?"
year_birth = gets.to_i
year_birth.upto(2020) do |i|
puts "- nombre = #{i} #{i - year_birth}"
end
| true |
a52ececc93c936e12efb3bcaab22db2d3593ee00 | Ruby | eedrummer/laika | /app/models/telecom.rb | UTF-8 | 2,296 | 2.734375 | 3 | [] | no_license | # Encapsulates the telecom section of a C32. Instead of having
# a bunch of telecom instances as part of a has_many, we've
# rolled the common ones into a single record. This should
# make validation easier when dealing with phone numbers
# vs. email addresses
class Telecom < ActiveRecord::Base
strip_attributes!
... | true |
3cfdf65db78923e93b2ad50e5d45f488b5a0c15c | Ruby | griswoldbar/patterns | /lib/things/person.rb | UTF-8 | 129 | 2.734375 | 3 | [] | no_license | class Person
attr_reader :name
def initialize(name)
@name = name
end
def prod_reaction
"how dare you!"
end
end | true |
02fd35e6fd8b9b4aa902d0c0137b020a42aab82e | Ruby | dmullek/dominion | /app/cards/haven.rb | UTF-8 | 1,464 | 2.578125 | 3 | [] | no_license | class Haven < Card
def starting_count(game)
10
end
def cost(game, turn)
{
coin: 2
}
end
def type
[:action, :duration]
end
def play(game, clone=false)
CardDrawer.new(game.current_player).draw(1)
game.current_turn.add_actions(1)
@log_updater.get_from_card(game.current_p... | true |
e14889a8f4a98afdc9b723bca18c9c9d85deda17 | Ruby | violentr/First_3_weeks_at_makers | /Learn-the-ruby-hard-way-week1/ex22.rb | UTF-8 | 698 | 3.390625 | 3 | [] | no_license |
def write_file(filenameR, filenameW)
# open the source file
file =File.open(filenameR)
# open the destination file for writing
file_d = File.open(filenameW, 'w')
# read the data from the source file
contents = file.read
# write to the destination
file_d.write(contents)
# close source file
file.close
# close... | true |
6d031b4df4185ed56ebe63db7c0a6415b95145bf | Ruby | LichP/Porp | /lib/porp/stock/entity.rb | UTF-8 | 3,223 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# Porp - The Prototype Open Retail Platform
#
# Copyright (c) 2011 Phil Stewart
#
# License: MIT (see LICENSE file)
class Stock
=begin
The StockEntity class represents physical stock. Quantities of StockEntities
are represented by StockHoldings.
=end
class Entity < Ohm::Model
attribute :de... | true |
75d4d1d72f5e833adfaaa49544799ab50b825938 | Ruby | LogaJ/ruby_prag_prog | /variables/vars.and.object.reference.properties.rb | UTF-8 | 221 | 3.46875 | 3 | [] | no_license | person = "Tim"
puts "The object in 'person' is an instance of a: #{person.class} class."
puts "The object 'person' has an object id of: #{person.object_id}."
puts "And the string referenced by 'person' is: '#{person}'."
| true |
70385583ea9e12a539b829b4706c0032803a86f4 | Ruby | fabriciojoc/ws_coordination_protocols_rails | /bank/app/models/coordination_context.rb | UTF-8 | 897 | 2.625 | 3 | [
"MIT"
] | permissive | class CoordinationContext
def initialize(coordination_type, id, registration_service, card_number, card_password, card_security_code, value)
@id = id
@coordination_type = coordination_type
@registration_service = registration_service
@card_number = card_number
@card_password = card_password
@c... | true |
d906855b6116a576b446d1170e2572fe4aebc683 | Ruby | kenjione/optimize_methods | /optimize.rb | UTF-8 | 1,490 | 2.515625 | 3 | [] | no_license | require 'sinatra'
require 'active_support/inflector'
require File.dirname(__FILE__)+"/methods/drawplot.rb"
require File.dirname(__FILE__)+"/methods/base_optimize_method"
BaseOptimizeMethod.require_methods
helpers do
def link_to(name, path, options = {})
params = options.map { |k, v| %|#{k}="#{v}"| }.join
pa... | true |
5f1d553e9bb8a27870ac2960ec509de02fee53c7 | Ruby | phss/playground | /exercises/euler/problem76.rb | UTF-8 | 271 | 3.546875 | 4 | [] | no_license | def ways_to_make(amount)
values = (1..(amount-1)).to_a
ways = Array.new(amount + 1, 0)
ways[0] = 1
values.each do |value|
(value..amount).each do |idx|
ways[idx] += ways[idx - value]
end
end
return ways[amount]
end
puts ways_to_make(100)
| true |
b6e2d1e55c2ea01376d0adad6f134a1c2c677ec8 | Ruby | NiestrojMateusz/Launch-School-101 | /exercises/Easy2/1_Teddy.rb | UTF-8 | 1,440 | 4.5625 | 5 | [] | no_license | # How old is Teddy?
# Build a program that randomly generates and prints Teddy's age. To get the age, you should generate a random number between 20 and 200.
# Example Output
# Teddy is 69 years old!
age = rand(20...201)
puts "Who's age you want to know?"
name = gets.chomp.capitalize
name = "Teddy" if name == ""
p... | true |
27223540a42092abf6bb35572e1a3ac2640f0015 | Ruby | rinapratama335/belajar-ruby | /5.perulangan/1.while.rb | UTF-8 | 90 | 2.9375 | 3 | [] | no_license | nilai = 1
while nilai <= 10 do
puts "Perulangan ke #{nilai}"
nilai = nilai + 1
end | true |
2b65ca9bec33ca2edf078d7a49187f6075a53620 | Ruby | beasteim/ruby-challenges | /help.rb | UTF-8 | 269 | 3.328125 | 3 | [] | no_license | #can successfully access each index of a string
#cannot convert an index into a fixnum
dob = '0505'
first = dob[0].to_i
puts first
second = dob[1].to_i
puts second
final = first + second
yay = 123
yay.to_s
puts yay.class
darn = "yay"
yo = darn.to_i
puts yo.class
| true |
7976cbc73fb3bf47a2c22d8f726981ecb7041a42 | Ruby | gahenton/intro2programming | /Methods/chaining_methods.rb | UTF-8 | 118 | 3.28125 | 3 | [] | no_license | def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
add(20, 45)
# returns 65
subtract(80, 10)
# returns 70
| true |
48aa7d4b4ce67946028d4513bde81a5fefd44b84 | Ruby | ommiles/birdwatcher-bros | /member.rb | UTF-8 | 422 | 3.171875 | 3 | [] | no_license | class Member
attr_reader :member_name
def initialize(member_name)
@member_name = member_name
end
def create_club(club_name, location)
new_club = Club.new(club_name, location)
new_club.members << self
new_club
end
def join_club(club_name)
joiner = Club.... | true |
95cfc2e12713a0c0f09d73dc779454477ba1034c | Ruby | HiramIO/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 2,405 | 3.53125 | 4 | [] | no_license | def translate(string)
output = []
words = string.split
words.each do |word|
text = word.split(//)
if text[0] == "a"
output << text.join + "ay "
elsif text[0] == "e"
output << text.join + "ay "
elsif text[0] == "i"
output << text.join + "ay "
elsif text[0] == "o... | true |
39c777149b3323c27275a2d83034bbdc2537575f | Ruby | lymanwong/Ruby-Stuff | /algorithms/which_are_in/which_are_in.rb | UTF-8 | 971 | 4.34375 | 4 | [
"MIT"
] | permissive | # Given two arrays of strings a1 and a2 return a sorted array in lexicographical order and without duplicates of the strings of a1 which are substrings of strings of a2.
# Example: a1 = ["arp", "live", "strong"]
# a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
# returns ["arp", "live", "strong"]
# a1 = ["tarp",... | true |
c8d607abfe45a554424610377af78ed6df9eb340 | Ruby | mwakipesile/launch-school-130 | /sum_of_multiples.rb | UTF-8 | 342 | 3.71875 | 4 | [] | no_license | require 'pry'
class SumOfMultiples
attr_reader :set
def initialize(*set)
@set = set.empty? ? [3, 5] : set
end
def self.to(number)
new.to(number)
end
def to(number)
(0...number).select { |number| multiple?(number) }.inject(:+)
end
def multiple?(number)
set.any? { |factor| number % fa... | true |
d07217e8d039a6f2d666811b6595bf655d51fdd7 | Ruby | fjohnson87/ruby-enumerables-reverse-each-word-lab-online-web-prework | /reverse_each_word.rb | UTF-8 | 188 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word
reverse_each_word = ["Hello", "there", "and", "how", "are", "you?"].join(' ')
reverse_each_word.each do |reverse_each_word|
puts "#{reverse_each_word.reverse}
end | true |
fc53ed6cc63fe0dd08b2a18b095c2de688ede713 | Ruby | DimaKrupko/Ruby2020 | /add_2.rb | UTF-8 | 300 | 3.234375 | 3 | [] | no_license |
puts "Введіть ціну товару,знижку у відсотках,та кількість товару через пробіл"
result=0
c=gets.chomp
c=c.split(" ")
price, discount, number =c[0].to_f, c[1].to_i, c[2].to_i
result=price*(discount*0.01)*number
puts result.round
| true |
e9550349b03c2f7e87600c9bbd72e778174086ab | Ruby | rrrene/ud | /bin/ud | UTF-8 | 906 | 2.984375 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
require 'trollop'
require 'ud'
opts = Trollop.options do
version "ud #{UD.version}"
banner <<-EOS
UD is a command-line tool to scrape definitions from the Urban Dictionary.
Usage:
ud [options] <word(s)>
where [options] are:
EOS
opt :ratio, 'Filter by upvotes/do... | true |
7895c2083b64036afc1a8a58effd402be01e4e4e | Ruby | nataliagalan/advanced-hashes-hashketball-chi01-seng-ft-080320 | /hashketball.rb | UTF-8 | 6,063 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
# Write your code below game_hash
def game_hash
{
home: {
team_name: "Brooklyn Nets",
colors: ["Black", "White"],
players: [
{
player_name: "Alan Anderson",
number: 0,
shoe: 16,
points: 22,
rebounds: 12,
assists: 1... | true |
999ea1eab53c19228bb6d3f5635128dd18b48017 | Ruby | free-beer/reorm | /spec/reorm/property_errors_spec.rb | UTF-8 | 3,357 | 2.875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Reorm::PropertyErrors do
subject {
Reorm::PropertyErrors.new
}
describe "#clear?()" do
it "returns true for an empty instance" do
expect(subject.clear?).to eq(true)
end
it "returns false for a non-empty instance" do
subject.add(:blah, "Some message.")
expect(subject... | true |
f8a5de2de063f0f60b6b6fb7852c2d5e05b65f1b | Ruby | wxm112/wdi8_nots | /air_conditioning.rb | UTF-8 | 674 | 3.796875 | 4 | [] | no_license | print "What's the current temperature? "
current_temperature = gets.to_i
print "If the A/C is functional? (y/n) "
air_conditional = gets.chomp.downcase
print "What temperature do you wish? "
desired_temperature = gets.to_i
def aircon(current_temperature,air_conditional,desired_temperature)
if air_conditional == "y"
... | true |
ac3d8de6e5a0116bdad2a4450526d7aaf4a342b4 | Ruby | iamdhunt/LLF | /app/models/comment.rb | UTF-8 | 1,403 | 2.578125 | 3 | [] | no_license | class Comment < ActiveRecord::Base
attr_accessor :mention
attr_accessible :content
belongs_to :member
belongs_to :commentable, polymorphic: true
has_many :mentions, as: :mentioner, dependent: :destroy
after_create :create_notification, :send_email, unless: Proc.new { |comment| comment.member.id == comment.com... | true |
b0b0677561e3b23dd3dc58f53814a45f4bd57c4d | Ruby | sheim-dev/pager_duty | /lib/pager_duty/client/escalation_policies.rb | UTF-8 | 7,325 | 2.546875 | 3 | [
"MIT"
] | permissive | module PagerDuty
class Client
# Module encompassing interactions with the escalation policies API endpoint
# @see https://v2.developer.pagerduty.com/v2/page/api-reference#!/Escalation_Policies
module EscalationPolicies
# List escalation policies
# @param options [Sawyer::Resource] A customi... | true |
194d8211d6a021ca9a7f9cd053d583c8e29a5934 | Ruby | everton/rRPG | /lib/character/modules.rb | UTF-8 | 952 | 2.671875 | 3 | [
"MIT"
] | permissive | module Character
module Modules
def self.included(base)
base.send :extend, ClassMethods
base.send :include, SingletonMethods
end
module AutoMagickInclusion
def automagicaly_require(mod_name)
require_relative "modules/#{mod_name}"
# TODO: create camelize and constan... | true |
d62ade2d98e990f112e582997ff3e7808a92854d | Ruby | sbstn-jmnz/BasicRuby | /first.rb | UTF-8 | 46 | 2.78125 | 3 | [] | no_license | puts "Hello Mothafaka"
text = gets
puts text | true |
fc7c459cfc47444ae48a69a5cfc8d538a512b3fb | Ruby | TheoObbard/w2d4_classwork | /execution_time.rb | UTF-8 | 1,847 | 4.4375 | 4 | [] | no_license | #my_min
# Given a list of integers find the smallest number in the list.
#my_min in O(n^2) time complexity
def my_min_1(list)
smallest = nil
list.each do |el1|
smallest = el1 if smallest == nil
list.each do |el2|
if el2 < el1 && el2 < smallest
smallest = el2
end
end
end
smallest... | true |
f8e560c06658701a7334a6f0362f3dc9c0d4fc3b | Ruby | opq290/Ruby | /kadai5_10.rb | UTF-8 | 204 | 3.046875 | 3 | [] | no_license | def f(s)
f=s.to_a
f
end
def g(s)
f=f(s)
g=Array.new
for i in 0..f.length-1
g[f[i]]=i
end
g
end
def in(a,s)
g=g(s)
if g[a] != nil
return true
else
return false
end
end
| true |
7e5e69a05d5e11d1433168d27503a5f9f8913eb2 | Ruby | enspirit/predicate | /spec/predicate/test_and_split.rb | UTF-8 | 2,205 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
class Predicate
describe Predicate, "and_split" do
let(:p){ Predicate }
subject{ pred.and_split([:x]) }
context "on tautology" do
let(:pred){ p.tautology }
it{ should eq([p.tautology, p.tautology]) }
end
context "on contradiction" do
let(:pred){ p.contra... | true |
d3158ba0f37dd9ffabedf517fc7c032c7739c2c6 | Ruby | arleigh-atkinson/fall_dev15 | /Day1.rb | UTF-8 | 3,243 | 4.1875 | 4 | [] | no_license |
# I need to create a variable with my first name
first_name = 'Arleigh'
# I need to create a variable with my last name
last_name = 'Atkinson'
# Be verbose with variable names
# I need to output my first and last name
#puts "#{first_name} #{last_name}"
#string interpolation: variables inside a string
# puts: ou... | true |
e873045997e115492015b45ab28e478a045f71a1 | Ruby | isabella232/tracktor-webapp | /lib/tracktor/params_handler.rb | UTF-8 | 661 | 2.59375 | 3 | [] | no_license | class ParamsHandler
def initialize(params, user)
@params = params
@user = user
end
def update
update_device_id
update_buttons
end
private
def update_device_id
if @params[:device_id].present?
@user.update_attributes(device_id: @params[:device_id])
end
end
def update_b... | true |
af649e0dc9cd349b05dae99402396858a069be77 | Ruby | helloRupa/chess-ruby | /lib/pieces/pawn.rb | UTF-8 | 2,525 | 3.1875 | 3 | [] | no_license | require_relative './piece.rb'
class Pawn < Piece
attr_reader :en_passant
def initialize(color, board, pos)
super
@en_passant = false
end
def symbol
"\u265F"
end
def moves
all_moves = []
all_moves.concat(get_forward_moves)
all_moves.concat(get_side_attacks)
all_moves.concat(... | true |
bd1a35cf5d1266d940085ff45b39b63c97131c99 | Ruby | bmarini/deadpool | /lib/deadpool/state_snapshot.rb | UTF-8 | 1,885 | 2.828125 | 3 | [] | no_license |
module Deadpool
class StateSnapshot
def initialize(state)
@name = state.name
@timestamp = state.timestamp
@status_code = state.status_code
@all_messages = state.all_messages
@error_messages = state.error_messages
@children = []
end
... | true |
5740566b15e18f2febd1ebc16556c1d272cd978a | Ruby | bbc/redux-client-ruby | /lib/bbc/redux/channel_category.rb | UTF-8 | 837 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | require 'virtus'
module BBC
module Redux
# Redux API Channel Category Object
#
# @example Properties of the channel category object
#
# category = redux_client.channel_categories.first
#
# category.description #=> String
# category.id #=> Integer
# category.pri... | true |
7976d4ada78a8c6a3c48bb3c9bf4570356b7bfbf | Ruby | YoshiMejia/ruby-oo-object-relationships-has-many-through-lab | /lib/artist.rb | UTF-8 | 497 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
#An artist has many genres through its songs and a genre has many artists through
#its songs.
class Artist
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def new_song(name, genre)
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.