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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ab0f71f9cb4c581af38543c0ed84fe8775c96e79 | Ruby | gernot-ohner/RB100 | /book/8_more_stuff/side_effects.rb | UTF-8 | 92 | 3.03125 | 3 | [] | no_license | def test(b)
b.map! { |letter| "good letter, #{letter}" }
end
a = %w(a b c)
p test(a)
p a
| true |
fec3974be93949152b501029fc1a401d872439d9 | Ruby | BlackRabbitt/bitmap_editor | /lib/bitmap_exception.rb | UTF-8 | 165 | 2.953125 | 3 | [] | no_license | class BitmapException
attr_reader :level, :error
ERROR="Error"
WARN="Warning"
def initialize(level, error)
@level = level
@error = error
end
end
| true |
1002e423bf9ff588e6c7ae669923b56cfa1f0b23 | Ruby | CoreyWinkelmann/rdci | /bin/example.rb | UTF-8 | 3,802 | 3.484375 | 3 | [] | no_license | require 'rdci'
# Example taken from the original DCI ruby example by Steen Lehmann
# Model class with no external dependenices. Includes a simple find method
# to create and store instances given an id - for illustration purposes only.
class Account
attr_reader :account_id, :balance
def initialize(account_id)
... | true |
b7ac33aa67e471bfc4d7fe5e627c79d99cac8958 | Ruby | thomasfrl/Semaine1_Jeudi | /lib/02_password.rb | UTF-8 | 434 | 2.71875 | 3 | [] | no_license | def signup
puts "bienvenu, veuillez rentrer un mot de passe"
print ">"
return mdp = gets.chomp
end
def login(mdp)
puts "bienvenu, quel est votre mot de passe"
print ">"
if gets.chomp != mdp
login(mdp)
else
welcom_screen
end
end
def welcom_screen
puts "bienvenu dans ta zone secrète"
puts "Voici le numéro... | true |
3132d3c432174991b70da196e189ee446859d6c6 | Ruby | CLTPayne/TDD-practise | /secret-diary/lib/secret_diary.rb | UTF-8 | 398 | 3.3125 | 3 | [] | no_license | class SecretDiary
attr_reader :entries
def initialize
@entries = []
end
def lock
"Is now locked"
end
def add_entry(title, body)
@entries << {title: title, body: body}
:ok
end
def print_entries
@entries.each do |entry|
entry.each do |title, body|
return "Title: #{en... | true |
96b9cb24a82bd1e1f449c3c8560cbc009cb29bfc | Ruby | Lukeveille/oct2_reinforcement | /exercise.rb | UTF-8 | 228 | 3.734375 | 4 | [] | no_license | hash = {}
(1..50).each do |count|
if count % 14 == 0
mod = count * 2
elsif count % 2 == 0
mod = count + 1
elsif count % 7 == 0
mod = count - 1
else
mod = count
end
hash[count] = mod
end
puts hash | true |
e74ec567a582d81331ad2aecb975a9983cbf8d8b | Ruby | mwhanna/housability | /spec/models/crimes_model_spec.rb | UTF-8 | 1,997 | 2.8125 | 3 | [] | no_license | require "rails_helper"
RSpec.describe Crime, :type => :model do
before(:all) do
crimes = CSV.read("./datafiles/crime.csv")
crimes.shift
numrows = 0
crimes.each do |row|
desc = row[0]
address = row[3].split(' ', 2)
if desc == 'Commercial Break and Enter'
if address[0].end_with? "XX... | true |
056efbd85daa7bb6d06e983e51bbb8edce2f3d47 | Ruby | semenchukostap/lab2 | /labolatorna2.rb | UTF-8 | 462 | 3.6875 | 4 | [] | no_license | thread_1 = Thread.new do
puts "hello word"
sleep(1)
puts "goodby world"
end
puts "Потік_1"
thread_1.join
a = 2
b = 2
c = 3
thread_2 = Thread.new(a, b, c) do |x, y, z|
puts x + y + z
end
puts "Потік_2"
thread_2.join
i = 0
thread_3 = Thread.new()do
while i < 5 do
i += 1
puts i
end
end
pu... | true |
f7f0ffc062787c10013d9410caee327b361f524a | Ruby | Loomus/Rails_Engine | /lib/tasks/csv_loader.rake | UTF-8 | 2,496 | 2.515625 | 3 | [] | no_license | require 'csv'
namespace :import do
desc "Import data from CSV file"
task data: :environment do
Merchant.destroy_all
Customer.destroy_all
Item.destroy_all
Invoice.destroy_all
Transaction.destroy_all
InvoiceItem.destroy_all
merchant_file = 'db/merchants.csv'
custome... | true |
3db72ad12cfda348176b3ad0efcc610078502479 | Ruby | LloydWes/projet_jour5_ruby | /lib/03_basics.rb | UTF-8 | 481 | 3.453125 | 3 | [] | no_license | def who_is_bigger (a, b, c) #Purement le tiens :-°
if a==nil || b==nil || c==nil
return "nil detected"
elsif a >= b && a >= c
return "a is bigger"
elsif b>= a && b >= c
return "b is bigger"
else
return "c is bigger"
end
end
def reverse_upcase_noLTA(str)
return str.reverse!.upcase... | true |
046918246d367952d9280dfa8a908a95a160edf4 | Ruby | alexhendra/belajarruby | /exercise/FindLeader.rb | UTF-8 | 261 | 3.203125 | 3 | [] | no_license | def solution(a)
n=a.size
l=[-1] + a
l.sort
count=0
pos=n/2
candidate=l[pos]
for i in 1..(n+1)
count+=1 if l[i] == candidate
end
return candidate if count > pos
return -1
end
puts solution([4,4,4,4,2,1,4,4,3,4]) | true |
7a0ceda2d8e8eb14c8307c3a17add0e50ab378cf | Ruby | EmKen/HomesNotHotels | /app/models/booking.rb | UTF-8 | 495 | 2.828125 | 3 | [] | no_license | class Booking < ApplicationRecord
belongs_to :user
belongs_to :listing
validate :availability
def availability
listing.bookings.each do |existing|
if overlap?(self, existing)
errors.add(:property_unavailable, "on the dates you have have requested")
end
end
end
def overlap?(x,y)
(x.che... | true |
7bb0b4a4037a7d30e7061b4460f2d153d653cdbe | Ruby | qqdipps/LeetCode-DS-Algos-Other | /array/delete_columns_to_make_sorted_944.rb | UTF-8 | 1,886 | 4.125 | 4 | [] | no_license | # We are given an array A of N lowercase letter strings, all of the same length.
#
# Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
#
# For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after... | true |
776d64d476afb0bdeca494b9de4d1c77676394f4 | Ruby | kennycaiguo/LearnRuby | /rubyproj/main.rb | UTF-8 | 201 | 3.875 | 4 | [] | no_license |
# for x in 1..5 do
# puts("hello ruby")
# end
puts("please enter a number:")
num=gets().to_i
if num>0
puts("positive number")
elsif num==0
puts("zero")
else
puts("negetive")
end
| true |
7c862d03acacb1d7a12e506702ef8bda0481d8d3 | Ruby | swmcc/importer_exporter | /spec/lib/decorators/multiple_stock_decorator_spec.rb | UTF-8 | 1,209 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe 'Decorator tests for mulitple stock items' do
context 'multiple objects are treated correctly' do
let(:items) { [coffee_obj, delivery_obj] }
let(:coffee_obj) { Stock.new coffee }
let(:delivery_obj) { Stock.new delivery }
let(:body) { JSON.parse(StocksDecorator.n... | true |
87b86ad730706be322f656e60611e6f79d15e58a | Ruby | mmatschiner/opsin_evolution | /rh1_gene_tree_inference/src/make_constraints.rb | UTF-8 | 5,390 | 2.609375 | 3 | [] | no_license | # m_matschiner Sat Jul 1 23:52:17 CEST 2017
# Get the command-line arguments.
infile_name = ARGV[0]
outfile_name = ARGV[1]
# Read the infile.
inlines = File.open(infile_name).readlines
set_of_inlines = [inlines[0]]
outstring = ""
1.upto(inlines.size-1) do |x|
if inlines[x][0..2] == "id:" or x == inlines.size-1
set... | true |
36bf052335269854cb2bb863f5fab7288b160715 | Ruby | Eliacaterina/ruby-problems | /prime_factors.rb | UTF-8 | 133 | 3.25 | 3 | [
"MIT"
] | permissive | def primeFactors(number, factor)
if number% factor != 0 && number/number == 1
puts factor
end
end
primeFactors(12, 2) | true |
66f3c295b95620ef7a63238d6bc9b6a3bf1e6c01 | Ruby | SamuelAmsallem/learn_ruby_sam | /01_temperature/temperature.rb | UTF-8 | 93 | 2.90625 | 3 | [] | no_license | #write your code here
def ftoc(num)
(num - 32)*5/9
end
def ctof(num)
(num * 1.8) + 32
end
| true |
c33011444ff7133e2db21d48cadea47ae76e9de7 | Ruby | rubyrider/clomp | /lib/clomp/operation.rb | UTF-8 | 4,919 | 2.609375 | 3 | [
"MIT"
] | permissive | module Clomp
class Operation
attr_reader :result, :configs, :output, :executed, :options
# Constructor for operation object
#
# @param track_builders [Array] the list of tracks we define
# @param options [Hash] of options to be provided by .[] call/method
# @return [self]
def initiali... | true |
e0bfb6163df90890a60abe9bfa38c1dff03e6ceb | Ruby | krbrennan/WRK-w2d1 | /chess/null_piece.rb | UTF-8 | 153 | 2.75 | 3 | [] | no_license | require 'singleton'
class NullPiece
include Singleton
attr_reader :symbol, :color
def initialize
@symbol = " "
@color = nil
end
end
| true |
265cc8653d99aa80cd2ca645d08684bdf1c56988 | Ruby | jliang87/zepoc | /rails/ruby/1.9.1/gems/capybara-2.0.2/lib/capybara/helpers.rb | UTF-8 | 1,061 | 3.09375 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
module Capybara
module Helpers
class << self
##
#
# Normalizes whitespace space by stripping leading and trailing
# whitespace and replacing sequences of whitespace characters
# with a single space.
#
# @param [String] text Text to normalize
#... | true |
e27b8a1ca7737c1f6a7ab37989434010a458ff03 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/d514380356cc49feb8f4451f27f5e305.rb | UTF-8 | 387 | 3.15625 | 3 | [] | no_license | class Complement
def self.of_dna(dna_strand)
dna_strand.gsub!(/G/, 'c')
dna_strand.gsub!(/C/, 'g')
dna_strand.gsub!(/T/, 'a')
dna_strand.gsub!(/A/, 'u')
dna_strand.upcase
end
def self.of_rna(rna_strand)
rna_strand.gsub!(/C/, 'g')
rna_strand.gsub!(/G/, 'c')
rna_strand.gsub!(/A/, '... | true |
47b38842c9dccd6fa1e0351195df1189813299c2 | Ruby | dnd/state-fu | /lib/support/arrays.rb | UTF-8 | 4,288 | 3.125 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | module StateFu
# Stuff shared between StateArray and EventArray
module ArrayWithSymbolAccessor
# Pass a symbol to the array and get the object with that .name
# [<Foo @name=:bob>][:bob]
# => <Foo @name=:bob>
def []( idx )
begin
super( idx )
rescue TypeError => e
if idx... | true |
4de170bb0eea164ef922af15db6e79c2c7f20805 | Ruby | ryanp54/collections_practice-cb-000 | /collections_practice.rb | UTF-8 | 679 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort{ |a,b| a <=> b }
end
def sort_array_desc(array)
array.sort{ |a,b| b <=> a }
end
def sort_array_char_count(array)
array.sort{ |a, b| a.size <=> b.size }
end
def kesha_maker(array)
array.collect do |item|
item[2] = "$"
item
end
end
def find_a(array)
array.select... | true |
2e078d9bf5679e4dd236788fbde80096d8f6e047 | Ruby | Waynexiee/My_leetcode | /sorted_list_to_bst.rb | UTF-8 | 1,073 | 4.03125 | 4 | [] | no_license | class ListNode
attr_accessor :val, :next
def initialize(val)
@val = val
@next = nil
end
end
class TreeNode
attr_accessor :val, :left, :right
def initialize(val)
@val = val
@left, @right = nil, nil
end
end
def sorted_list_to_bst(head)
arr = []
while head
... | true |
6f0df06abc456d78d61bbd35b92cc1be11d7e692 | Ruby | SarahBunker/rb101_programming_foundations | /ruby_written_assessment_practice/local_var_scope_my_problems.rb | UTF-8 | 4,615 | 4.21875 | 4 | [] | no_license | ###Local Variable Scope
###########################
#Practice showing which things create a new scope
array_nums = [1,2,3,4,5]
array_nums.each {|num| puts num}
#p num #Traceback (most recent call last):
# local_var_scope_my_problems.rb:7:in `<main>': undefined local variable or method `num' for
# main:Obj... | true |
e4b9a6a943ba33783bfb48472e5df51848618d0b | Ruby | kenmeriftw/khsm | /spec/models/game_question_spec.rb | UTF-8 | 2,249 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe GameQuestion, type: :model do
let(:game_question) { FactoryBot.create(:game_question, a: 2, b: 1, c: 4, d: 3) }
context 'game status' do
it 'correct .variants' do
expect(game_question.variants).to eq(
'a' => game_question.question.answer2,
'b' => gam... | true |
4cd7568a659e047e470fb4497a0db6f1e9eda884 | Ruby | bspates/SE331_Fuzzers | /Inspectors/RecInspector.rb | UTF-8 | 1,400 | 2.625 | 3 | [] | no_license | require './Inspectors/Inspector.rb'
require './Inspectors/LinkInspector.rb'
require './Inspectors/CookieInspector.rb'
require './Inspectors/InputInspector.rb'
require './Utility/WebSpecific.rb'
class RecInspector < Inspector
def initialize(d, t)
super(d, t)
@linkInspect = LinkInspector.new(d, t)
@cook... | true |
61dff3eead43fcc0d5007499d0388e0d769e9436 | Ruby | kitlangton/assignment_sort | /benchmark.rb | UTF-8 | 540 | 3.4375 | 3 | [] | no_license | require_relative 'merge_sort'
require_relative 'bubble_sort'
require_relative 'insertion_sort'
require_relative 'quick_sort'
def sort_benchmark
start = Time.now
yield
finish = Time.now
puts (finish - start)
end
array = Array.new(2000){rand(3000)}
puts "insertion sort"
sort_benchmark do
insertion_sort(arr... | true |
ca562d9fc8994ca7c0a0a7d913958435d9435906 | Ruby | drewbstew/ruby_projects | /todo1.rb | UTF-8 | 171 | 3.328125 | 3 | [] | no_license | puts "Welcome to TODO app! Enter 3 tasks:"
tasks = []
3.times do
puts "Enter a task:"
tasks << gets.chomp
end
puts "Please remember to do the following:"
puts tasks
| true |
9ce6c8af9ac70738276438b895008b0fa93b1453 | Ruby | daliacodes/cli-applications-guessing-game-wdc01-seng-ft-022221 | /guessing_game_cli.rb | UTF-8 | 251 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def run_guessing_game
num = rand(6)+1
user_input = gets.chomp.to_i
if user_input == num
print "You guessed the correct number!"
else
print "Sorry! The computer guessed #{num}."
end
if user_input == exit
puts "Goodbye!"
end
end | true |
dfaa1c9d2bec9124c51c546b52721ebb82f3213b | Ruby | MartinCrane/ruby-collaborating-objects-lab-web-0217 | /lib/song.rb | UTF-8 | 289 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist
# @@songs
def initialize(name)
@name = name
end
def self.new_by_filename(name)
song_arr = name.split(" - ")
artist = Artist.find_or_create_by_name(song_arr[0])
song = Song.new(song_arr[1])
song.artist = artist
song
end
end | true |
f23b3ab017fec606376b9035d2e9bd01681cb34a | Ruby | AbbyMB/Views-Challenge | /app.rb | UTF-8 | 1,255 | 3.265625 | 3 | [] | no_license | require "json"
require "pry"
data = File.read('./views.json')
json_data = JSON.parse(data)
puts "Enter View Information"
user_input = gets.chomp
input_type = ""
if user_input[0] == "."
input_type = "classNames"
user_input = user_input.tr('.','')
elsif user_input[0] == "#"
input_type = "identifier"
user_input... | true |
72155feddf66e579e85a14ff3d916a28c6636b85 | Ruby | velvetsnowman/Checkout | /spec/stock_spec.rb | UTF-8 | 532 | 2.96875 | 3 | [] | no_license | require 'stock'
describe Stock do
subject (:stock) { described_class.new(items) }
let(:items) do
{
coke: 2.00,
bread: 3.00
}
end
it 'has a list of stock items' do
expect(stock.items).to eq items
end
it 'should show the price of an item' do
expect(stock.price(:coke)).to eq(item... | true |
0624e14305a77b903117e9c73c320d7f46ee7e81 | Ruby | calamitas/vanunits | /lib/van/units/constants/mks.rb | UTF-8 | 11,078 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'van/units'
require 'van/units/constants/math'
module Van::Units
module Constants
# = Constants in the MKS system (meters, kg, sec)
#
# Large assortment of real world contants in standard m kg s types.
#
# == Synopsis
#
# include Van::Units::Constants
#
# MKS::SPEED_OF_LIGHT #=> 2.9979... | true |
dff5690846f0339f5323e0f3ef14d65a052f6cf8 | Ruby | khalilgharbaoui/rubybank | /app/models/record.rb | UTF-8 | 586 | 2.515625 | 3 | [] | no_license | class Record < ApplicationRecord
belongs_to :bank_account
belongs_to :counterpart, class_name: 'BankAccount'
validates :amount, numericality: { greater_than_or_equal_to: 0 }
before_save :default_note, on: :create
before_save :decorate_amount, on: :create
private
def decorate_amount
status == 'receiv... | true |
b4dee15583ef554385f33b095e346b38cf94c5ca | Ruby | thejayneo/lotrd | /lib/lotrd/controller/bankController.rb | UTF-8 | 1,345 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'yaml'
require_relative '../view/bank'
module BankController
def withdraw(wdw)
player = YAML.load(File.read(ENV['HOME'] + "/." + "playerdata.yml"))
gold = player.gold
balance = player.balance
if wdw > balance
::Bank.deficit
elsif wdw < 1
::... | true |
b245dc8133af7ed028bab5b5c7b6660094ae64a8 | Ruby | njpa/launchschool-rb101 | /small_problems/11_medium_1/01_rotation_1.rb | UTF-8 | 3,185 | 4.75 | 5 | [] | no_license | =begin
Rotation (Part 1)
=================
Write a method that rotates an array by moving the first element to the end
of the array. The original array should not be modified.
Do not use the method `Array#rotate` or `Array#rotate!` for your implementation.
Example:
rotate_array([7, 3, 5, 2, 9, 1]) == [3, 5, 2, 9, 1... | true |
d59cfcc730d924a5de54bc44a5894bebae50c571 | Ruby | Elffers/Project_Euler | /ruby/Problem33.rb | UTF-8 | 1,966 | 3.703125 | 4 | [] | no_license | # The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
# We shall consider fractions like, 30/50 = 3/5, to be trivial examples.
# There are exactly four non-trivial example... | true |
470ffd9536b6b36e7b710a3708444ea6233e0d97 | Ruby | oscarmolivera/code_farm | /Ruby/CoderByte/007_SimpleSymbols.rb | UTF-8 | 4,081 | 3.90625 | 4 | [] | no_license | =begin
Have the function SimpleSymbols(str) take the str parameter being passed
and determine if it is an acceptable sequence by either returning the string
true or false. The str parameter will be composed of + and = symbols with
several letters between them (ie. ++d+===+c++==a) and for the string
to be true each ... | true |
a125290d5841208c34506ef742163d1f7dacf3df | Ruby | beck03076/CrawlFish | /app/controllers/logger_controller.rb | UTF-8 | 2,251 | 2.546875 | 3 | [] | no_license | class LoggerController < ApplicationController
def impressions
if(!File.exist?("public/transactions_logs/"+Date.today.to_s+"/"))
FileUtils.mkdir_p("public/transactions_logs/"+Date.today.to_s+"/")
end
self.index("public/transactions_logs/"+Date.today.to_s+"/")
render :nothing => true
end
... | true |
7a3a5a8906894d9da4358ff6cfd86593d88f02fc | Ruby | pshussain/Backup | /random.rb | UTF-8 | 169 | 2.8125 | 3 | [] | no_license | class String
define_method('generate') do
value = "";
Integer(self).times{value << (45 + rand(50)).chr}
return value
end
end
puts "5".generate
| true |
954a6a2336310e9e0e39ed27e0be039ba58bd11a | Ruby | isabella232/measured | /lib/measured/cache/json.rb | UTF-8 | 1,366 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Measured::Cache
class Json
attr_reader :filename, :path
def initialize(filename)
@filename = filename
@path = Pathname.new(File.join(File.dirname(__FILE__), "../../../cache", @filename)).cleanpath
end
def exist?
File.exist?(@path)
end
d... | true |
67bb7f4badd5be781bb5d470793749961f6fd140 | Ruby | ruby-rdf/sparql | /lib/sparql/algebra/operator/divide.rb | UTF-8 | 2,273 | 3 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | module SPARQL; module Algebra
class Operator
##
# The SPARQL numeric `divide` operator.
#
# [117] MultiplicativeExpression::= UnaryExpression ( '*' UnaryExpression | '/' UnaryExpression )*
#
# @example SPARQL Grammar
# PREFIX : <http://example.org/>
# SELECT ?s WHERE {
# ?s... | true |
fce39ece653d5726e389e408a4c23ab3cdb12c05 | Ruby | bibikovilya/summer-2019 | /3715/2/lib/helpers/location.rb | UTF-8 | 569 | 2.90625 | 3 | [] | no_license | module Location
MINSK_CAMP_LATITUDE = 53.913071..53.917243
MINSK_CAMP_LONGITUDE = 27.564656..27.573243
GEOTAG_FILE_NAME = 'geo.txt'.freeze
def valid_location?
payload['location'] && valid_latitude? && valid_longitude?
end
private
def valid_latitude?
MINSK_CAMP_LATITUDE.cover? payload['location'... | true |
e0c16f3557fec7aa6145da40ee24c07cf0faa261 | Ruby | farmerchuk/130_more_ruby | /challenges/circular_buffer.rb | UTF-8 | 4,030 | 3.171875 | 3 | [] | no_license | require 'minitest/autorun'
class CircularBuffer
class BufferEmptyException < StandardError; end
class BufferFullException < StandardError; end
def initialize(buffer_size_limit)
@buffer_size_limit = buffer_size_limit
@buffer = []
end
def read
raise BufferEmptyException if buffer.empty?
buffe... | true |
1327b4c01216e34b72bdd21be9026b6c6e3b34fd | Ruby | gjmcgough/phase-0-tracks | /ruby/arrays_drill.rb | UTF-8 | 595 | 3.828125 | 4 | [] | no_license | def array_method(a , f)
comb_array = a << f
end
p array_method([] , "a")
p array_method(["a", "b", "c", 1, 2], 3)
def dead_end(h , b , o)
new_array = []
new_array + [h , b , o]
end
array = []
p array
array += ["p" , "dsl" , "edjsa" , "djsk" , "djsak"]
p array
array.delete_at(2)
p array
... | true |
a2153f4fbfd080c0832de214774c13621ce2e697 | Ruby | brianmenard/playlister-sinatra-v-000 | /app/models/song.rb | UTF-8 | 342 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class Song < ActiveRecord::Base
belongs_to :artist
has_many :genres, through: :song_genres
has_many :song_genres
def slug
unslugged = self.name
unslugged = unslugged.split(" ")
slugged = unslugged.join("-").downcase
slugged
end
def self.find_by_slug(slug)
Song.all.find{|song| song.sl... | true |
b4eaf81fd2089eaf60983639484dd5298ec03247 | Ruby | ShannonLCapper/zorkda | /lib/zorkda-web/Actors/Thing/Enemy/Skulltula.rb | UTF-8 | 2,919 | 2.796875 | 3 | [] | no_license | module Zorkda
module Actors
#DONE
class Skulltula < Enemy
attr_accessor :moves_when_last_spun
def initialize(name, description, distance)
super(name, "Skulltula", "Skulltulas", 2, "RNG", distance)
@description = description
@navi_description = "This nasty spider likes to hang down from the cei... | true |
8a5d732f1cb5875f65c778d520498d5543749312 | Ruby | jatpatel/brewery_db_api_fetch | /app/resources/api/beer_resource.rb | UTF-8 | 624 | 2.578125 | 3 | [] | no_license | module Api
class BeerResource < JSONAPI::Resource
def initialize(brewery_db_client)
@client = brewery_db_client
end
def get_all(options = {})
# default: page number
options[:page] = 1 unless options[:page] && options[:page] > 0
response_data = @client.get_response('/beers', opti... | true |
b037e4ee228591928436fc89993663210072fee1 | Ruby | dannyli0109/code_along | /week08/phone/phone.rb | UTF-8 | 449 | 3.15625 | 3 | [] | no_license | class Phone
def initialize raw_phone_number
@raw = raw_phone_number
end
def number
result = @raw.gsub(/[^0-9]/,'')
if result.length != 10
if result[0] == "1" && result.length == 11
result = result[1..10]
else
result = "0000000000"
end
end
result
end
def... | true |
48a187ea3d8dfbc2611392a8e368602bc2e7fd4e | Ruby | Madelene/Voter-simulator | /maddie_voter_sim.rb | UTF-8 | 3,338 | 3.75 | 4 | [] | no_license |
#you can only call a method within a class on the instance of the class
class Voter
attr_accessor :name, :party
def initialize (full_name, party)
@name = full_name
@party = party
end
end
class Politician
attr_accessor :name, :affiliations
def initialize(name, party)
@name = name
@party... | true |
a2a94f0cd4a2acf86d854a21c9da7d4890da82fe | Ruby | justinj26/Mod2-code-challenge-practice-SOLO-lab-Students-app | /app/models/instructor.rb | UTF-8 | 458 | 3.109375 | 3 | [] | no_license | class Instructor < ApplicationRecord
has_many :students
def average_age
student_ages = self.students.map do |student|
student[:age]
end
the_average = student_ages.sum / student_ages.count
the_average
end
def students_alphabetical
alphabetical = self... | true |
d68c2c5bd470ac71b4295ae4af47ad49b884b4be | Ruby | sajg1/e31_classnotes_complete | /week_01/day_2/testing/specs/my_functions_spec.rb | UTF-8 | 590 | 3.25 | 3 | [] | no_license | require( 'minitest/autorun' )
require( 'minitest/emoji' )
require_relative('../my_functions.rb')
class FunctionsTest < MiniTest::Test
def test_greet_craig
# Arrange
name = 'craig'
time_of_day = 'evening'
# Act
result = greet(name, time_of_day)
# Assert
expected_result = 'Good evening, ... | true |
1b45c2ce10d5492dd82a8fffc5461453fef849b8 | Ruby | yassun/ruboty-kendama | /lib/ruboty/kendama/actions/kendama.rb | UTF-8 | 1,110 | 2.515625 | 3 | [
"MIT"
] | permissive | module Ruboty
module Kendama
module Actions
class Kendama < Ruboty::Actions::Base
YOUTUBE_API_URL = 'http://gdata.youtube.com/feeds/api/videos'
def initialize
@trick = trick
end
def get(message)
if url = parse(response)
message.reply(@trick +... | true |
6264d648a14d6588d9f81ede71f9f40ef11811f4 | Ruby | pulinagrawal/project-q-repo | /app/helpers/application_helper.rb | UTF-8 | 638 | 3.015625 | 3 | [] | no_license | module ApplicationHelper
end
class OneStat
attr_accessor :quizzes
attr_accessor :questions
attr_accessor :correct
def initialize
@quizzes = 0
@questions = 0
@correct = 0
end
def hit(quiz, quest, correct)
@quizzes += quiz
@questions += quest
@cor... | true |
ea2ff799f2bd79a0c27f2a1e785b99d283b09943 | Ruby | snblack/poulpe | /app/models/keyword.rb | UTF-8 | 558 | 2.671875 | 3 | [] | no_license | class Keyword < ApplicationRecord
has_many :positions, dependent: :delete_all
belongs_to :product
validates :title, presence: true
def current_position
self.positions.last&.value.to_i
end
def changes_thirty_days_ago
thirty_days_ago = Date.today - 30
thirty_days_ago_position = self.positions.... | true |
7b0772da09254e63696888e096b15258504203aa | Ruby | 1993hzh/hangman | /test/dataTraining.rb | UTF-8 | 1,796 | 3.234375 | 3 | [] | no_license | require 'set'
require "singleton"
require_relative 'mockWordProvider.rb'
require_relative '../guesser.rb'
require_relative '../game.rb'
require_relative '../log/logManager.rb'
class DataTraining
@@logger = LogManager.instance.getLogger
def testTrainingData
gameResult = Hash.new
DataTraini... | true |
ceb7dadd8b634005bafdb3c2e4196e34b7e7e23c | Ruby | peterkinnaird/cocktail_central | /lib/tasks/export.rake | UTF-8 | 4,311 | 2.953125 | 3 | [] | no_license |
namespace :export do
desc "Parses JSON files into a seeds.rb way."
task :seeds_format => :environment do
#Open each JSON file
require 'rubygems'
require 'json'
localCount = 0
Dir.glob('vendor/recipes/*.json') do |item|
#localCount += 1
#if localCount % 4 == 0
# addTest = t... | true |
1073249b92dc939b5e804ba01fbb02aa5ac26e59 | Ruby | islador/Bowling | /spec/models/score_card_spec.rb | UTF-8 | 3,053 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: score_cards
#
# id :integer not null, primary key
# throw1 :integer
# throw2 :integer
# throw3 :integer
# throw4 :integer
# throw5 :integer
# throw6 :integer
# throw7 :integer
# throw8 :integer
# throw9 :integer
# th... | true |
5136001d9fdf225f44678a14818fb631fccc4216 | Ruby | givegab/periodic_time_range | /spec/periodic_time_range_spec.rb | UTF-8 | 2,303 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe PeriodicTimeRange do
it 'has a version number' do
expect(PeriodicTimeRange::VERSION).not_to be nil
end
describe '#to_range' do
def hms(h, m, s)
Time.zone.local(2014, 7, 23, h, m, s)
end
context '15 minutes between recurrences' do
it 'returns a range o... | true |
391e45a8d8f778a9ab254ed21caad614df9de1a1 | Ruby | jtbui20/Tempest | /game_engine/character.rb | UTF-8 | 1,758 | 3.25 | 3 | [] | no_license | # * Character defines the underlying foundation of a character within the screen, particularly event handlers or logic handlers.
# * It was evident through design that there would be multiple characters.
# * The use of OOP Principles: Abstractation & Inheritance, was used to cater for the flexibility.
require 'gosu'
r... | true |
912e6f1394153aea07f42f8618b4857c18b78e9b | Ruby | guyzwick/phase-0 | /week-4/4.5/calculate-grade/my_solution.rb | UTF-8 | 261 | 3.375 | 3 | [
"MIT"
] | permissive | # Calculate a Grade
# I worked on this challenge [by myself, with: ].
# Your Solution Below
def get_grade(num)
if num >= 90
grade = "A"
elsif num >= 80
grade = "B"
elsif num >= 70
grade = "C"
elsif num >= 60
grade = "D"
else
grade = "F"
end
end
| true |
143eb27739a8768ecf9f1c1e97d04d60762bb4c3 | Ruby | LKHennessy/advent-of-code | /2017/day-5/jump_maze.rb | UTF-8 | 358 | 3.28125 | 3 | [] | no_license | class JumpMaze
def self.jump(maze)
maze = maze.each_line.map { |offset| offset.split.map(&:to_i) }.flatten
current_index = 0
steps = 0
while maze[current_index]
current_argument = maze[current_index]
steps += 1
maze[current_index] += 1
current_index = current_index + current_... | true |
7801f7eb3cd735ba00fce06a56e21b43e34ed5f3 | Ruby | matthewmain/cli_snow | /snow_spotify.rb | UTF-8 | 34,454 | 3.5 | 4 | [] | no_license |
class Window
def initialize
puts "\n\nSnow's about to fall in Spotify and pile up on your album cover image...\n\n"; sleep 1.5; 300.times {puts "\n"}
#window settings
@@width = get_positive_integer_from_answer_to("Terminal window width:\n\n"); clear_screen
@@height = get_positive_integer_from_answer_to("Term... | true |
743aeaaef404d0acad64962967bb771f09ac9480 | Ruby | yk1126/resume_builder | /user_input.rb | UTF-8 | 428 | 3.203125 | 3 | [] | no_license | class UserInput
attr_accessor :resume_data
def initialize(resume_data)
@resume_data = resume_data
end
def read
@resume_data.name = get_data("Name : ")
@resume_data.age = get_data("Age : ")
@resume_data.nation = get_data("Nation : ")
@resume_data.dob = get_data("DOB : ")
@resume_data.mob ... | true |
764f6c3ee3f2aa19a71b2e28ccf12a30459fa417 | Ruby | stattleship/stattleship-ruby | /lib/stattleship/total_player_stat.rb | UTF-8 | 1,562 | 2.578125 | 3 | [] | no_license | module Stattleship
class TotalPlayerStat < Stattleship::Endpoint
def to_sentence
if season_name.nil?
"#{player.name} has #{format_stat(total)} #{lowercase_stat}"
else
"#{player.name} had #{format_stat(total)} #{lowercase_stat} in the #{season_name} season"
end
end
def lo... | true |
3db384a54363c2e2e7edd112ebc026826ecd27b9 | Ruby | midhunkrishna/muskrat | /lib/muskrat/configuration/guard.rb | UTF-8 | 2,149 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative '../../refinements/refined_hash'
using RefinedHash
module Muskrat
module Configuration
class Guard
KEYS_UNDER_ENV = [:concurrency, :subscriptions, :mqtt]
ERROR_MESSAGES = {
has_environment: 'Configuration not under environment.',
has_concurrency: 'Concurrency should... | true |
9ef8a28e341e5afbe65dba54a0b324f54265463d | Ruby | wrex/rperf | /spec/tc_utility_spec.rb | UTF-8 | 1,946 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rperf'
describe Rperf do
describe "::normalize_units" do
it "should leave valid numbers alone (numeric or string)" do
Rperf::normalize_units(4321).should == 4321
Rperf::normalize_units('4321').should == 4321
end
it "should turn '8 KiB' into 8192" do
Rperf::normalize_units("8 ... | true |
3c9cdfe436463b931127f9ec7e6dac6991c284ed | Ruby | syamoji56/RubyCamp2018Spring_Group5_Keyboardver | /src/director/title_director.rb | UTF-8 | 2,089 | 2.578125 | 3 | [] | no_license | module Title
class Director
def initialize
@haikei=Haikei.new(Window.width) #背景
@logo=Image.load("images/title.png")#タイトルロゴ
@flag = 0#テキストメッセージ変更管理フラグ
@font=Font.new(32,font_name="MS 明朝")#フォント
@kyaputya1=Image.load("images/kyaputya/kyaputya1.png")
@kyaputya2=Image.load("image... | true |
72a42324b82c044b8ddfe6765879451bdabd0b68 | Ruby | jasonlong/classroom | /app/models/concerns/git_hub.rb | UTF-8 | 1,481 | 2.875 | 3 | [
"MIT"
] | permissive | module GitHub
class Error < StandardError; end
class Forbidden < StandardError; end
class NotFound < StandardError; end
# Public
#
def with_error_handling
yield
rescue Octokit::Error => err
case err
when Octokit::Forbidden then raise_github_forbidden_error
when Octokit::NotFound... | true |
e2650f90701acc0ce9a0d94640b16c4df34f7b2e | Ruby | nayakhilesh/nlp-2-pcfg | /pcfg.rb | UTF-8 | 7,736 | 3.1875 | 3 | [] | no_license | # Coursera NLP class
# Akhilesh Nayak
# Assignment 2
# 4/10/2013
require 'json'
require 'optparse'
require 'logger'
$logger = Logger.new(STDOUT)
$logger.level = Logger::INFO
def write_replaced_file(filename)
freq_hash = get_freq_hash(filename)
infrequent_words = freq_hash.reject { |word, freq| freq >= 5 }
... | true |
781f63c7aff9eaa7c464ea4ca984560a1eb318cb | Ruby | piketa/ruby_excercise | /024.rb | UTF-8 | 1,137 | 3.640625 | 4 | [] | no_license | print "☆レーダー☆\n"
print "ターゲットとして 0~100 のうち1つの数が設定されます。探索する位置と範囲を入力してターゲットを見つけてください。\n"
print "ターゲットと探索位置の差が探索範囲以下であればヒットです。探索範囲より大きければ、はずれです。\n"
print "探索位置とターゲットが一致すれば正解です。\n"
print "----------------------------------------------\n"
print "ゲームを開始します。\n"
begin
target = rand(101)
print "ターゲットが設定されました。\n"
1.step ... | true |
fac7b6e87665f68aa3c6ef780dbcc8896572e57e | Ruby | Tasha25/gray_lady | /spec/models/scraper_spec.rb | UTF-8 | 1,499 | 2.734375 | 3 | [] | no_license | require 'spec_helper'
describe Scraper do
describe ".new" do
it "initializes with a url" do
expect( Scraper.new("http://www.hiddengemsarchery.com") ).to be
expect{ Scraper.new("http://www.hiddengemsarchery.com") }.to_not raise_error
end
it "raises an error without a url" do
expect{ Sc... | true |
1327d0f92772f91975728dd4a585835c0c7cef2b | Ruby | anaisofia/intro_a_ruby | /unidad2/sesion1/solo_impares.rb | UTF-8 | 74 | 2.9375 | 3 | [] | no_license | n = ARGV[0].to_i
n.times do |i|
next unless i.odd?
puts i
end | true |
fcb781f7eb05e33b255bc88397546d9933dd6bd9 | Ruby | togiberlin/algorithmic_challenges | /coderbyte/a_easy/ruby/20_division_stringified/division_stringified.rb | UTF-8 | 138 | 3.046875 | 3 | [
"MIT"
] | permissive | def division_stringified(num1, num2)
quotient = (num1 / num2.to_f).round
quotient.to_s.reverse.scan(/\d{1,3}/).join(',').reverse
end
| true |
216949c68bfd67e46ad47583d27c87a2ca1f0b9d | Ruby | tasyjean/ruby-mhl | /lib/mhl/genetic_algorithm_solver.rb | UTF-8 | 6,975 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'concurrent'
require 'erv'
require 'facter'
require 'logger'
require 'mhl/bitstring_genotype_space'
require 'mhl/integer_genotype_space'
module MHL
class GeneticAlgorithmSolver
# mutation_probability is the parameter that controls the intensity of mutation
attr_reader :mutation_probability
de... | true |
3d1777101a3d9468dc2e294666a9b1f0c63be8bc | Ruby | hetzluh/Pacifica | /src/boat.rb | UTF-8 | 3,574 | 3.59375 | 4 | [] | no_license | #!/usr/local/bin/ruby
=begin
This class defines the Boat object.
A boat can be a trade boat: T
Or a war boat: W
Attributes:
kingdomId -> int, kingdom belonging to boat
currentCrew -> int, current crew number
War boats begin with 10.
Trade boats begin with 5.
*** On war boat, 3 crew must survive or the boat will pe... | true |
5718b913fed76ee6e15209b8ac244d4b482cb3ef | Ruby | roadie-app/google-directions-api | /lib/google_directions_api/directions.rb | UTF-8 | 3,527 | 2.84375 | 3 | [
"MIT"
] | permissive | require_relative './base'
require_relative './polyline/encoder'
module GoogleDirectionsAPI
class Directions < Base
attr_accessor :from, :to, :waypoints, :departure_time, :use_shortest_distance
def self.new_for_locations(from:, to:, waypoints: nil, departure_time: nil, use_shortest_distance: false)
new... | true |
700c7c12fff06621e105b4c6e05f55e2f48a107f | Ruby | aws-samples/aws-lambda-containerized-custom-runtime-blog | /lib/utils.rb | UTF-8 | 1,737 | 3.078125 | 3 | [
"MIT-0"
] | permissive | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
class Utils
# Static values for customer and order details to be used on the invoice.
# In a real-world scenario, we would receive this as POST body or
# GET query string parameters.
def initialize
provide... | true |
95b5b726b4f172795207969e760c1bdbd104a60a | Ruby | Aschen/coinmarketcap-ruby-api | /lib/coinmarketcap/coins.rb | UTF-8 | 1,071 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'faraday'
require 'json'
module Coinmarketcap
class Coins
attr_reader :count, :markets, :timestamp, :currency_exchange_rates
def initialize(attributes)
@count = attributes["markets"].count # @coins = Coinmarketcap::Coins.list(10) | @coins.count
@markets = attributes["markets"]
@timestamp = attr... | true |
deba1c5d9c8afcb49ddc80d080200ee3e5499681 | Ruby | amatriain/feedbunch | /FeedBunch-app/app/inputs/timezone_clock_icon_input.rb | UTF-8 | 763 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
##
# Output HTML for a timezone select form field.
#
# The HTML generated is compatible with Bootstrap, and it prepends a time icon
# (from FontAwesome[http://fortawesome.github.io/Font-Awesome/]) before the input.
#
# This class is intended to be used from simple_form[https://github.com/... | true |
8bcd88876dd7684e6c6fdeb84b105f6ef555a75e | Ruby | kangkg/phase-0-tracks | /ruby/problem_solving_methods.rb | UTF-8 | 5,800 | 4.59375 | 5 | [] | no_license | ## PSEUDO CODE
# Method (array of integers, integer to search for)
# 1. return integer index, or NIL if not present
# 2. dont use built-in.
# end
########################## RELEASE 0 #########################
########################## METHODS #########################
def search_array(array, integer... | true |
c3106c957471cc471d1046606afc53aa60da5563 | Ruby | kristiankristensen/em-smsified | /examples/sending_and_subscribing.rb | UTF-8 | 2,429 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ##
# Run this file from the smsified root dir, ie. :
# ruby examples/sending_and_subscribing.rb
#
# Remember to copy config.yml.sample to config.yml and insert your SMSified credentials
# Also you need to change the "sender_address" parameter below to your registered SMSified number, and the "receiver_address" to the m... | true |
9252bca64708ccc04cf934f85bf817fefe227211 | Ruby | imdanaaa/rspec-fizzbuzz-ruby-intro-000 | /fizzbuzz.rb | UTF-8 | 225 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(number)
if number % 15 == 0 && number/ 15 == 1
return "FizzBuzz"
elsif
number % 3 == 0 && number / 3 == 1
"Fizz"
elsif
number % 5 == 0 && number / 5 == 1
"Buzz"
else
nil
end
end
| true |
b659cde7978517d410695c168d39521f42c00f8a | Ruby | Samanthabarceta/like_system | /lib/like_system/likee.rb | UTF-8 | 1,181 | 2.6875 | 3 | [
"MIT"
] | permissive | ###
# LikeSystem module
#
# This module defines common behavior in like system
###
module LikeSystem
###
# Likee module
#
# This module defines likee behavior in like system
###
module Likee
###
# Extends ActiveSupport::Concern
###
extend ActiveSupport::Concern
###
# Included config... | true |
cada3f8aeb904796ec7944c533aad0713a09ab66 | Ruby | ppelszynski/dice_roller_v2 | /spec/services/neighboring_number_filter_spec.rb | UTF-8 | 407 | 2.78125 | 3 | [] | no_license | require 'spec_helper'
require_relative '../../services/neighboring_numbers_filter'
describe NeighboringNumbersFilter do
it 'removes two lowest values' do
numbers1 = [1, 1, 1, 2, 3, 4, 5]
numbers2 = [10, 15, 1, 2, 30, 35, 40]
expect(NeighboringNumbersFilter.call(numbers1)).to eq([1, 2, 3, 4, 5])
exp... | true |
6ff5d096d98e2c81dbe05278e783ee6bf33f5203 | Ruby | lagnajeetdas/optionspreads | /lib/optionexpirydates.rb | UTF-8 | 1,436 | 2.53125 | 3 | [] | no_license | class Optionexpirydates
require 'httparty'
require 'json'
require 'filtermainexpirydates'
def initialize(symbol)
@symbol = symbol
@baseurl_tradier = ENV['baseurl_tradier']
@tradier_api_key = ENV['tradier_api_key']
apicall_e_dates
end
def apicall_e_dates
begin
url_options_expiry_string =... | true |
123202068a6ce27a3fd9e7d1ab43ae38f66e4fe8 | Ruby | 4l1n/DistroPayments | /app/lib/aes_crypt.rb | UTF-8 | 2,855 | 3.09375 | 3 | [] | no_license | require 'base64'
require 'digest'
require 'openssl'
require 'aes'
module AesCrypt
def self.encrypt(password, plain_text, previous = nil , card_token = nil , card_iv = nil)
begin
if previous
cipher = OpenSSL::Cipher.new('AES-256-CBC')
password = Digest::SHA256.digest(password)
cipher.... | true |
9fa3feb355f487eb8069bc9839e48e7176d67add | Ruby | rikkhill/dutch-numbers | /test/dint.rb | UTF-8 | 4,318 | 3.640625 | 4 | [] | no_license | require 'test/unit'
require_relative '../lib/dutch'
# Tests for Dutch Integers
# We can check this object satisfies the axioms for
# a ring over the integers
class TestIntegerRing < Test::Unit::TestCase
def setup
@zero = Dint.new(0)
@one = Dint.new(1)
@two = Dint.new(2)
@five = Dint.new(5)
@te... | true |
1e71003e7edeb11218772d27090c316efbeba493 | Ruby | adamkoperek/image-explorer | /back-end/app/controllers/ajax/images_tags_controller.rb | UTF-8 | 1,701 | 2.546875 | 3 | [] | no_license | class Ajax::ImagesTagsController < ApplicationController
def create
image_id = params[:imageId]
tag_value = params[:tag].downcase
# if image exists
if Image.exists?(image_id)
# then get image and tag by its' ids
image = Image.find(image_id)
tag = Tag.find_by_value(tag_value)
... | true |
b1a789b2a9eff08908c73ad6b0daef6c41d3965f | Ruby | RicardoRojo/workbook-exercises | /easy/quiz1/exercise3.rb | UTF-8 | 204 | 3.140625 | 3 | [] | no_license | #Solution
str = "Few things in life are as important as house training your pet dinosaur."
puts "Original string.- #{str}"
str.gsub!("important","urgent")
puts "String with the text modified.- #{str}" | true |
54c3bfef73f89ace7df2e489ccdd70e242e7a40d | Ruby | aleebrady/learn_co | /intro-to-rake-v-000/Rakefile | UTF-8 | 1,049 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #####namespace :greeting
#####greeting:hello
#should print out 'hello from Rake!'
#####greeting:hola
#should print out 'hola de Rake!'
#####namespace :db
#db:migrate
#invokes the :enviro... | true |
894841b0212f42bf91932cc7c732c9fb36a86dd7 | Ruby | jeromeOthot/Puzzle-Quest-Adventure | /Scripts/RPG/RPG_BaseItem.rb | UTF-8 | 3,081 | 2.734375 | 3 | [] | no_license | class RPG::BaseItem
include Comparable
def <=> (other); self.id <=> other.id end
def load_notetags
end
# attr_accessor :rarity
# attr_accessor :effects
#--------------------------------------------------------------------------
# * Constante
#--------------------------------------------------... | true |
672f8e45f661ead4556c84938f7eb6fe0be21cdf | Ruby | bcoffin9/project_springer_travails | /knight.rb | UTF-8 | 2,600 | 4.0625 | 4 | [] | no_license | require_relative "node.rb"
class Knight
attr_reader :position
def initialize pos=[1,1]
@position = pos
end
#level order, iteration
#going to do recursion and store the min answer in each call
#depth first could creat infinite loop (stack overflow) if it drills down on the left
def ... | true |
fdb275635cf884acd71d0ff14569bf691cf4ae43 | Ruby | jbauzone/role-player | /lib/action.rb | UTF-8 | 489 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
# Represents actions available to a player.
module Action
MOVE_LEFT = 'left'
MOVE_RIGHT = 'right'
MOVE_TOP = 'top'
MOVE_BOTTOM = 'bottom'
HIT = 'hit'
MOVE_ACTIONS = [MOVE_LEFT, MOVE_RIGHT, MOVE_TOP, MOVE_BOTTOM].freeze
def self.description
MOVE_ACTIONS.each do |action... | true |
5a2fcb9079c7dcd08c04e719176fc521165c2c1d | Ruby | SawyerMerchant/project_dom_tree | /lib/warmups.rb | UTF-8 | 773 | 3.28125 | 3 | [] | no_license | class Tag
attr_reader :type, :classes, :id, :name
attr_accessor :child
Type = /^(<)(\w+)\b/
Classes = /class=\'(.*?)\'/
Id = /id=\'(.*?)\'/
Name = /name=\'(.*?)\'/
def initialize string
@string = string
@child = nil
end
def parse
# regex sniffs for open tags
# close tags
# '= s... | true |
b723bf8db4cfd2ff08a642a69f3d4eeee655803f | Ruby | pedropreciado/classwork | /W2D1/board.rb | UTF-8 | 966 | 3.515625 | 4 | [] | no_license | require_relative 'piece'
require_relative 'null_piece'
class Board
def initialize
@board = blank_grid
end
def blank_grid
Array.new(8) { Array.new(8) {NullPiece.new}}
end
def set_pieces
royals = [Piece.new] * 8
pawns = [Piece.new] * 8
@board[-1] = royals
@board[0] = royals.reverse
... | true |
fac975e4cb7478b647965cd9db2419509eaeb2c7 | Ruby | PedroGabrielBO/thelgrains-heroku | /app/models/web_comentario.rb | UTF-8 | 830 | 2.625 | 3 | [] | no_license | class WebComentario < ActiveRecord::Base
validates_presence_of :nome, :email, :comentario
validates :comentario, length: { minimum: 5, maximum: 500 }
validate :limite_de_comentario
private
def limite_de_comentario
# TODO, query de verificacao de limite de WebComentarios (parametros de configuracao)
... | true |
ae2892eb52296b20515f7ce16c5bb87045b937d4 | Ruby | pmodels/mpich | /test/hydra/exit_status.rb | UTF-8 | 2,923 | 2.84375 | 3 | [
"mpich2"
] | permissive | #! /usr/bin/env ruby
# This script tests that hydra gives the correct output and error codes when
# child programs exit in various ways. If hydra's output format ever changes
# then this test will need to be updated.
require 'test/unit'
class TestExitStatus < Test::Unit::TestCase
def test_exit0
output = `mpie... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.