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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f1366ef46f960465b443b6c45fae187b8ff697f4 | Ruby | d-mv/newsletter | /webapp/lib/newsletter/parsers/process_article.rb | UTF-8 | 729 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
require 'net/http'
class ProcessArticle
def parse_medium(article)
url = article.children.at('link').next_sibling.to_s
@posts = PostRepository.new
return {} unless @posts.find_by_url(url).to_a.size.zero?
art_raw = Nokogiri::HTML(Net::HTTP.get(URI.parse url))
title ... | true |
23551efa57b39c3e656d175353202c2e35d336da | Ruby | mnipper/Chatterbot | /learner.rb | UTF-8 | 799 | 3.21875 | 3 | [] | no_license | require 'yaml'
class Learner
attr_reader :sentences, :waiting
def initialize
@waiting = false
begin
@sentences = YAML.load(File.read("learn_data")) || Hash.new{|h, k| h[k] = []}
rescue
raise "Can't load learn data"
end
end
def give_response(response)
@sentences[@last_unknown_s... | true |
05e701b52e8ff5198d948383c63e23d149c2577a | Ruby | salomekbg/caesar-cipher-web-0916 | /lib/caesar.rb | UTF-8 | 847 | 3.375 | 3 | [] | no_license | def caesar_encode(string, number)
alphabet = "abcdefghijklmnopqrstuvwxyz"
new_string = ""
string.split('').each do |char|
if alphabet.include?(char.downcase)
index = (alphabet.index(char.downcase) + number) % 26
new_string << alphabet[index] if char == char.downcase
new_string << alphabet[i... | true |
0327cf653b2b56f3436ee96fe79840f3835d456a | Ruby | tripeersyou/the_craft_central | /app/models/ending_inventory_product.rb | UTF-8 | 668 | 2.578125 | 3 | [] | no_license | class EndingInventoryProduct < ApplicationRecord
belongs_to :product
belongs_to :ending_inventory
validates :product, :ending_quantity, presence: true
validates :ending_quantity, numericality: { greater_than_or_equal_to: 0, allow_nil: false }
validate :ending_quantity_valid
def ending_quantity_valid
s... | true |
073cd4af184e62c942d436e6a8a9af3209cbae83 | Ruby | juliana06/book_ruby_intro | /Exercises/Strings/10.rb | UTF-8 | 132 | 2.703125 | 3 | [] | no_license | colors = "blue pink yellow orange"
puts colors.match?("yellow")
puts colors.match?("purple")
# or
# puts colors.include?("yellow") | true |
c5172d720dd525c4a5f782eccc41e8d509ec072a | Ruby | salo18/intro-to-ruby | /Exercises/e3.rb | UTF-8 | 188 | 4.0625 | 4 | [] | no_license | # Now, using the same array from #2, use the select method
# to extract all odd numbers into a new array.
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
arr_odd = arr.select do |x|
x.odd?
end
| true |
c40d66f70a79f876141452632c14d041e93e4f6c | Ruby | iguto/nothello | /lib/board_printer.rb | UTF-8 | 525 | 3.328125 | 3 | [] | no_license | class BoardPrinter
def initialize
end
def print(board)
puts print_first
print_panels(board)
end
private
def print_panels(board)
printable_panels = board.panels.map do |row|
row.map do |e|
TypeConverter.type_to_s(e.type)
end
end
printable_panels.each.with_index do |... | true |
40ac7b59084d0e8a22480e8ccde30e16ea0cfb24 | Ruby | susd/liberty-sis | /app/presenters/base_presenter.rb | UTF-8 | 391 | 2.84375 | 3 | [] | no_license | class BasePresenter
def initialize(object, template)
@object = object
@template = template
end
private
def self.presents(name)
define_method(name) do
@object
end
end
def tpl
@template
end
def method_missing(name, *args, &block)
if tpl.respond_to? name.to_sym
... | true |
56f6da327ff5870f88ae37458507177a604a5985 | Ruby | bv-hemant/Training | /linked_list.rb | UTF-8 | 2,754 | 3.8125 | 4 | [] | no_license | load "node_linked_list.rb"
class Linked_list
attr_accessor :head_node
def search_element(value)
result = false
current_node = @head_node
while current_node != nil
if(current_node.data == value)
result = true
break
end
current_node = current_node.next
end
return result
end
def delete_n... | true |
6dc18e170f770e4ef4bf14e64700aa55921d1cdb | Ruby | birdvisionapp/birdvision | /lib/modules/csv_importable.rb | UTF-8 | 2,325 | 2.65625 | 3 | [] | no_license | require 'csv'
module CSVImportable
def import_from_file(csv_file, entity)
import_from_content(csv_file.read, entity)
end
def import_from_content(csv_content, entity)
csv_table = parse_csv_content(csv_content)
check_headers(csv_table.headers, entity.headers)
check_for_duplicates(csv_table, entity... | true |
c2d3ada68851b13f9d4de6ae9ecfad85bedcf7f2 | Ruby | ralfpinheiro/Interactive-Math-Game | /players.rb | UTF-8 | 177 | 3.078125 | 3 | [] | no_license | class Players
attr_reader :name
attr_accessor :life, :turn
def initialize(name = 'Player')
@name = name
@life = 3
@turn = false
end
end | true |
6a084a5552c397a756c7f826e96dc69c89b34f54 | Ruby | Lucas-Rossetti/Ruby | /method/method-example.rb | UTF-8 | 161 | 3.640625 | 4 | [] | no_license | def calc()
print "First number\n"
a = gets.chomp.to_i
print "Second number\n"
b = gets.chomp.to_i
ans = a+b
puts "The sum is #{ans}"
end
calc()
| true |
039fc8e796bfa3f931245ee39350cce6bf4de3f1 | Ruby | ayanit1/ruby_practice | /lib/sum_without_highest_and_lowest_number.rb | UTF-8 | 205 | 3.21875 | 3 | [] | no_license | class SumArray
def sum_array(arr)
if arr.nil? || arr.size == 1
0
else new_arr = arr.sort
new_arr.delete_at(0)
new_arr.delete_at(-1)
new_arr.inject(0,:+)
end
end
end
| true |
c471dee1e267564f44cd114d1a2c77904c72240a | Ruby | laurasimmons30/korning | /import.rb | UTF-8 | 2,745 | 3 | 3 | [] | no_license | # Use this file to import the sales information into the
# the database.
require "pg"
require "csv"
def db_connection
begin
connection = PG.connect(dbname: "korning")
yield(connection)
ensure
connection.close
end
end
def exists_by_name?(name, table)
result = db_connection do |conn|
conn.exec(... | true |
f38920834c745aa71aa9708d81965c5978447f3d | Ruby | BkBky/blog_anonimo | /app/controllers/posts.rb | UTF-8 | 2,998 | 2.75 | 3 | [] | no_license | enable :sessions
get '/create' do
erb :create
end
#Mostrar el post creado
get "/post/:id" do
@post = Post.find(params[:id])
erb :post
end
#actualizar post
get "/update/:id" do
@edit = Post.find(params[:id])
@edit_tags = @edit.tags
erb :update
end
#mostrar post a borrar
get "/delete/:id" do
p "estoy ... | true |
4591793b68adfdf5e3f43e2a3820a1534e297338 | Ruby | wchiquito/IRONHACK-WDBAS2016-Week-2 | /Day-1/varios/fizzBuzz.rb | UTF-8 | 1,240 | 3.5 | 4 | [] | no_license | class FizzBuzz
def print_fizzbuzz number
fizzbuzz = divisible number, 3, 'Fizz'
fizzbuzz += divisible number, 5, 'Buzz'
fizzbuzz = number.to_s if fizzbuzz.empty?
fizzbuzz
end
def divisible number, divisor, text
return '' if not number.modulo(divisor) == 0
text
end
def fizzbuzz
@fizzbuzz = FizzBuzz.... | true |
835c7fdb49635afbbba231ddc1f5af94ad2807df | Ruby | hsandt/reminiscence | /src/tc_hub.rb | UTF-8 | 1,499 | 2.609375 | 3 | [] | no_license | require_relative "hub"
require_relative "input"
require_relative "settings"
require "test/unit"
class TestHub < Test::Unit::TestCase
def setup
Settings.create_instance
Settings.get.reading_time_factor = 0.05
Settings.get.wrap_line_length = 50
@input = StringIO.new
Input.create_instance @input
... | true |
01f47f6d6c6218b9fa93f1185eb96161f4cdde66 | Ruby | oclaussen/prompt-builder | /lib/prompt_builder/color.rb | UTF-8 | 4,782 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
# frozen_string_literal: true
#
# Copyright 2017, Ole Claussen <claussen.ole@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licens... | true |
5aac3ea09c2ee31c1620853727f38bec853ca247 | Ruby | jmooree30/Hangman | /hangman.rb | UTF-8 | 2,668 | 4.09375 | 4 | [] | no_license | require 'json'
load 'display.rb'
class Hangman
attr_accessor :name
@name = name
def initialize
puts "What is your name?"
@name = gets.chomp
puts "
################################################
HANGMAN
################################################
_________
... | true |
9c834f7edfc8f0a348a17fb80f4770fbdd6d9e0e | Ruby | BC-MAY-21-ROR/kata-02-el-juego-de-la-vida-dia-04-k02-t02-d04 | /src/grid.rb | UTF-8 | 2,809 | 3.5625 | 4 | [] | no_license | # frozen_string_literal: true
require_relative './reader'
require_relative './board'
require_relative './cell'
class Grid
def plain_matrix
cell_data = Reader.new.read_file
rows = cell_data.length
columns = cell_data[0].length
plain_cell_matrix = Array.new(rows) { Array.new(columns) }
cell_data.e... | true |
bb50e813e07d0a7e663e126c4848a1d1d1090632 | Ruby | causes/mogli | /spec/model_spec.rb | UTF-8 | 8,583 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class TestModel < Mogli::Model
set_search_type :test_model
define_properties :id, :other_property, :actions
creation_properties :other_property, :actions
has_association :comments, "Comment"
hash_populating_accessor :from, "User"
hash_populating_accessor :activities, "Activity"
hash... | true |
d070a4cf570c58776b0edefcc7f5329599afa4f7 | Ruby | bradparker/whenever | /app/models/day.rb | UTF-8 | 1,881 | 2.875 | 3 | [] | no_license | # frozen_string_literal: true
require "forwardable"
class Day
include TimeRange::Naming
def self.from_date(date, time_zone:, user_id:, event_range: nil)
new(
date.year,
date.month,
date.day,
time_zone: time_zone,
user_id: user_id,
event_range: event_range,
)
end
e... | true |
8b86f95c1228c4ba1fbd9570b2cbe9b3b61c49c3 | Ruby | ddemkiw/Takeway | /spec/menu_spec.rb | UTF-8 | 594 | 2.828125 | 3 | [] | no_license | require 'menu'
describe Menu do
let(:menu) {Menu.new}
before do
Menu.any_instance.stub(:puts)
end
it 'should know the available dishes and their prices' do
expect(menu.dishes).to be_a Hash
end
it 'should include peking duck' do
expect(menu.dishes).to include ({"peking_duck" => 3})
end
... | true |
2d0ecc6d8af95cb04d13ca61f86c4a645b42a9f9 | Ruby | zbadiru/ruby-project-guidelines-lon01-seng-ft-042020 | /app/models/player.rb | UTF-8 | 1,902 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Player < ActiveRecord::Base
PROMPT = TTY::Prompt.new
has_many :game_records
has_many :decks, through: :game_records
def self.player_names
Player.all.map {|player| player.name}
end
def self.select_a_player
puts "Please select a player."
player_names = Player... | true |
a4cb2fcdca116c4b0f2a5ffb6c20242716fc2492 | Ruby | joestephens/bank_tech_test | /lib/statement.rb | UTF-8 | 257 | 3.15625 | 3 | [] | no_license | # understands storing transactions
class Statement
attr_reader :transactions
def initialize
@transactions = []
end
def add_transaction(time, amount)
transaction = [time, amount]
@transactions << transaction
transaction
end
end
| true |
4e678b0999ecc6aa02e2949ffac2543c26607799 | Ruby | Talbatross/18xx | /lib/engine/abilities.rb | UTF-8 | 1,893 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | # frozen_string_literal: true
if RUBY_ENGINE == 'opal'
require_tree 'ability'
else
require 'require_all'
require_rel 'ability'
end
module Engine
module Abilities
def init_abilities(abilities)
@abilities = []
(abilities || []).each do |ability|
klass = Ability::Base.type(ability[:type]... | true |
8869ae0756b84a8db29549f440d89af26dcb128f | Ruby | kiran-gurujada/pickaxe | /chapter23/symbol_to_proc_trick.rb | UTF-8 | 205 | 3.203125 | 3 | [] | no_license | # Ruby implements +to_proc+ for symbols.
# So you can replace this:
names = %w{ ant bee cat }
result = names.map {|name| name.upcase}
# with this:
names = %w{ ant bee cat }
result = names.map(&:upcase)
| true |
6a8c927568c77ed5af0a0aa05b8f8789156bc5c5 | Ruby | au-research/ANDS-ResearchData-Registry | /applications/portal/core/assets/vendor/mustache/hooks/pre-commit | UTF-8 | 2,521 | 3.015625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'json'
def puts_c(color, str)
puts "\x1b[#{color}m#{str}\x1b[0m"
end
# for tracking if bump was needed
$bumped = false
def did_bump
if !$bumped
puts "bump detected!"
if `which uglifyjs`.empty?
puts_c 31, "you need uglifyjs installed"
puts "run `sudo npm install -g uglify-js`"
... | true |
6109f27c5f991039884ee277378281c679b5037e | Ruby | bmbrina/Hephaestus | /Classes/DimensionFactory.rb | UTF-8 | 2,856 | 3.390625 | 3 | [] | no_license | require_relative 'Program'
require_relative 'DimensionStructure'
#######################
# Description: This makes all the necessary mathematical calculations for
# dimensional variables
# Parameters: (program, type:Program, description: receives program in order to
# modify a variable)
# Return value: N/A
# Error han... | true |
bdeaeaf34b593e32361c6e603ca4109f5231181e | Ruby | Tracyaa/learn | /mod1/ruby-intro-to-arrays-lab-dumbo-web-career-012819/lib/intro_to_arrays.rb | UTF-8 | 386 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
arr = []
end
def array_with_two_elements
arr = [1, 2]
end
def first_element(arr)
arr[0]
# arr.first
end
def third_element(arr)
arr[2]
end
def last_element(arr)
arr[-1]
# arr.last
end
def first_element_with_array_methods(arr)
arr.first
end
def last_element_with_array_metho... | true |
9d22c7eaa07f0e47a4146bde105f9e8ac0a10a2e | Ruby | redding/ns-options | /test/system/proxy_tests.rb | UTF-8 | 1,812 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'assert'
require 'ns-options/assert_macros'
require 'test/support/proxy'
class SomeProxyIntTests < Assert::Context
include NsOptions::AssertMacros
desc "the integration test proxy module"
setup do
@proxy = SomeProxy
end
subject { @proxy }
should have_option :some, SomeProxy::SomeThing, {
... | true |
91387e2994553302e89bd7beeb8d69422252cfab | Ruby | martinsson/BugsZero-Kata | /ruby/spec/support/not_so_random_generator.rb | UTF-8 | 329 | 3.125 | 3 | [] | no_license | class NotSoRandomGenerator
def initialize(expected_results)
@cursor = -1
@expected_results = expected_results
end
def rand(upper_limit)
@cursor += 1
if @cursor >= @expected_results.size
raise "Not enough expected_results given"
end
(@expected_results[@cursor] * upper_limit).ceil
... | true |
5844443e5ecfb58f6719b708d89956965cbd9529 | Ruby | kaidee/kaidee | /ruby/letter_stuff.rb | UTF-8 | 82 | 3.09375 | 3 | [] | no_license | def random
(rand(26) + 65+32).chr
end
puts 97.chr
30.times{print random}
puts '' | true |
f4f99f1eb2ce97ea48c150fa9d10bf388cb9124e | Ruby | Jarrel09/intro_to_programming | /work/lesson_3/medium_3.rb | UTF-8 | 375 | 3.46875 | 3 | [] | no_license | #Question 3
# => "pumpkins"
#=> ["pumpkins", "rutabaga"]
# The string concatenation doesn't change the string variable because it doesn't
# mutate the caller. Rather, it creates a new object in memory. However, with
# with the << method for the array, it doesn in fact mutate the caller.
# Question 5
# def color_valid(... | true |
08549d20c2a592f8512f9bf913a45eed294839ea | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/1268.search-suggestions-system.rb | UTF-8 | 2,299 | 3.234375 | 3 | [] | no_license | #
# @lc app=leetcode id=1268 lang=ruby
#
# [1268] Search Suggestions System
#
# https://leetcode.com/problems/search-suggestions-system/description/
#
# algorithms
# Medium (63.46%)
# Total Accepted: 51.9K
# Total Submissions: 81.8K
# Testcase Example: '["mobile","mouse","moneypot","monitor","mousepad"]\r\n"mouse"\... | true |
3617bbfc87f33a5b662ec3a0b31efad616fa3b5d | Ruby | briangershon/s3backup | /lib/s3_bucket_list.rb | UTF-8 | 3,159 | 2.75 | 3 | [
"MIT"
] | permissive | require 'sqlite3'
class S3BucketList
CACHE_DATABASE_PATH = Pathname("s3_bucket_list.cache.db")
def initialize(s3_client, aws_bucket_name, s3_bucket_list_object_prefix, logger=nil)
@s3_client = s3_client
@aws_bucket_name = aws_bucket_name
@s3_bucket_list_object_prefix = s3_bucket_list_object_prefix
... | true |
8d401aeb538736cea95db8fb629148542c1f2371 | Ruby | TonyCWeng/Practice_Problems | /review/kth_largest_element.rb | UTF-8 | 151 | 3.046875 | 3 | [] | no_license | def find_kth_largest(arr, k)
arr.sort[-k]
end
# Array#sort is quicksort (nlog n). indexing into an array
print find_kth_largest([5,4,11,20,31], 2)
| true |
78d1f1b5ec94ad289f1906081bb5597e06771546 | Ruby | elizsutherland/Refactoring | /rps/round.rb | UTF-8 | 647 | 3.390625 | 3 | [] | no_license | class Round
hand = ["rock", "paper", "sciccors"]
def intialize
@player = player
@ai = ai
@round =[]
end
def pick_rps
@player.game_rules.1
@ai.game_rules.1
@round << player + ai
end
def show_hand
puts @round
end
private
@game_rules {
'rock/paper' => 'paper'
... | true |
09408ed21421b1028b9f7c47d6f082a0e1087ac4 | Ruby | anu5754/week1homework | /spec/01_object_spec.rb | UTF-8 | 933 | 3.296875 | 3 | [] | no_license | describe 'Everything is an Object!' do
it "Objects have methods" do
'two'.methods.should include :upcase
end
it "Objects have a class" do
'two'.class.should eq String
end
it "Objects can be sent messages" do
'two'.send(:upcase).should eq 'TWO'
# that code sends the message 'upcase' to the s... | true |
9f80a0b1bfdd5e08406cd8ca097c9350552e3d37 | Ruby | Carolinemay/kwk-l1-fizzbuzz-kwk-students-l1-dur-072318 | /fizzbuzz.rb | UTF-8 | 306 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # if x is divisable by 3and 5 do fizzbuzz
# if x is divisible by 3 return fizz
# if divisable by 5 return buzz
# if not divisable by either return nothing
def fizzbuzz(x)
if x % 3== 0 && x % 5== 0
"FizzBuzz"
elsif x % 3 == 0
"Fizz"
elsif x % 5 == 0
"Buzz"
else
end
end
| true |
8a9fcc86c0eaee1cc4e59e6086c1458ebfc7d3c3 | Ruby | kahahope/ROR_Thinknetica | /lesson2/numbers.rb | UTF-8 | 61 | 3.15625 | 3 | [] | no_license | array = []
10.step(100, 5) { |num| array << num }
puts array
| true |
061c79debc0e0320d4e098b950fc791a61090a31 | Ruby | alechoey/cs169-glookup | /midterm/merge_midterm_scores.rb | UTF-8 | 1,535 | 3.109375 | 3 | [] | no_license | # Returns a file containing student names and their corresponding multiple choice grade
# to input into Pandagrader
require 'csv'
require_relative '../csv_helpers'
# multiple_choice_grades_file = 'mult_choice_grades.csv'
# frq_grades_file = 'midterm1_grades.csv'
#
# merged_grades_file = 'multiple_choice_with_names.c... | true |
982b6ec339d6d67c0164ed68fc5d77a616733768 | Ruby | Antony-QP/EZ_Tenda_Hackathon | /app/models/auction.rb | UTF-8 | 800 | 2.546875 | 3 | [] | no_license | require 'date'
class Auction < ApplicationRecord
belongs_to :user
has_many :bids
CATEGORIES = ['gin', 'whisky', 'vodka', 'tequila', 'rum', 'beer', 'wine', 'lager', 'cider', 'craft_beer', 'bitter', 'stout', 'red_wine', 'white_wine', 'sparkling_wine', 'fortified_wine', 'champagne', 'carbonated_soft_drinks']
va... | true |
2aa9c4cb8bed94a0a28e360d2e1eaa75ef70de66 | Ruby | kitsuner/week2-day1 | /03_basics/basics.rb | UTF-8 | 517 | 3.1875 | 3 | [] | no_license | # write your code here
def who_is_bigger(a, b, c)
d = [a, b, c]
if a==nil || b==nil || c==nil
return "nil detected"
else
e = d.max
if d.index(e) == 0
return "a is bigger"
else
if d.index(e) == 1
return "b is bigger"
else
return "c is bigger"
end
end
end
end
def reverse_upcase_noLTA(a)
re... | true |
94876be07eb7b4f9286e203f9fa407d448d8058e | Ruby | stephengeller/tic-tac-toe-techtest | /lib/diagonal_formatter.rb | UTF-8 | 316 | 3.28125 | 3 | [] | no_license | class DiagonalFormatter
def format_array(board)
row_1 = board[0]
row_2 = board[1]
row_3 = board[2]
combine_arrays(row_1, row_2, row_3)
end
def combine_arrays(row_1, row_2, row_3)
arr = []
arr.push([row_1[0], row_2[1], row_3[2]])
arr.push([row_1[2], row_2[1], row_3[0]])
end
end
| true |
121cdab468ce5724cb679c6dd9d7a71cc65e6dba | Ruby | PiyushNankar12/Ruby_Training | /Yash Mekhe/Day3/ip_validate.rb | UTF-8 | 735 | 3.296875 | 3 | [] | no_license | def ip_validate(ip)
arr=ip.split('.')
num=arr[0].to_i
#ip++
#print num
num1=arr[1].to_i
num2=arr[2].to_i
num3=arr[3].to_i
if num>=1 && num<=255 && num1>=0 && num1<=255 && num2>=0 && num2<=255 && num3>=0 && num3<=255
print "Valid ip!!\n"
else
print "Invalid ip!!"
return
end
if num>=1 && num<=126
pri... | true |
0b075f49d7b7c988a7a1c5d87fc37dd06fef9c82 | Ruby | sdthameem/Udacitask | /udacitask.rb | UTF-8 | 883 | 3.15625 | 3 | [] | no_license | require_relative 'todolist.rb'
# Creates a new todo list
mylist = TodoList.new("Things to complete")
# Add four new items
mylist.add_item("Alarm ring")
mylist.add_item("Wake up")
mylist.add_item("Bath")
mylist.add_item("Ready to office")
# Print the list
mylist.print_list
# Delete the first item
mylist.remove_item(... | true |
3af71e17f92c54e7eddfc5a41c8b8a798578eadb | Ruby | zekroTJA/yuna | /src/davidgetter.rb | UTF-8 | 3,319 | 3.375 | 3 | [] | no_license | #!/usr/bin/ruby
require 'uri'
require 'open-uri'
require 'whenever'
# require_relative 'main'
class DavidGetter
def initialize (list_file, img_path)
@list_file = list_file
@img_path = img_path
end
# TEST URLS
# https://www.deviantart.com/art/The-Crypt-King-741021746
# https:/... | true |
4ffafd74bb61f35ffeb85023bc81b87d56de01e3 | Ruby | leahwho/grocery-store | /lib/customer.rb | UTF-8 | 1,182 | 3.65625 | 4 | [] | no_license | require 'csv'
class Customer
attr_reader :id
attr_accessor :email, :address
# method for initialize instance of customer
def initialize(id, email, address)
@id = id # this is an integer
@email = email # this is a string
@address = address # this is a hash
end
# reads CSV file data, in... | true |
56617de77dad0e71943cc9af853c4c1145c71157 | Ruby | Awlter/LaunchSchool_Walter | /180/5/re_psql_todos/sequel_persistence.rb | UTF-8 | 1,396 | 2.625 | 3 | [] | no_license | require 'sequel'
DB = Sequel.connect("postgres://localhost/todos")
class SequelPersistence
def initialize(logger)
DB.logger = logger
end
def find_list(id)
all_list.where(lists__id: id).first
end
def all_list
DB[:lists].left_join(:todos, list_id: :id)
.select do
[... | true |
5089094a27652a2fa2eb8a034b99b9a1253815c8 | Ruby | SephoraM/LS-120 | /lesson5/tic_tac_toe.rb | UTF-8 | 8,534 | 3.65625 | 4 | [] | no_license | module Joinable
DELIMITER = ','
JOINING_WORD = 'or'
def joinor(arr)
return arr.join("#{JOINING_WORD} ") if arr.size <= 2
arr[0..-2].join("#{DELIMITER} ") + " #{JOINING_WORD} #{arr.last}"
end
end
class Board
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + # rows
[[1, 4, 7], [2, ... | true |
39e6bdf6eeddd8c19dba8a66edb49f35e82221c3 | Ruby | zhulinpinyu/rabbitmq_example | /01_helloworld/receiver.rb | UTF-8 | 719 | 2.59375 | 3 | [] | no_license | require "bunny"
conn = Bunny.new(:hostname => "192.168.59.103",:automatically_recover => false)
conn.start
ch = conn.create_channel
q = ch.queue("hello")
begin
puts " [*] Waiting for messages. To exit press CTRL+C"
q.subscribe(:block => true) do |delivery_info, properties, body|
puts " [x] Received #{bo... | true |
9e4cd914f800812cc4b3ba97be5d6ff7c6fc386a | Ruby | nathanworden/100-Programming-Back-end-Prep | /001 Learn to Program/03. Variables and Assignment.rb | UTF-8 | 2,690 | 4.96875 | 5 | [] | no_license | # Variables and Assignment
# Chapter 3
# So far, whenever we have putsed a string or a number, the thing we putsed is gone. What I mean is, if we wanted to print something out twice, we would have to type it in twice:
puts '...you can say that again...'
puts '...you can say that again...'
# ...you can say that again... | true |
c979b518063ebce03d68ab10b2fb73a4dace2218 | Ruby | ljnezzy/crowdfund_rails | /app/helpers/projects_helper.rb | UTF-8 | 497 | 2.5625 | 3 | [] | no_license | module ProjectsHelper
def format_target_pledge_amount(project)
if project.we_need_help?
content_tag(:strong, 'We need your Help!!')
else
number_to_currency(project.target_pledge_amount)
end
end
def time_remaining(project)
from_time=Time.now
to_time=project.pledging_ends_on
days_remain... | true |
4690070a137a3a7239a5fed7de42a5f68e10097d | Ruby | ccankov/appacademy-homeworks | /w2d2/lib/board.rb | UTF-8 | 1,637 | 3.609375 | 4 | [] | no_license | require_relative 'player.rb'
class Board
attr_accessor :cups
def initialize(name1, name2)
@player1 = Player.new(name1, 1)
@player2 = Player.new(name2, 2)
@cups = []
place_stones
end
def place_stones
(0..13).each do |cup|
@cups[cup] = [6, 13].include?(cup) ? [] : %i(stone stone stone... | true |
7977723fabd7127346d04fe0bfb7a03b918897f3 | Ruby | ali-hassan/MultiCoupon | /spec/support/category_resolver.rb | UTF-8 | 406 | 2.84375 | 3 | [
"MIT"
] | permissive | # Give $10 discount when buying a Ruby book.
class CategoryResolver
def resolve(coupon, options)
category = options[:category]
book = options[:book]
return options if category.blank? && book.blank?
category = book.category if book
if category.name == 'Ruby'
options[:discount] = 10
o... | true |
14f2a460a0cfcd6851cb5f5eaabae90f1efd738d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/8f2a999110d94fb49f393fb492ffa607.rb | UTF-8 | 474 | 3.46875 | 3 | [] | no_license | require 'prime'
class Raindrops
def self.convert(number)
pling, plang, plong = false
prime_array = Prime.prime_division(number)
prime_array.each do |array|
prime_number = array.first
pling = true if prime_number == 3
plang = true if prime_number == 5
plong = true if prime_number ==... | true |
b85110c5a70d6decb04675aa2a6a272f16310980 | Ruby | sun-mit/Ruby | /module.rb | UTF-8 | 578 | 3.40625 | 3 | [] | no_license | module Swimmable
def swim
"I'm swimming!"
end
end
class Animal; end
class Fish < Animal
include Swimmable # mixing in Swimmable module
end
class Mammal < Animal
end
class Cat < Mammal
end
class Dog < Mammal
include Swimmable # mixing in Swimmable mo... | true |
1e511c5c4e5210db122e3313dad5b24485b51a1c | Ruby | BounGTKL/le_morpion | /app.rb | UTF-8 | 1,030 | 3.75 | 4 | [] | no_license | require "./lib/GameBoard.rb"
require "./lib/Player.rb"
def switch_player
@current_player == @player_1.name ? @current_player = @player_2.name : @current_player = @player_1.name #We define the switching between the two players
end
@player_1 = Player.new
@player_2 = Player.new
@current_player = @player_1.name
... | true |
12ceabccf1e3b09d735856af0a9d8268ed6ea8fd | Ruby | Fukkatsuso/AtCoder | /JoinedContest/ABC139F.rb | UTF-8 | 1,121 | 3.65625 | 4 | [] | no_license | # WA
def distance(x, y)
return ((x ** 2) + (y ** 2)) ** 0.5
end
n = gets.chomp.to_i
xy = []
xsum = 0
ysum = 0
n.times do
x, y = gets.chomp.split(" ").map(&:to_i)
xsum += x
ysum += y
xy << [x, y]
end
dist = distance(xsum, ysum)
d = [[0, 0]] * 4
dist = [0] * 4
(0..n-1).each do |i|
x ... | true |
157a5fd20cc7220bac8a8397b2add1db8f00883e | Ruby | PaulDebevec/pantry_1909 | /test/recipe_test.rb | UTF-8 | 1,137 | 2.984375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/recipe'
require './lib/ingredient'
class RecipeTest < Minitest::Test
def test_it_exists
mac_and_cheese = Recipe.new("Mac and Cheese")
assert_instance_of Recipe, mac_and_cheese
end
def test_it_initializes
mac_and_cheese = Recipe.new(... | true |
dcf6b6a28e3097faa6087ed9faabd3b1af1954a8 | Ruby | vdencheva/ruby-retrospective-1 | /solutions/02.rb | UTF-8 | 1,860 | 3.453125 | 3 | [] | no_license | class Song
attr_accessor :name, :artist, :genre, :subgenre, :tags
def initialize(name, artist, genre, subgenre, tags, artist_tags)
@name, @artist = name, artist
@genre, @subgenre, @tags = genre, subgenre, tags
add_tags_for_artist(artist_tags)
add_tags_for_genre()
end
private
def add_tags_fo... | true |
1ab7b133f96be3ba7b573c5d915ea3250c38f565 | Ruby | sowcow/testdo | /lib/testdo.rb | UTF-8 | 1,852 | 3.21875 | 3 | [
"MIT"
] | permissive | require "testdo/version"
require "testdo/capture"
def test &block
Testdo::Test.new.feed(&block).print
end
module Testdo
class Test
include Testdo
BASIC_EXPECTATIONS = %i[===]
CAPTURE = {
[Class,Time,Symbol,Rational,Integer,Hash,Bignum,Float,Complex,NilClass,Fixnum, Range, String, NilClass, Re... | true |
3f960e59b4c1c313356a8571864b894501bea97a | Ruby | agonopol/eatnbitch | /lib/core_extensions.rb | UTF-8 | 1,390 | 3.25 | 3 | [] | no_license | require 'date'
class Date
def self.yesterday
self.today - 1
end
end
class DateTime
def start_of_day
change(:hour => 0, :min => 0)
end
def start_of_month
change(:day => 1, :hour => 0, :min => 0)
end
def start_of_week
days_to_monday = self.wday!=0 ? self.wday-1 : 6
result = self - da... | true |
8d3d7d2273bb758cf4e203c52c9d6cca3748e07b | Ruby | twblalock/csvToJson | /csvToJson.rb | UTF-8 | 310 | 2.8125 | 3 | [] | no_license | require "csv"
require "json"
out = []
CSV.foreach(ARGV[0], {:headers => true}) do |row|
j = {}
row.each do |header, value|
if !j[header].nil?
raise "Duplicate column header: #{header}"
end
j[header] = value
end
out << j
end
puts JSON.pretty_generate(out)
| true |
c54c91ad23971852456260bd8e097e026f9d53ba | Ruby | weppos/hanami-controller | /lib/lotus/action/flash.rb | UTF-8 | 3,480 | 2.796875 | 3 | [
"MIT"
] | permissive | module Lotus
module Action
# Container useful to transport data with the HTTP session
# It has a life span of one HTTP request or redirect.
#
# @since 0.3.0
# @api private
class Flash
# Session key where the data is stored
#
# @since 0.3.0
# @api private
SESSION_K... | true |
c4808502c23e28768bcfdd271d129a7e1c590e13 | Ruby | mil/inc | /incscript.rb | UTF-8 | 6,422 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'yaml'
require 'pp'
require 'shellwords'
require 'fileutils'
# Colorizing strings
class String
def color(c)
colors = {
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:magenta => 35,
:cyan => 36,
... | true |
8ca2d37cd37e862b668fc558597cf27713989bc9 | Ruby | RobinHeathcote/tech_test_1 | /spec/8_spec.rb | UTF-8 | 295 | 2.6875 | 3 | [] | no_license | require './lib/8'
describe 'find nearest' do
it 'finds the index of a number in a sorted list' do
expect(find_nearest(6, [1, 6, 7, 9, 13])).to eq(1)
end
it 'finds the next largest number if the number doesnt exist' do
expect(find_nearest(8, [1, 6, 7, 9, 13])).to eq(3)
end
end
| true |
fd7c34925e1b6548d06356bf2a49ab7e62174bfa | Ruby | zitsel/supero | /app/models/dress_shoe.rb | UTF-8 | 1,586 | 2.609375 | 3 | [] | no_license | class DressShoe < Product
store_accessor :properties, :brand, :maker, :model, :model_number, :style, :color, :size_only, :width, :upper_material, :upper_condition, :sole_material, :sole_type, :sole_condition, :heel_material, :heel_condition, :insole_type, :insole_condition, :lining_type, :lining_condition
before_upda... | true |
6d9dc16ce44bfab8a365c5e5ba272828b7c9ea6f | Ruby | simon-ulrik/Spel---Mastermind | /Mastermind_2.0.rb | UTF-8 | 1,982 | 3.953125 | 4 | [] | no_license | def Mastermind()
system ("cls")
rand_number_1 = rand(0..9)
rand_number_2 = rand(0..9)
rand_number_3 = rand(0..9)
rand_number_4 = rand(0..9)
# while rand_number_2 != rand_number_1
# rand_number_2 = rand(0..9)
# end
#
# while rand_number_3 != rand_number_1 || rand_number_3 != rand_number_2
# rand_number_3... | true |
ec67cd48fe143d93edbe6d7b5afba41defa52d40 | Ruby | josefzacek/lynda-rspec | /Chapter03/03_01/car_project/spec/car_spec.rb | UTF-8 | 1,229 | 2.96875 | 3 | [] | no_license | require 'car'
describe 'Car' do
describe 'attributes' do
it 'allows reading and writting for :make' do
car = Car.new
car.make = 'Subaru'
expect(car.make).to eq('Subaru')
end
it 'allows reading and writting for :year' do
car = Car.new
car.year = 2000
expect(car.year).t... | true |
8d9f02b0c42b16030c3d191a9764128c384d3df4 | Ruby | AlexUkPC/The-Well-Grounded-Rubyist | /Chapter1/c2f_ex1.rb | UTF-8 | 233 | 3.234375 | 3 | [] | no_license | puts "Reading Celsius temperature from data file..."
num = File.read("temp.dat")
celsius = num.to_i
fahrenheit = (celsius*9/5)+32
puts "Saving result to output file 'temp.out'"
fh= File.new("temp.out","w")
fh.puts fahrenheit
fh.close | true |
9a00debc2abac9318ccc97921502fbb099893bf3 | Ruby | lucasduarte/faq_bot | /app/services/website/remove_service.rb | UTF-8 | 418 | 2.53125 | 3 | [] | no_license | module WebsiteModule
class RemoveService
def initialize(params)
@company = Company.last
@params = params
@id = params["id"]
end
def call
begin
website = @company.websites.find(@id)
rescue
return "Website inválido, verifique o Id"
end
Website.tran... | true |
df783da7b83f8363d34609c14cc28dd5ca59ff5e | Ruby | ejohns11-2019/Casino_Project_Gr4 | /Dice.rb | UTF-8 | 865 | 3.890625 | 4 | [] | no_license | class Dice
attr_accessor :guess, :result
def initialize
@guess= guess
@result = result
roll
end
def roll
@die1 = 1 + rand(6)
@die2 = 1 + rand(6)
end
def show_dice
print "Die1: ", @die1, " Die2:", @die2
end
def show_sum
print "Sum of dice is ", @die1 + @die2, ".\n"
@result = @die1 + @... | true |
cac93dcdc00579b9741bb85da164b6f415da8f3f | Ruby | nao0831/ruby_programming | /binary.rb | UTF-8 | 217 | 3.25 | 3 | [] | no_license | def to_binary(number)
test(number, 2)
end
def test(warareru, waru, result = "")
if warareru == 1
"1#{result}"
else
test(warareru / waru, waru, "#{(warareru % waru)}#{result}")
end
end
| true |
2e4f326305bab6e154d577a05dc9ba69707b2ee7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/904066f5661548c19810ca9f9b5f016b.rb | UTF-8 | 800 | 3.90625 | 4 | [] | no_license | class Bob
def hey sentence
message = Message.new(sentence)
case message.type
when :question
question_answer
when :shout
shout_answer
when :silence
silence_answer
else
default_answer
end
end
private
def default_answer
'Whatever.'
end
def shout_answer
... | true |
02ffa6d8c80021977e7baa71de70e9293bc1438f | Ruby | jacksonweekes/roxy-session-viewer | /scraper.rb | UTF-8 | 977 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'json'
url = "http://www.roxy.com.au/now-showing"
document = Nokogiri::HTML(open(url))
movies = []
counter = 0
document.css("li[class='cinema-movie-list-group-item list-group-item']").each do |movie|
title = movie.css("a[class='cmlgi-movie-title']").... | true |
1c2643d703a8ad86ef09b260465acdb9ad575dcd | Ruby | Mattlk13/maglev | /src/test/Trac819.rb | UTF-8 | 521 | 3.234375 | 3 | [] | no_license | # MRI prints out the file and line number with the error:
#
# $ ruby ~/tmp/l.rb
# /Users/pmclain/tmp/l.rb:2: syntax error, unexpected tINTEGER, expecting $end
# x << Array.new 4 if 1 == 2
#
# MagLev does not print the file info:
#
# $ maglev-ruby ~/tmp/l.rb
# at line 2, syntax error, found tINTEGER expe... | true |
3142722c1b69ba5cccf4c62edb2872751f35de32 | Ruby | jesriv/people-api | /spec/lib/parser_spec.rb | UTF-8 | 1,260 | 3.15625 | 3 | [] | no_license | require 'parser'
RSpec.describe "Parser" do
# Create a dummy class to emulate extending the module
let(:extended_class) { Class.new { extend Parser } }
it "input should not be empty" do
result = extended_class.split_input(nil)
expect(result).to eq(false)
end
it "should read a comma separated line"... | true |
6a14e9a078b089852038098e43ebe44fcc178083 | Ruby | WizardOfOgz/memoized_inflectors | /spec/lib/memoized_inflectors_spec.rb | UTF-8 | 5,202 | 3.171875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
RSpec.describe ::MemoizedInflectors do
describe "StringMethods" do
described_class::StringMethods::INFLECTORS.each do |inflector|
before do
# Clear the cache before each example
described_class.clear_cache
end
it "caches values for #{ inflector }" do
... | true |
827f102d1a2f4c3e1fc46f131407cd02a816558a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/2640f916e7b84a9382aeee37bbc3cf43.rb | UTF-8 | 672 | 3.640625 | 4 | [] | no_license | class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(list)
result = []
remove_identicals_in(list).each do |possible_anagram|
result << possible_anagram if match?(possible_anagram)
end
result
end
private
def match?(possible_anagram)
get_cha... | true |
986f8cb5395613b8af4f76421b73d726c9ccdc6b | Ruby | gracepacencia/Banking-TTS | /lib/checking_account.rb | UTF-8 | 238 | 2.71875 | 3 | [] | no_license | class CheckingAccount < BankAccount
def initialize (name, number, initial_balance,limit)
super name, number, initial_balance
@limit = limit
end
def print_spending_limit
p 'Daily spending limit' + @limit.to_s
end
end | true |
dc4717477daaf19a210ee8b87fd44e9a5d62a703 | Ruby | rohanpmoore/animal-shelter-ruby | /lib/customer.rb | UTF-8 | 2,300 | 3.0625 | 3 | [] | no_license | class Customer
attr_reader :customer_id, :customer_name, :customer_phone, :type_preference, :breed_preference
def initialize(attributes)
@customer_id = attributes.fetch(:customer_id)
@customer_name = attributes.fetch(:customer_name)
@customer_phone = attributes.fetch(:customer_phone)
@type_preferen... | true |
800285dd92aa5fa29058c6c9964b8b362ab1ce01 | Ruby | aquariumbio/covid19-test | /diagnostic_rt_qpcr/libraries/protocolsurvey/source.rb | UTF-8 | 1,785 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Includes methods for giving a survey to the Tech and get ting answers.
module ProtocolSurvey
def protocol_survey(operations)
question1 = 'Are you aware of any mistakes or errors that may have occurred '\
'while executing this Job? If so briefly explain.'
sur... | true |
f2e9192ccab8dcef6d81e668189be963db06177f | Ruby | takaxyz/atcoder | /ABC126/E.rb | UTF-8 | 917 | 3.4375 | 3 | [] | no_license | class Node
attr_accessor :parent, :rank
def initialize(n)
@parent = n
@rank = 0
end
end
class UnionFindTree
def initialize(n)
@nodes = (0..n).to_a.map { |i| Node.new(i) }
end
def find(x)
return x if @nodes[x].parent == x
return @nodes[x].parent = find(@nodes[x].parent)
end
... | true |
b6fdfbb5228a72dd6b39e6d354aa71affccf68f5 | Ruby | metade/musicbore | /vendor/grammar/test/grammatical_context_test.rb | UTF-8 | 3,757 | 2.796875 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'test_helper')
require 'grammar/grammatical_context'
class GrammaticalContextTest < Test::Unit::TestCase
def test_nil_subject
c = Grammar::GrammaticalContext.new(:audience => 'john')
assert_equal '', c.subject
end
def test_subject_when_subject_and_audience_diff... | true |
f91ba6927d536913e7432658f0e1ea341295cc84 | Ruby | jacobhlyon/ruby-advanced-class-methods-lab-web-062617 | /lib/song.rb | UTF-8 | 1,318 | 3.34375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist_name
@@all = []
def initialize
@name = name
@artist_name = artist_name
end
def self.all
@@all
end
def save
self.class.all << self
end
def self.create
new_song = self.new
@@all << new_song
new_song
end
def self.new_... | true |
d53b519345fe18c52cb11983b5643785fbfeb749 | Ruby | rekapap/Problem-solving | /Leetcode/657.rb | UTF-8 | 336 | 3.03125 | 3 | [] | no_license | # @param {String} moves
# @return {Boolean}
def judge_circle(moves)
moves_map = {
L: [0, -1], R: [0, 1],
U: [1, 0], D: [-1, 0]
}
final_p = moves.upcase.split(//).inject([0, 0]) do |sum, move|
add = moves_map[move.to_sym]
[sum, add].transpose.map { |x| x.reduce(:+) }
end
x,y = final_p
x.zero?... | true |
fbcb08d6eb34754b25f4cd41fab48deae443c423 | Ruby | SantiagoSalazarPavajeau/collections_practice-online-web-pt-100719 | /collections_practice.rb | UTF-8 | 755 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(int_arr)
int_arr.sort
end
def sort_array_desc(int_arr)
int_arr.sort {|x,y| y <=> x}
end
def sort_array_char_count(int_arr)
int_arr.sort {|x,y| x.length <=> y.length}
end
def swap_elements(int_arr)
int_arr[1],int_arr[2] = int_arr[2],int_arr[1]
int_arr
end
def reverse_array(int_arr)
int... | true |
dc723c3910d8365b527ac128e2d74f59d8dd254e | Ruby | thorntj91/launch-school | /ruby_foundations/lesson_1/reduce.rb | UTF-8 | 315 | 3.765625 | 4 | [] | no_license | require 'pry'
def reduce(array, acc = 0)
array.each { |ele| acc = yield(acc, ele) }
acc
end
array = [1, 2, 3, 4, 5]
puts reduce(array) { |acc, num| acc + num }
puts reduce(array, 10) { |acc, num| acc + num }
puts reduce(array) { |acc, num| acc - num }
puts reduce(array) { |acc, num| acc + num if num.odd? } | true |
e7909aaa1fd0b9ad853c4aa91de1352475233285 | Ruby | Haseeb-Qureshi/crypto-challenges | /base/base.rb | UTF-8 | 981 | 3.296875 | 3 | [] | no_license | class Base < String
def initialize(*args)
args[0] = self.class.to_self(args[0]) if args[0].is_a?(Numeric)
super(*args)
end
def self.get_alphabet
raise NotImplementedError
end
def self.alphabet
@alphabet ||= get_alphabet
end
def self.values
@values ||= alphabet.each_with_index.to_h
... | true |
c4c6a4da818e23f1d87b475e80f7ae5ae8d9e0f6 | Ruby | onevivek/wazu | /lib/job_utils.rb | UTF-8 | 910 | 2.703125 | 3 | [] | no_license | module JobUtils
def run_job_list(job_ids)
puts "==================================================================="
begin
raise "empty job ids list" if job_ids.empty?
pids = []
process_count = 0
all_done = false
while !all_done do
job_ids.each do |job_id|
puts... | true |
e14c5fad53d8174fd69549c3031d5614c94a54dd | Ruby | wagolemusa/vim | /convert.rb | UTF-8 | 85 | 2.59375 | 3 | [] | no_license | remaining_guesses = 10 - num_guesses
puts remaining_guesses.to_s + " guesses left."
| true |
dde617943235edceb1c19103063663b7816a2776 | Ruby | Benjaminpjacobs/homework | /sorting_suite/tests/merge_sort_test.rb | UTF-8 | 2,188 | 2.96875 | 3 | [] | no_license | gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../sorting_suite'
class SortingSuite::MergeSortTest < Minitest::Test
def test_it_exists
sorter = SortingSuite::MergeSort.new
end
def test_with_2
sorter = SortingSuite::MergeSort.new
to_sort = [2,1]
expected = [1,... | true |
f03e08a11e5184142c45b5e4b074b80a93840f4c | Ruby | manjithd/rulox | /tests/expr_printer.rb | UTF-8 | 414 | 3.390625 | 3 | [
"MIT"
] | permissive | require_relative "../src/expressions.rb"
require_relative "../src/astPrinter.rb"
require_relative "../src/token.rb"
expression = Binary.new(
Unary.new(
Token.new(:MINUS, "-", nil, 1),
Literal.new(123)
),
Token.new(:STAR, "*", nil, 1),
Grouping.new(Literal.new(45.67))
)
output = AstPrinter.print expression
pu... | true |
a717f10cd8dbdd57d38714b53a62ee3b1c424ee2 | Ruby | tommeier/texticle | /spec/texticle/searchable_spec.rb | UTF-8 | 1,501 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'texticle/searchable'
class WebComic < ActiveRecord::Base
# string :name
# string :author
end
class SearchableTest < Test::Unit::TestCase
context "when extending an ActiveRecord::Base subclass" do
setup do
@qcont = WebComic.create :name => "Questionable Content", :author... | true |
7732111db706bf4bb006a911121d2e9597f4e718 | Ruby | MarcosIpo/jogo_forca | /lib_teste.rb | UTF-8 | 332 | 3.0625 | 3 | [] | no_license | class SelecionarPalavra
def self.selpal
p = []
File.open(File.expand_path('../lista_palavras.txt', __FILE__), 'r') do |arquiv|
while linha = arquiv.gets
p.push (linha.upcase)
end
p.sample
end
end
end
contentsArray=[] # start with an empty array
f.each_line {|line|
contentArray... | true |
89064278e7e3215d1f58ac07a6a056d2911e909e | Ruby | starlafreyscott/learning_ruby | /human_tdd/human_rspec.rb | UTF-8 | 897 | 3.21875 | 3 | [] | no_license | require_relative 'wizard'
RSpec.describe Wizard do
it 'Wizard has a default health of 50 and intelligence of 25' do
wizard1 = Wizard.new('Name1')
# What we want to happen
expect(wizard1.health).to eq(50)
expect(wizard1.intelligence).to eq(25)
end
it 'Wizard has a heal method that increases health... | true |
dd014e19e69947a9d164589494c9d7029a557151 | Ruby | thomax/sonic-o-matic | /lib/twitter_listener.rb | UTF-8 | 2,073 | 2.875 | 3 | [] | no_license | require 'tweetstream'
require 'net/http'
require 'uri'
module SonicOMatic
DIVISOR = ' [o=o] '
class TwitterListener
attr_reader :logfile, :keyword
def initialize(logfile, keyword = nil)
@logfile = logfile
@keyword = keyword
configure_tweetstream
end
def run
message = "Li... | true |
a1d12c7b15efdd0e044d0bd7953e1b392a4416e7 | Ruby | ShadowKoBolt/coolpay | /lib/coolpay/authenticating_client.rb | UTF-8 | 1,526 | 2.71875 | 3 | [] | no_license | module Coolpay
# Client for making authenticated calls
class AuthenticatingClient
def initialize(username:, api_key:, authenticate_url:)
@username = username
@api_key = api_key
@authenticate_url = authenticate_url
end
def get(url, options = {})
retries ||= 0
response = Typ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.