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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b86bdf1ce9f76d49fe6dd02e517f7d37a3d25df5 | Ruby | athio92/launchschool | /courses/100/L1T13/02_Variables/name.rb | UTF-8 | 152 | 3.484375 | 3 | [] | no_license | puts "Type your first name"
firstname = gets.chomp
puts "Type your last name"
lastname = gets.chomp
10.times {puts "Hello #{firstname} #{lastname}!"}
| true |
0b54d9725387a44ba88753e68e7acd32f85be6fb | Ruby | triedman99/project_cli_connect_four | /lib/board.rb | UTF-8 | 2,514 | 3.78125 | 4 | [] | no_license | class Board
attr_reader :board
def initialize
@board = Array.new(7){Array.new(7)}
end
def render
puts
puts "0 1 2 3 4 5 6"
@board.each_with_index do |row, row_index|
row.each_with_index do |col, col_index|
col.nil? ? print("-".center(4)) : print(col.to_s.center(4))
... | true |
b3f20f6900892181142b54c42a41b09a685463b0 | Ruby | atsutsumi/mrs_client_s | /lib/mrscs/receiver.rb | UTF-8 | 2,248 | 2.640625 | 3 | [] | no_license | # coding: UTF-8
require 'socket'
module Mrscs
#
# Unixドメインソケットサーバを起動し外部からのデータを受信します。
# データを受信した後はこのクラスで保持するdelegateインスタンスに受信データを連携します。
#
class Receiver
# アクセサ定義
attr_accessor :delegate
#
# 初期化処理
#
# ==== Args
# _options_ :: 起動時の設定
# ==== Return
# ==== Raise
... | true |
63265ac2b53c35918586a4633df95e13a10a4950 | Ruby | arturaz/custom_serialize | /lib/arturaz/custom_serialize.rb | UTF-8 | 1,957 | 2.65625 | 3 | [
"MIT"
] | permissive | module Arturaz
module CustomSerialize
module ClassMethods
# Serialize attributes in custom way instead of using default #serialize
# which always serializes to YAML. This method allows you to serialize
# in your own kind of ways.
#
# For example if you want serialize +Array+ to comma... | true |
b4aeaf69dae79d5583e2a52e8db360a6647639a4 | Ruby | gellieb/workspace | /workspace_1/002-chrispine/7.5.3-deaf-grandma-extended-2.rb | UTF-8 | 998 | 3.96875 | 4 | [] | no_license | # What if Grandma doesn’t want you to leave?
# When you shout BYE, she could pretend not to hear you.
# Change your previous program so that you have to shout
# BYE three times in a row. Make sure to test your program:
# if you shout BYE three times but not in a row, you should
# still be talking to Grandma.”
put... | true |
86bdbb2437340b0ef714e4b894bc421799421649 | Ruby | macZombie/Ruby- | /csvFile.rb | UTF-8 | 8,741 | 2.640625 | 3 | [] | no_license | #!/usr/bin/ruby
#File: csvFile.rb
#
# csvFile.rb
class CsvFile < CustomFile
@bufferFile = ""
@bufferFileName = ""
@indexArray = Array.[]
def initialize(fileName)
super(fileName,"Comma Separated Variables / Sheet")
@ind... | true |
5770a25fb95da7cf2d9d71530244a4e0bc7eb229 | Ruby | techiela/timecard.rb | /timecard.rb | UTF-8 | 3,095 | 3.203125 | 3 | [] | no_license | require 'win32/eventlog'
require 'date'
require 'rubygems'
require 'active_support/time'
include Win32
class Timecard
#
# コンストラクタ
#
def initialize
self.initializeEventLogContainer
end
#
# イベントログ格納配列を初期化する
#
def initializeEventLogContainer
@result = {}
today = Date.today;
# 先月の1日から今... | true |
ee13d508d251951786851d025db4b9d249a845ce | Ruby | deirdrehyde/W2D3 | /poker/spec/card_spec.rb | UTF-8 | 324 | 2.6875 | 3 | [] | no_license | require 'rspec'
require_relative '../lib/card'
describe Card do
describe "#initialize" do
subject(:card) {Card.new(:heart, 8)}
it "establishes a value for the card" do
expect(card.value).to eq(8)
end
it "establishes a suit for the card" do
expect(card.suit).to eq(:heart)
end
end
... | true |
31ff99f14952c25a35f3c5fbf7edc008b9473df8 | Ruby | danakatz/level_up_exercises | /data_science/spec/lib/data_calculator_spec.rb | UTF-8 | 858 | 2.734375 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "data_calculator"
describe DataCalculator do
it "calculates the conversion rate for each cohort" do
reader = DataReader.new("data/test_data.json")
calc = DataCalculator.new(reader)
expect(calc.conversion_rate("A")).to equal(2 / 24.to_f)
expect(calc.conversion_rate("B")).... | true |
dd71baf7f3d78bda31731c1971a50b9f9d5c6526 | Ruby | betodt/RubyHW | /HW/albertodiaztostado-278-5pm-assignment3/q4.rb | UTF-8 | 555 | 3.734375 | 4 | [] | no_license | #!/usr/bin/ruby
# Alberto Diaz-Tostado
# COEN 278
# Assignment 3
# Question 4
class Array
def collect
i = 0
newAry = []
while i < length
#push value returned from block into new array
newAry.push(yield(self[i]))
i += 1
end
return newAry
end
def collect!
i = 0
while i ... | true |
f9fbdcf2e1bf5facc5f8744a7af7a0cb4a902b9c | Ruby | beingy/daily-recipe-cli-gem | /lib/daily_recipe/Recipe.rb | UTF-8 | 1,218 | 2.859375 | 3 | [
"MIT"
] | permissive | class DailyRecipe::Recipe
attr_accessor :name, :cook_time, :rating, :reviews, :url
def self.today
self.scrape_food_network
end
# def self.scrape_recipes
# self.scrape_food_network
# end
def self.scrape_food_network
recipes = []
doc = Nokogiri::HTML(open("http://www.foodnetwork.com/recip... | true |
5c0dcaf432caa159d40f4fb5fe4817e23791ce5f | Ruby | Alexis-Trainee/ruby | /each_array.rb | UTF-8 | 108 | 2.984375 | 3 | [
"MIT"
] | permissive | names = ['Joãozinho', 'Manoel', 'Juca']
name = 'leonardo'
names.each do |name|
puts name
end
puts name
| true |
3e91b770e5385491d35181d7b81f8786a15f7523 | Ruby | Nikos4Life/Prework-Ruby | /copy_name.txt | UTF-8 | 610 | 3.609375 | 4 | [] | no_license | #this is a comment
puts "I"
puts "like"
puts "pie."
print "Cookies"
print "are"
print "good"
print "too."
operation_result = 12 * 34
puts "Operation result is "
puts operation_result
a_string = "This is a String"
another_string = 'This is also a String'
multiline_string = """
A long time ago in a galaxy far, far away... | true |
13055498715f3a696af9a9e4cde7a904f95aec46 | Ruby | shiado/Project-2-Muse | /db/seeds.rb | UTF-8 | 1,820 | 2.59375 | 3 | [
"MIT"
] | permissive | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
573074dc51d715c33abadddefc281042b39c7177 | Ruby | Thomascountz/odin_projects | /caeser_cypher/lib/caeser_cypher.rb | UTF-8 | 598 | 3.234375 | 3 | [] | no_license | SMALL_Z = 122
BIG_Z = 90
CHRS_IN_ALPHABET = 26
def c_cypher(args = {})
string = args.fetch(:string, nil)
index = args.fetch(:index, nil)
string = string.split('').map! do |character|
if character =~ /[a-zA-z]/
if character =~ /[a-z]/ && character.ord + index > SMALL_Z
((character.ord + ... | true |
f2406969d26ca177ba6f8a5ce0203459afe47fa5 | Ruby | huyserp/Advanced_Ruby_Building_Blocks | /bubble_sort.rb | UTF-8 | 1,264 | 3.796875 | 4 | [] | no_license | def bubble_sort(array)
shifting = true
while shifting
shift_count = 0
working_counter = 0
i = 0
while i < (array.length - 1)
if array[i] > array[(i + 1)]
array[i], array[(i + 1)] = array[(i + 1)], array[i]
working_counter += 1
... | true |
7cfe894f0bebb0bc6f8c4b65a4f21a087b2ffe20 | Ruby | nyc-fiery-skippers-2016/flash-and-dash-cards | /db/seeds.rb | UTF-8 | 1,098 | 2.9375 | 3 | [
"MIT"
] | permissive | Card.delete_all
card_content = [{question: 'What ended in the year 1919?', answer: '1918', deck_id: 1},
{question: 'It goes all over the world, but always stays in a corner. What is that?', answer: 'stamp', deck_id: 1},
{question: 'It goes up and comes down, but never move. What it is?', answer:'staircase',deck_id: ... | true |
f09969799f38a32c9424dc7002d27470cb00a4d7 | Ruby | sarahseewhy/student-directory_beta | /exercise6.rb | UTF-8 | 2,737 | 4 | 4 | [] | no_license | # Adding more information
#You can add more information info about students in the 'students' array or you can ask user for input
# students = => [
# {:name => "Mario Gintili", :cohort => :February, :hobby => :coding}
# {:name => "Mikhail Dubov", :cohort => :February, :hobby => :coding}
# {:name => "Karolis Noreika... | true |
143fc9f69eb25187aa02f53dbd3e22802a99289b | Ruby | LeftoverCurry/Hangman | /lib/game_data.rb | UTF-8 | 1,613 | 3.203125 | 3 | [] | no_license | # frozen_string_literal: true
require 'json'
require './lib/magic_word.rb'
# contains information to run or save a game.
class GameData
attr_accessor :user_name, :chosen_letters, :guesses_remaining
attr_accessor :letters_left_to_guess, :randomly_picked_word
def initialize(
user_name,
chosen_letters = []... | true |
8f989efa9e9caa71236f4984ad944a388f44e59d | Ruby | alf-tool/alf-core | /lib/alf/engine/materialize/array.rb | UTF-8 | 2,103 | 3.25 | 3 | [
"MIT"
] | permissive | module Alf
module Engine
#
# Provides in-memory materialization through a ruby Array.
#
# This class acts as a Cog, that it, it is an enumerable of tuples. An
# optional ordering can be passed at construction.
#
# Materialization occurs at prepare time, with auto-prepare on first
# ... | true |
4f65ab308c3db35428d4a2d995404cfa53a3b974 | Ruby | jodar/exercicios_algoritmos | /exercicios_arthur/folha_14/ex_14_15-1.rb | UTF-8 | 170 | 3.203125 | 3 | [] | no_license | a = [21, 12, 1, 0, 14, -4, -5, 42, 23, 32]
b = []
puts a.inspect
a.reverse_each do |item|
b.push << item
end
a.clear
b.each do |item|
a.push << item
end
print a
| true |
6346cccc34b8d7826dd9e970213faa0a37728129 | Ruby | afinebojangle/clickametrics | /db/seeds.rb | UTF-8 | 637 | 2.640625 | 3 | [] | no_license | require 'faker'
5.times do
user = User.new(
email: Faker::Internet.email,
password: Faker::Lorem.characters(10))
user.save!
end
users = User.all
50.times do
Website.create!(
user: users.sample,
url: Faker::Internet.url
)
end
websites = Website.all
100.times do
website = websites.sam... | true |
950289963457655cd5590bf22745f376bada106a | Ruby | panther99/srbot | /lib/core.rb | UTF-8 | 1,789 | 3.140625 | 3 | [] | no_license | require 'pretty-xml'
include PrettyXML
require_relative "helpers.rb"
class Bot
# Creates new AIML constructor with defined bot name and version
#
# @param name [String] name of AIML document
# @param version [String] version of AIML used in document
def initialize(name, version="2.0")
@name = name
@content ... | true |
c3b5e75d350d13c0e349856ea416cd41059220d6 | Ruby | 4amic/Anagram_Generator | /app/models/word.rb | UTF-8 | 1,032 | 3.375 | 3 | [] | no_license | class Word < ActiveRecord::Base
before_save :add_letters, :downcase
validates_presence_of :text
def add_letters
characters = self.text.chars
alphabetized_characters = characters.sort
self.letters = alphabetized_characters.join
end
def downcase
self.text.downcase!
end
def self.find_anagrams(wo... | true |
506701aec6d8746a9b2a80d507ce3a90fed82a0b | Ruby | naridas/airport_challenge | /spec/airport_spec.rb | UTF-8 | 1,251 | 2.765625 | 3 | [] | no_license | require 'airport'
describe Airport do
let(:plane){ double :plane }
let(:weather){double :weather}
#let(:good_weather){ double :weather, stormy?: false}
#let(:bad_weather){ double :weather, stormy?: true }
subject(:airport){ described_class.new(weather, capacity = rand(100))}
it 'landing plane' do
allow(weath... | true |
64a78adde1a1b1d6e5607a425a59033d5ed0e02b | Ruby | sveredyuk/kottans_hometasks-1 | /1/task_1_simple_calculator.rb | UTF-8 | 890 | 3.984375 | 4 | [] | no_license | class Calculator
def initialize
@a = get_operand 'A'
@b = get_operand 'B'
@operation = get_operation
end
def calculate
result = @a.public_send(@operation, @b)
result.finite? ? result : "Division by zero? What a pity!"
end
private
def get_operand operand
print "Please, enter #{oper... | true |
b06184bac63ee983b17e16492445be04cee51965 | Ruby | mmdotz/tictactoe | /spec/gametestindex.rb | UTF-8 | 6,060 | 3.796875 | 4 | [] | no_license |
class Player
attr_reader :choice_array, :choice, :print_X, :build_computer_choice_array
def initialize
@choice_array = [] #didn't need @choice here because we assigned it when first used
@win = false
end
def build_choice_array #human choice array
@choice_array << @choice
end
def b... | true |
9df2eb8d30eb4138d2b16b24940a225a287b04f2 | Ruby | andersonrodriguesdelima/changedate | /app/models/change_date.rb | UTF-8 | 2,842 | 3.125 | 3 | [] | no_license | class ChangeDate < ApplicationRecord
def self.change_date(date, operacao, minutos)
return ArgumentError, "Data não pode ser vazia" if date.to_s.empty?
return ArgumentError, "Operação não pode ser vazia" if operacao.to_s.empty?
return ArgumentError, "Operação inválida. Somente são permitidas as operações ... | true |
f0cc9ff0bd483940c90f54a344699c8f0166311e | Ruby | Rooted1/Pizza_Gallery | /lib/p_buy_view.rb | UTF-8 | 4,453 | 3.3125 | 3 | [] | no_license | require_relative './p_readyforcheckout.rb'
require 'pry'
def create_order(pizza)
users_pizza = Pizza.find_by(pizza_name: pizza)
current_user = User.find_by(name: $name_input)
users_cart = Cart.find_or_create_by(user_id: current_user.id)
users_order = Order.create(pizza_id: users_pizza.id, cart_id: user... | true |
438eb1ce6b133d88feb2ea8e9cd2c34eee62f617 | Ruby | kssajith/nearby_parking | /lib/http_client.rb | UTF-8 | 189 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'net/http'
class HttpClient
attr_reader :client
def initialize(client = Net::HTTP)
@client = client
end
def get(uri)
uri = URI(uri)
client.get(uri)
end
end
| true |
a1eb83c597fea647a3d138df2584fafae57ba9c7 | Ruby | Bayonnaise/Week-4-challenge | /Level1/spec/new_inject_spec.rb | UTF-8 | 1,681 | 3.21875 | 3 | [] | no_license | require 'new_inject'
describe Array do
let(:ary) { [1,2,3,4,5] }
context 'iteration approach' do
it 'sums a simple array using iteration' do
expect(ary.iteration_inject(0)).to eq 15
end
it 'sums the same array with no starting value' do
expect(ary.iteration_inject).to eq 15
end
it 'accepts a start... | true |
a7bc1b80be0b10f1d39c8e23b0d6c88e5831816b | Ruby | JramR7/mock-nequi | /app/db_managers/transaction_manager.rb | UTF-8 | 1,900 | 2.84375 | 3 | [] | no_license | require_relative 'helpers/validate_data'
require_relative '../models/transaction'
require_relative 'helpers/sql_query_executor'
class TransactionManager
include ValidateData
include SqlQueryExecutor
def insert(params)
if valid_data?(params)
if insert_execution('transactions', params)
transacti... | true |
1a2794802badb8537435d49b064eda647e127e9b | Ruby | momchenr/scratch | /app/helpers/users_helper.rb | UTF-8 | 435 | 2.578125 | 3 | [] | no_license | module UsersHelper
def location_display(user)
return "---" if user.city.blank? && user.state.blank?
return user.city.camelcase + ", " + user.state.upcase if user.state && user.city
return user.state.upcase if user.state && user.city.blank?
return user.city.camelcase if user.city && user.state.blank?
... | true |
d745df2069c0bb78f7b7136393ffada34976dc92 | Ruby | viniciustferreira/cv_mail | /spec/xml_spec.rb | UTF-8 | 918 | 2.578125 | 3 | [] | no_license | require "./App/xml.rb"
describe "Xml" do
before(:all) do
@xml = Xml.new("./Config/dados_email_teste.xml","./Config/data.xml","./Config/body.xml","./Config/signature_teste.xml")
@data =
{
:domain => 'gmail.com',
:user => 'viniciustferreira.affairs',
:password => "S@ra5432Um",
:smtp => 'smtp.gma... | true |
bff798bbffc0cf2c46b85c25bfa725ef69075a94 | Ruby | MihaiLiviuCojocar/unbeatable-tic-tac-toe | /features/step_definitions/web_steps.rb | UTF-8 | 1,996 | 2.671875 | 3 | [] | no_license | Given(/^I am on the homepage$/) do
visit '/'
end
Then(/^I should see "([^"]*)"$/) do |text|
expect(page).to have_content text
end
When(/^I register$/) do
fill_in 'player_name', with: 'Mihai'
click_on 'Register'
end
Then(/^I should see a welcome message$/) do
expect(page).to have_content "Welcome, Mihai!"
e... | true |
8c0d9054cc1372adf7ca084b8f71d256caf01c1c | Ruby | newtypeV2/ruby-collaborating-objects-lab-dc-web-051319 | /lib/mp3_importer.rb | UTF-8 | 323 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_reader :path
attr_accessor :songs
def initialize(path)
@path = path
end
def files
fileArray=Dir[self.path+"/*.mp3"]
songs = fileArray.collect do |songtitle|
songtitle[21..]
end
end
def import
self.files.each {|x| Song.new_by_filename(x) }
end
e... | true |
90d82a8c3511f3a0650974e4cf96389607111259 | Ruby | ysaito8015/ex_ruby | /ex1704.rb | UTF-8 | 488 | 3.421875 | 3 | [] | no_license | # 配列にデータを作成
fruits = %W(apple banana cherry fig grape)
# "sample4.txt" を書き込みモードで新規に作成
file = File.open("sample4.txt", "w:UTF-8")
fruits.each do |fruit|
file.puts fruit
end
# ファイルを閉じる
file.close
# "sample4.txt" を読込モードでオープンする
file = open("sample4.txt", "r:UTF-8")
# ファイルからデータをすべて読み込み、それを表示する
print file.read
# ファイルを閉... | true |
a5bab8e48c4c85dd22b1c1f2529d58c9006188a8 | Ruby | NJichev/ruby-homework | /tasks/05/sample_spec.rb | UTF-8 | 3,592 | 2.921875 | 3 | [] | no_license | require 'rspec'
require_relative 'solution'
RSpec.describe DataModel do
let(:user_model) do
Class.new(DataModel) do
attributes :first_name, :last_name
data_store HashStore.new
end
end
describe '.attributes' do
it 'returns said attributes' do
expect(user_model.attributes).to match_... | true |
7ceaf59f601e8138538e5b527ca01d245656f7aa | Ruby | waneal/discord-ttsbot | /discord-voicebot.rb | UTF-8 | 3,009 | 2.859375 | 3 | [] | no_license | require 'discordrb'
require 'aws-sdk'
TOKEN = ENV['DISCORD_BOT_TOKEN']
VOICE_ID = ENV['POLLY_VOICE_ID']
TTS_CHANNELS = ENV['TTS_CHANNELS'].split(',')
SampleRate = "16000"
MP3_DIR = "/data/tts/mp3"
NAME_DIR = "/data/tts/name"
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: '!'
bo... | true |
2fea996adc37f02dce2fa21556814963a2d6ddbe | Ruby | Nuricz/TTPS-Ruby | /práctica-4/sinatra/ej6/app.rb | UTF-8 | 1,707 | 3.421875 | 3 | [] | no_license | require 'sinatra'
class NumberToX
def initialize(app)
@app = app
end
def call(env)
status, headers, response = @app.call(env)
new_response = response.map { |c| c.gsub(/\d/,'x') }
[status, headers, new_response]
end
end
use NumberToX
get '/' do
body "GET / lista t... | true |
08c8f7eca6c9f6f8937842ea9a6b59c4cf29a4d8 | Ruby | natyv/shakeItOff | /main.rb | UTF-8 | 2,736 | 2.609375 | 3 | [] | no_license | require 'date'
require 'json'
require 'sinatra'
require 'pg'
require "./db_config"
require './models/user'
require './models/food_item'
require 'fatsecret'
FatSecret.init('12c2ef215e604e3f8ed6853dfe478390','7cb2062d9146486eb1a137ace3819a2a')
enable :sessions
helpers do
def current_user
User.find_by(id: sessi... | true |
0527b39b3761b0b0215548bf7cff5c3dd9e0fcfd | Ruby | telegeniic/Escuela_Fime | /Ruby/PosNeg.rb | UTF-8 | 162 | 3.640625 | 4 | [] | no_license | print("ingresa un numero: ")
x = gets().to_i
if (x==0) then
puts("Es cero")
else if (x<0) then
puts("Es Negativo")
else
puts("Es Positivo")
end
end
| true |
097f85fb00d2035bb4bbdf3b60287878f004af78 | Ruby | kstephens/cabar | /lib/ruby/cabar/main.rb | UTF-8 | 4,668 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'cabar/base'
require 'cabar/configuration'
require 'cabar/loader'
require 'cabar/resolver'
require 'cabar/plugin/manager'
require 'cabar/command/manager'
require 'cabar/command/runner'
require 'cabar/observer'
require 'cabar/logger'
module Cabar
# Main bin/cbr script object.
class Main < Base
includ... | true |
4a95f9653c90938e3570d755a560b22ce610ed69 | Ruby | ErickG123/miniProjetosRubyOO | /classe_objeto.rb | UTF-8 | 113 | 2.59375 | 3 | [] | no_license | # Definindo uma classe
class MinhaClasse
end
# Instância de objeto
objeto = MinhaClasse.new
p objeto.object_id | true |
2d18f93e356cb1e983e3c8167f52433ca47314ac | Ruby | zunda/sleepy-test | /web.rb | UTF-8 | 644 | 2.828125 | 3 | [] | no_license | # vim: ts=3 sw=3:
require 'sinatra'
usage='/?spinup=<WAIT_SEC>;interval=<INTERVAL_SEC>;repeat=<REPEAT_NUMBER>'
get '/' do
content_type 'text/plain'
par = Hash.new
%i(spinup interval repeat).each do |k|
par[k] = (params[k] || 0).to_i
end
stream do |out|
$stdout.puts "Sleeping for #{par[:spinup]} sec for spinu... | true |
1b11391fdab4559720d689c4153b78491e991f10 | Ruby | cbbakshi/CS.169.1x | /HW1/ex1.rb | UTF-8 | 235 | 3.328125 | 3 | [] | no_license | def palindrome?(string)
string.downcase.gsub(/[^A-Za-z]/,'') == string.downcase.reverse.gsub(/[^A-Za-z]/,'')
end
def count_words(string)
result = Hash.new(0)
string.downcase.scan(/\w+/).each{|word| result[word]+=1}
result
end
| true |
52d9096059bfc8c9133224bb8adc2f848d5cbc6d | Ruby | nickmarrone/euler | /problems/003-largest-prime-factor.rb | UTF-8 | 92 | 2.8125 | 3 | [] | no_license | require '../lib/fixnum'
number = 600851475143
factors = number.factors
puts factors.last
| true |
dd21607f90d63d23b0da301609cfb0a11889f2be | Ruby | coolsun/heist | /lib/heist/runtime/callable/macro/tree.rb | UTF-8 | 6,018 | 3.359375 | 3 | [
"MIT"
] | permissive | module Heist
class Runtime
class Macro
# <tt>Tree</tt>s are used by instances of +Matches+ to store expressions
# matched by macro patterns. Patterns may contain patterns that repeat
# (indicated by following the pattern with an ellipsis), and these
# repetitions may be nested. +Tre... | true |
e36f75c7079c56fe84dc03193d7a423cc65cd383 | Ruby | kevindjacobson/minecraft_api | /lib/minecraft_api.rb | UTF-8 | 699 | 2.890625 | 3 | [] | no_license | require 'socket'
require 'io/wait'
require_relative 'world'
require_relative 'camera'
require_relative 'player'
class MinecraftApi
attr_reader :world
attr_reader :camera
attr_reader :player
def initialize(host = 'localhost', port = 4711)
@socket = TCPSocket.new host, port
@world = World.new(self)
... | true |
d3a348d89bbc7278abffe5546c44317c9b0e3139 | Ruby | vertige/Scrabble | /lib/game.rb | UTF-8 | 4,158 | 3.953125 | 4 | [] | no_license | require_relative 'dictionary'
require_relative 'tile_bag'
require_relative 'player'
require_relative 'scoring'
require_relative 'board'
module Scrabble
class Game
attr_reader :board, :tile_bag, :dictionary, :players
def initialize
@board = Scrabble::Board.new
@tile_bag = Scrabble::TileBag.new
... | true |
96db0ad8ac9c23232e7e52d35a36239c3005169c | Ruby | afonsir/experiments | /ruby/optimization/fibo.rb | UTF-8 | 458 | 3.3125 | 3 | [] | no_license | require 'benchmark'
def fib(nth)
return if nth.negative?
seq = [0, 1]
(1...nth).each { |i| seq << seq[i - 1] + seq[i] }
seq[nth]
end
def r_fib(nth)
return 1 if [0, 1].include? nth
r_fib(nth - 1) + r_fib(nth - 2)
end
memory_before = `ps -o rss= -p #{Process.pid}`.to_i / 1024
time = Benchmark.realtime... | true |
866bbe518a7f643594f127ae3346a3e36642cb6b | Ruby | kinsbrunner/interview-cake-ruby | /13-find-rotation-point/lib/Dictionary.rb | UTF-8 | 966 | 3.875 | 4 | [] | no_license | class Dictionary
attr_reader :words
def initialize(words = [])
@words = words
end
def find_rotation_point
first_word = words[0]
floor_index = 0
ceiling_index = words.length - 1
# Improvement to be able to process fully-ordered arrays
return 0 if first_word < words[-1]
... | true |
709b5c50833b70d1bfa15c5d711dedc5794a3a40 | Ruby | MartinCrane/reverse-each-word-web-0217 | /reverse_each_word.rb | UTF-8 | 230 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
arr = string.split(" ")
# sentence = ""
# arr.each do |word|
# sentence = sentence + word.reverse + " "
# end
# sentence = sentence[0..-2]
(arr.collect {|x| x.reverse}).join(" ")
end
| true |
f3b3e2f19af08a38a4f564499034e5ce04255f37 | Ruby | dafurios/taller-rack | /desafio-rack2/config.ru | UTF-8 | 1,716 | 3.03125 | 3 | [] | no_license | # Ejercicio 02
require 'rack'
class MiSegundaWebApp
# def call(env)
# if env['REQUEST_PATH'] == '/'
# [202, { 'Content-Type' => 'text/html' }, ['<h1> INDEX </h1>']]
# end
# end
# end
def call(env)
case env['REQUEST_PATH']
when '/'
[202, { 'Content-Type' => 'te... | true |
ddf9be4a1cdac8142633133502a7dfe96e5a3d9a | Ruby | mkopsho/oo-student-scraper-onl01-seng-ft-050420 | /lib/scraper.rb | UTF-8 | 1,054 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
page = Nokogiri::HTML(open(index_url))
page.css(".student-card").collect do |student|
{
:name => student.css(".student-name").text,
:location => student.css(".student-location").text,
:profile... | true |
870adadd39b040f32b691186dbbf5228f29d81f3 | Ruby | satgo1546/project904 | /check.rb | UTF-8 | 1,818 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby
def no(i, line)
puts "#{i.to_s} #{line}"
system "pause"
end
File.open("data.txt", "r") do |f|
pattern = {
:page => /^\[\d+\]$/,
:chinese_sentence => /^[“”A-Za-z0-9]*[一-龠][A-Za-z0-9一-龠,。、;:‘’“”!?·《》()]+$/,
:english_sentence => /^[ -~‘’“”]+ [ -~‘’“”]+$/,
:english_word => /^[A-Za-z]+$/,
... | true |
6b937c4aa12ff6210c21c13606ccffc6ec8db6b0 | Ruby | jnastya/bases-Ruby | /lesson3/module_accessor.rb | UTF-8 | 820 | 2.90625 | 3 | [] | no_license | module Accessors
def attr_accessor_with_history(*names)
attr_accessor :history
names.each do |name|
var_name = "@#{name}".to_sym
define_method(name) { instance_variable_get(var_name) }
define_method("#{name}=") do |value|
instance_variable_set(var_name, value)
@history ||= {... | true |
499fc4efaaf78ef984bde944440c92efa698d931 | Ruby | project-kotinos/reinteractive___wallaby | /lib/utils/wallaby/cell_utils.rb | UTF-8 | 1,022 | 2.53125 | 3 | [
"MIT"
] | permissive | module Wallaby
# Cell utils
module CellUtils
class << self
# Render a cell and produce output
# @param context [ActionView::Context]
# @param file_name [String]
# @param locals [Hash]
# @return [String] output
def render(context, file_name, locals = {}, &block)
snake_... | true |
36ba7e59617cd84352cdb89468255ee5b3db2618 | Ruby | AnaBoca/bootcamp-ruby-challenges | /linkedlist2_challenge.rb | UTF-8 | 1,335 | 4.1875 | 4 | [] | no_license | # Reverse a linked list using mutation
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node = nil)
@value = value
@next_node = next_node
end
def print_values(list)
if !list
puts "nil\n"
return
else
print "#{list.value} --> "
... | true |
f1b14e3ace92ecbf7d356c6fc7eb66a2be2abef7 | Ruby | eduardodelcastillo/Calculator | /calculator.rb | UTF-8 | 1,478 | 4.21875 | 4 | [] | no_license | #calculator.rb
result = 0
operation = ""
operator = ""
num1 = 0
num2 = 0
quit_var = ""
def say(msg)
puts "------ #{msg} ------"
end
class String
def numeric?
Float(self) != nil rescue false
end
end
loop do
loop do
say("Please enter the first number (q to quit).")
num1 = gets.chomp
quit_var =... | true |
d4993d2de762fbbe3116734c9a5212a908430bb5 | Ruby | lpotepa/euler | /19.rb | UTF-8 | 765 | 4 | 4 | [] | no_license | def solution
count = 0
last_starting_day = nil
(1901..2000).each do |year|
(1..12).each do |month|
starting_day = last_starting_day || 6
month_days = month_days(month, year)
(starting_day..month_days).step(7).each do |day|
last_starting_day = 7 - (month_days - day)
count += 1... | true |
3263e1fb5ab03b808eb1a92befca73001c2efd48 | Ruby | celluloid/celluloid | /lib/celluloid/proxy/sync.rb | UTF-8 | 800 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # A proxy which sends synchronous calls to an actor
class Celluloid::Proxy::Sync < Celluloid::Proxy::AbstractCall
def respond_to?(meth, include_private = false)
__class__.instance_methods.include?(meth) || method_missing(:respond_to?, meth, include_private)
end
def method_missing(meth, *args, &block)
rai... | true |
5bd37f2f4a8c3daf7500643eae9b55e6e0ae85aa | Ruby | MadeInMemphisEntertainment/lyrics_finder | /spec/lyrics_finder/providers/lyrics_mania_spec.rb | UTF-8 | 526 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
describe LyricsFinder::Provider::LyricsMania do
describe '.format_url' do
context 'with valid author and title' do
let(:song) { Song.new("amêricàn authors", "best day of my life") }
let(:lyrics_mania) { LyricsFinder::Provider::LyricsMania.new(song) }
let(:valid_url) { "http://... | true |
f9ccf4f092cd8a8d8cd4bb18ee243d0adbf7cb4d | Ruby | FKnottenbelt/LS_100_part1 | /lssg_problems/session_6apr2018/easy.rb | UTF-8 | 802 | 4.3125 | 4 | [] | no_license |
# Write a function that takes in a string of one or more words,
# and returns the same string, but with all five or more letter words
# reversed. Strings passed in will
# consist of only letters and spaces. Spaces will be included only
# when more than one word is present.
# i: sentence
# o: string with words of ... | true |
3e59fd1b24cfb5053c2ec98424bbeb4cc33ee6a8 | Ruby | curvgrl5000/Shaw_Exercises | /ext37.rb | UTF-8 | 49,361 | 4.40625 | 4 | [] | no_license | # EXERCISE 37: SYMBOL REVIEW
###############################################################################################
# It's time to review the symbols and Ruby words you know, and to try to pick up a few more for the next few lessons. What I've done here is written out all the Ruby symbols and keywords t... | true |
9d5e61b6b521d98f8b8f49978af7bf2884c8f948 | Ruby | Bismarck-GM/using-new-ruby-linters | /launch_school_exercises/001.rb | UTF-8 | 170 | 3.375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
new_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
new_array.each do |v|
puts v
end
# Could've used also new_array.each { |value| puts value }
| true |
76eeae2233f8785ef4282f41ff391bda02e69c78 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/01aecafedee843a4ab09669470a07f5a.rb | UTF-8 | 326 | 3.3125 | 3 | [] | no_license | require 'byebug'
class Hamming
def self.compute(mydna, yourdna)
combinedsequence = mydna.chars.zip(yourdna.chars)
debugger
differencecount = 0
combinedsequence.each{|x,y|
if (x != y) && !(x.nil?) && !(y.nil?)
differencecount = differencecount + 1
end
}
differencecount
en... | true |
5ed8992a3d53c8e4a796532de6d663e2bb99a1b7 | Ruby | atalanda/atalogics_api | /examples/example_address_check.rb | UTF-8 | 1,882 | 2.65625 | 3 | [
"MIT"
] | permissive | lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'atalogics_api'
AtalogicsApi.configure do |config|
config.client_id = "XXXXXXXXXXXXXXXXXXXXXXXXX"
config.client_secret = "XXXXXXXXXXXXXXXXXXXXXXXXX"
end
# generate a new client
client = AtalogicsApi::Clie... | true |
45bf6937bd95e9e8048a243780ae82b45e8c1131 | Ruby | elapassarelli/NewElectionSite | /KWK/projects/game_of_swordz/game.rb | UTF-8 | 429 | 2.609375 | 3 | [] | no_license | require_relative 'player.rb'
JamesBond007 = Player.new("James Bond")
JamesBond007.status_report
Ela = Player.new("Ela Passarelli")
Ela.status_report
EvaaUtzz = Player.new("Eva Utz")
EvaaUtzz.status_report
JamesBond007.attack(Ela)
JamesBond007.status_report
Ela.status_report
Ela.attack()
Ela.status_report
JamesBond0... | true |
a7fd20f65c552eec236db3b612f379a204c255a5 | Ruby | kradul/bewd_sf_12 | /05_Classes_Objects/solutions/hw_store_solution/lib/customer.rb | UTF-8 | 1,690 | 3.9375 | 4 | [] | no_license | #use this file to define a class that will represent a customer
class Customer
attr_accessor :name, :money, :shopping_cart
def initialize(name, money)
@name = name
@money = money
@shopping_cart = {}
end
def add_to_cart (store, item, num)
#code here
#look up the item's price in the store
price = store... | true |
d9d263983a654d38976ec9e2f237fa1515787800 | Ruby | adamcooke/moonrope | /lib/moonrope/html_generator.rb | UTF-8 | 2,487 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'fileutils'
require 'moonrope/doc_context'
module Moonrope
class HtmlGenerator
def initialize(base, template_root_path)
@base = base
@template_root_path = template_root_path
end
attr_reader :base
attr_reader :template_root_path
def host
ENV['MR_HOST']
... | true |
365d61a73543711daab09138cd26468c0943a68e | Ruby | CodingDojoDallas/ruby-oct-2016 | /Guerrero_Melissa/animals/mammal.rb | UTF-8 | 206 | 3.671875 | 4 | [] | no_license | class Mammal
attr_accessor :alive, :health
def initialize(alive, health)
@alive=True
puts "I am alive!"
@health=150
self
end
def display_health
puts "The health score is #{@health}."
end
end | true |
e59cbde4180e29b47c0fb023db492b05f2fb1f93 | Ruby | firrds/DXRuby-Game-Tutorial | /answer/q1-1.rb | UTF-8 | 947 | 3.125 | 3 | [] | no_license | # coding: utf-8
require 'dxruby'
x = 400
y = 0
image = Image.load_tiles("./character.png", 4, 4)
# Sprite.new とはゲーム上でキャラクタを扱う為に使用するメソッドで、
# このメソッドによって作られたデータを使うことで、
# キャラクタの位置の変更や衝突の判定を簡単に行うことが出来る
sample_sprite = Sprite.new(x, y, image[0])
Window.loop do
# sample_sprite という Sprite データの x 座標をプラス 1 する... | true |
65895039fe7be44c57f8e6df66341d002c982333 | Ruby | standevenjw/euler | /project21.rb | UTF-8 | 433 | 3.703125 | 4 | [] | no_license | #Project 21 from projecteuler.net
#Evaluate the sum of all the amicable numbers under 10000
#Coded by: James Standeven
#!/usr/bin/env ruby
arr = [0, 1]
sum = 0
top = 10000
def divisors n
list = []
m = 1
while m <= n/2
if n % m == 0
list << m
end
m += 1
end
list
end
0.upto(top){|c| arr[c... | true |
94600b783a72da02634607438932378ba6b09250 | Ruby | 12Starlight/App-Academy-Master | /Immersive/W6D3/Paired Exercise/Chess/board.rb | UTF-8 | 2,755 | 3.71875 | 4 | [] | no_license | require_relative 'pieces'
require "byebug"
class Board
attr_reader :grid
def initialize
@grid = Array.new(8) { Array.new(8)}
# Setup nullpieces
(2..5).each do |row|
(0..7).each do |col|
@grid[row][col] = NullPiece.instance
end
end
# Setup pawns
... | true |
ec5bd7f59bcede300ae7e97d49bbb3a1ac2456d6 | Ruby | VanessaVViana/TestesUnitarios-RubyRspec | /unitarios/spec/bank/saque_cp_spec.rb | UTF-8 | 1,707 | 2.796875 | 3 | [] | no_license | require_relative '../../app/bank'
describe ContaPoupanca do
describe 'Saque' do
context 'Quando o valor é positivo' do
before(:all) do
@cp = ContaPoupanca.new(1000.00)
@cp.saca(200.00)
end
it 'entao atualiza saldo' do
expe... | true |
bcd07473a3faa0eea58ddb5f6cfadcb41fa39fed | Ruby | ardnek/parsing-http | /lib/parse_request.rb | UTF-8 | 1,436 | 3.34375 | 3 | [] | no_license | # write your code here
http_request = File.read('../data/get_request.txt').split("\n")
#blueprint
class Request
attr_accessor :request
def http_verb
@request[0].split(" ")[0]
end
def version
@request[0].split(" ")[2]
end
def path
@request[0].split(" ")[1].split("?")[0]
end
def query_par... | true |
2fff1dd6315ee509021c90cf247a4410c399a3df | Ruby | wallacerunner/ruby_code_dump | /kata/ipv4toint32.rb | UTF-8 | 516 | 3.125 | 3 | [] | no_license | # Take IPv4 address, convert every octet of it to binary, join and covert the
# result into an integer
def ip_to_int32(ip)
ip.split('.').map { |octet| octet.to_i.to_s(2).
prepend('0' * (8 - octet.to_i.to_s(2).length)) }.join.to_i(2)
end
require 'ipaddr'
def ip_to_int32_require(ip)
x = IPAddr.new(ip).to_... | true |
3356ff6f800eedb4bd5e180a5bb1f256e530efc1 | Ruby | bbensky/pine_ruby_exercises | /chris_pine_ex/ch9_classes.rb | UTF-8 | 4,491 | 3.828125 | 4 | [] | no_license | =begin
a = Array.new + [12345]
b = String.new + 'hello'
c = Time.new
puts 'a = ' + a.to_s
puts 'b = ' + b.to_s
puts 'c = ' + c.to_s
time = Time.new
time2 = time + 60
puts time
puts time2
≈
puts Time.mktime(2000, 1, 1)
puts Time.mktime(1976, 8, 3, 10, 11)
puts Time.mktime(1979, 5, 27) - Time.mktime(1976, 8, 2... | true |
d3785c9c3f261802a8e5e49ce687b4582c7732a8 | Ruby | dsawardekar/riml | /test/integration/riml_commands/compiler_test.rb | UTF-8 | 6,516 | 2.640625 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../../test_helper', __FILE__)
class RimlCommandsCompilerTest < Riml::TestCase
test "riml_source raises error if the file is not in Riml.source_path" do
riml = <<Riml
riml_source "nonexistent_file.riml"
Riml
assert_raises Riml::FileNotFound do
compile(riml)
end
end
... | true |
e6199cc5a75067ebc9e15999f7a929c26d8a377e | Ruby | almalee24/school-domain-onl01-seng-ft-081720 | /lib/school.rb | UTF-8 | 464 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_reader :roster, :school_name, :student_name
def initialize(school_name)
@school_name = school_name
@roster = {}
end
def add_student(student_name, grade)
if @roster[grade]
@roster[grade] << student_name
else
@roster[grade] = []
@roster[grade] << student_na... | true |
d5ba411b3c01aeb9ec21bf296ff63a195a0ff3c8 | Ruby | learn-co-students/web-060517 | /quizzes/customer.rb | UTF-8 | 287 | 3.171875 | 3 | [] | no_license | class Customer
attr_writer :name
attr_reader :name
def initialize(name, hometown)
@name = name
@hometown = hometown
end
def name
@name
end
def foo
self.name
end
end
customer = Customer.new
customer.name = 'bob'
customer.name
-> "bob"
<@name="bob">
| true |
91d5d8b6f37f2eae29f6d2dc88e2ca11d4fb86b2 | Ruby | ehrenmurdick/space | /src/states/warp.rb | UTF-8 | 2,144 | 2.703125 | 3 | [] | no_license | require 'yaml'
require './src/obj/npc'
class Warp < Chingu::GameState
traits :viewport, :timer
attr_accessor :player
attr_reader :danger, :song
def initialize(old_system, new_system)
super()
@old_system = YAML.load(File.read("data/systems.yml"))[old_system]
@new_name = new_system
@new_system = Y... | true |
af485a82561d28e5de6a4f49f19ab796d87ffefd | Ruby | arathunku/rulsp | /count.rb | UTF-8 | 53 | 2.5625 | 3 | [] | no_license | puts ARGV[0].to_i.times.inject(0) { |acc| acc + 1 };
| true |
74db6d81fadf15c28d4f725780a3c7103dd2c209 | Ruby | Geek24/ruby_practice | /polymorphism.rb | UTF-8 | 431 | 4.03125 | 4 | [] | no_license | # Practice for how polymorphism works in Ruby
class Bird
def tweet(bird_type)
bird_type.tweet # calling its version of tweet here
end
end
class Cardinal < Bird #inherit from bird
def tweet
puts "Tweet"
end
end
class Parrot < Bird
def tweet
puts "Squawk"
end
end
generi... | true |
bcd96a832d93ae09212b654aa14298332d97ea66 | Ruby | Nilsyy/reinforcements | /bonus.rb | UTF-8 | 623 | 3.28125 | 3 | [] | no_license | documentary = "Cowspiracy"
drama = "Riverdale"
comedy = "Mr. Bean"
dramedy = "Glee"
puts "On a scale of 1-5, rate documentaries:"
documentary_answer = gets.to_i
puts "On a scale of 1-5, rate dramas:"
drama_answer = gets.to_i
puts "On a scale of 1-5, rate comedies:"
comedy_answer = gets.to_i
if documentary_answe... | true |
cfe3658390556810a03cf13725f6c0b838a418a8 | Ruby | miura1729/mruby-meta-circular | /sample/pjson.rb | UTF-8 | 5,898 | 3.296875 | 3 | [] | no_license | class Array
def each(&block)
return to_enum :each unless block
idx = 0
while idx < length
block.call(self[idx])
idx += 1
end
self
end
end
class Context
WHITE_SPACES = [" ", "\t", "\r", "\n"]
NUMBER_LETTERS = '0123456789+-.eE'
HEX_LETTERS = '012345678... | true |
c0e1ece91414db17fa5912b59d9467f3190ff95a | Ruby | MaryCrisEstudillo/Ruby-Activities | /rubyactivities/abstraction.rb | UTF-8 | 1,264 | 4.03125 | 4 | [] | no_license | class Transaction
def initialize
puts "What do you want to do?"
chooseTransac = gets.chomp
if chooseTransac == "deposit"
puts "Enter Deposit Amount:"
@deposit = gets.chomp.to_i
@currentMoney = 200
deposit_amount
elsif chooseTr... | true |
b52a44f12d470fda01714fefec7a0ce22a46c8d3 | Ruby | skellock/sugarcube | /spec/uiimage_spec.rb | UTF-8 | 16,493 | 2.640625 | 3 | [
"BSD-2-Clause"
] | permissive | describe 'UIImage' do
describe 'UIImage.canvas' do
it 'should create an image' do
UIImage.canvas(size: [10, 10]).should.is_a UIImage
end
it 'should have the right size' do
CGSizeEqualToSize(UIImage.canvas(size: [10, 10]).size, [10, 10]).should == true
end
it 'should return width' d... | true |
52770c05042313ace28e222880f4425afe301bbb | Ruby | deborahleehamel/exercism | /ruby/sieve/sieve.rb | UTF-8 | 292 | 2.90625 | 3 | [] | no_license | class Sieve
def initialize(limit)
@limit = limit
end
def primes
range = (2..@limit).to_a
numbers = []
while range.any?
numbers << (pick = range.shift)
range.reject! { |n| n % pick == 0 }
end
numbers
end
end
module BookKeeping
VERSION = 1
end
| true |
a9d247249f553a8702e63d726885198dfc6beee3 | Ruby | vnqthai/railway-system | /lib/railway/models/line_station.rb | UTF-8 | 670 | 3.40625 | 3 | [] | no_license | # A connection between Line and Station
# Store information represents this Line-Station connection:
# - line: Line object. See line.rb.
# - station: Station object. See station.rb.
# - number: station number (1, 2, 32, etc.)
# - open_at: date of opening, can be in the past or in the future
class LineStation
attr_acc... | true |
82dde1a0972475e75cd604f315c0bc7ae3e2b5bd | Ruby | MASisserson/rb101 | /lesson_3/easy_1/1.rb | UTF-8 | 175 | 3.90625 | 4 | [] | no_license | # Question 1
numbers = [1, 2, 2, 3]
numbers.uniq
puts numbers
# The above code should print:
# 1
# 2
# 2
# 3
# #uniq! is mutating. #uniq is not. numbers remains the same.
| true |
36aed5a048d9aa1517efb91ac06245b271605f59 | Ruby | soimort/pi | /pi | UTF-8 | 19,655 | 2.578125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# coding: utf-8
"""
pi -- A simple pandoc wrapper that does the trick
URL: https://github.com/soimort/pi
Author: Mort Yao <soi@mort.ninja>
Dependencies:
- ruby >= 2.2
- listen ~> 3.0
- pandoc >= 1.15
"""
require 'date'
require 'logger'
require 'open3'
require 'optparse'
require 'webri... | true |
c35948e5462fd1344402791a2fd14258d38d57a8 | Ruby | jdhunterae/sim-venture | /rb_v/tests.rb | UTF-8 | 681 | 3.140625 | 3 | [
"MIT"
] | permissive | require './utils.rb'
require './actions.rb'
require './characters.rb'
require './battles.rb'
def test_character_stats
people = [Fighter.new, Cleric.new, Mage.new, Thief.new]
people.each { |person| puts person.get_sheet }
end
def test_monsters
monsters = [Orc.new, Goblin.new]
monsters.each { |monster| puts m... | true |
39c9a7316ea1bef10f3339f734bd04a304d63c9d | Ruby | aryaziai/simple-blackjack-cli-sf-web-091619 | /lib/blackjack.rb | UTF-8 | 1,124 | 4 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
rand(1..11)
end
def display_card_total(total)
total
puts "Your cards add up to #{total}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
get_user_input = gets.chomp
end
... | true |
73f82fa3d9f0ce91d5fb176854d30ae574fa7bca | Ruby | YukalatasKaslet/self | /Dummy_class.rb | UTF-8 | 585 | 4.09375 | 4 | [] | no_license | puts "self es igual a: #{self}"
class DummyClass
def intance_method
puts "Dentro de un método de instancia"
puts "En este contexto self es igual a: #{self}"
end
def self.class_method
puts "Dentro de un método de clase"
puts "En este contexto self es igual a: #{self}"
... | true |
a1c71a2e384d1de04c79e38e645a9af60f3b6171 | Ruby | VasaStulo/Ruby | /Lab1_demo/lib/students.rb | UTF-8 | 625 | 2.75 | 3 | [] | no_license | #frozen_string_literal: true
require 'csv'
# if (Gem.win_platform?)
# Encoding.default_external = Encoding.find(Encoding.locale_charmap)
# Encoding.default_internal = __ENCODING__
# [STDIN, STDOUT].each do |io|
# io.set_encoding(Encoding.default_external, Encoding.default_internal)
# end
# end
class Stu... | true |
926a57c7039e4e1484c7950d1ff9dbbc98d97122 | Ruby | aldelcy/IronHack-Class | /Week 1/Day 5/Chess/lib/pieces.rb | UTF-8 | 1,468 | 3.78125 | 4 | [] | no_license | #PIECES
require_relative "piece_info.rb"
require_relative "move_value.rb"
class Rook < Piece
include Move
def move?(x, y)
move_value(x, y)
if (@nw_x==0 && @nw_y>=0) || (@nw_x>=0 && @nw_y==0)
true
else
false
end
end
end
#===============================
class King < Piece
inc... | true |
093b2dc1b39a6a4e8762674b3d7467b6ee4049f6 | Ruby | KaminKevCrew/Jumpstart_Lectures | /old_lectures/3-30-W1D3_lecture.rb | UTF-8 | 4,316 | 4.09375 | 4 | [] | no_license | # Homework
def average_of_three(num1, num2, num3)
return (num1 + num2 + num3) / 3.0
end
# p average_of_three(5, 6, 8)
# a word is special if it starts with "c" OR has an even number of letters, but NOT both
# Write a method special_word? that takes in a string and returns true if the word is special
def sp... | true |
2000735af15c6334ccc0897fe4ca04f376ff17e0 | Ruby | yezideteachers/projet | /spec/models/personne_spec.rb | UTF-8 | 649 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe Personne do
before do
@personne = Personne.new(nom: "yezide")
end
describe "when name is not present" do
before { @personne.nom = " " }
it { should_not be_valid }
end
describe "when name is too long" do
before { @personne.nom = "a" * 45 }
it { should_not ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.