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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e2a5451fc1958a89fce00446472898a24dd2dc1a | Ruby | Hollyw00d/ninja-ruby | /ninja_spec.rb | UTF-8 | 456 | 2.703125 | 3 | [] | no_license | require_relative "ninja"
RSpec.describe Ninja do
before do
@ninja = Ninja.new
end
it "has an ancestor chain that includes Human" do
@ninja = Ninja.ancestors.include?(Human)
expect(@ninja).to eq(true)
end
it "has a stealth method that increases its stealth by 10" do
@ninja.increase_stealth
... | true |
9b6a67ef18d7343d8482e805ba656339d07e0b88 | Ruby | creasyw/project_euler | /Q005/Q005.rb | UTF-8 | 132 | 3.234375 | 3 | [] | no_license |
n = 20
x = (1..n).to_a
(1..n-1).each{|i| x[i+1..n-1] = x[i+1..n-1].map{|k| if k%x[i]==0 then k/x[i] else k end}}
puts x.reduce(:*)
| true |
661e69f14e8e04998a038b5171c563da7b5fb859 | Ruby | klowewilliams/ruby_projects | /class.rb | UTF-8 | 192 | 3.109375 | 3 | [] | no_license | class Park
attr_accessor :name, :site, :condition
def initialize (location)
puts "You've initialized #{location}"
end
def east
puts "Head towards the rising sun."
end
end | true |
dfb2bc26e36a76af6e38188b3c856ad811a411d3 | Ruby | haidahaha/swispon | /app/helpers/application_helper.rb | UTF-8 | 319 | 2.59375 | 3 | [] | no_license | module ApplicationHelper
def daysDiff(fromDate)
diff = Time.zone.now - fromDate
color =
if diff < 1.day
""
elsif 1.day <= diff && diff < 2.days
"success"
elsif 2.days <= diff && diff < 3.days
"warning"
else
"danger"
end
return color
end
end
| true |
c7551029a0a488c41fe8a259d20023120f15f3dd | Ruby | alioral/Owe | /app/models/user.rb | UTF-8 | 1,472 | 2.515625 | 3 | [] | no_license | class User < ActiveRecord::Base
#attr_accessible :name, :oauth_expires_at, :oauth_token, :oauth_token_secret, :provider, :uid
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.in... | true |
b2c8edd974bd5f2c0d1fef647b221cee2769aca6 | Ruby | bphommaha/j7ruby | /exo_05.rb | UTF-8 | 142 | 3.421875 | 3 | [] | no_license |
#x c'est la variable qui correspond à un chiffre
puts "choisis un nombre:"
x = gets.chomp.to_i
x.times do
puts "salut ça farte"
end
| true |
ec36385febcd855050e13535684727e174dc4901 | Ruby | christiandebarrio/movie_lovers | /lib/searchfake.rb | UTF-8 | 3,307 | 2.640625 | 3 | [] | no_license | class MovieFake
attr_reader :id, :title, :url, :poster
@@number_movies = 0
def initialize id, title, url, poster
@@number_movies += 1
@id = @@number_movies
@title = title + " (" + @id.to_s + ")"
@url = url
@poster = poster
end
end
class SearchFake
attr_accessor :text, :movies
... | true |
ac5259b3ca12e5fe00299485e7b6a91330153c67 | Ruby | Gosstapher/Project_1 | /app/models/gig.rb | UTF-8 | 1,526 | 2.828125 | 3 | [] | no_license | class Gig < ActiveRecord::Base
has_many :bookings, dependent: :destroy
has_many :users, through: :bookings
belongs_to :venue
belongs_to :artist
belongs_to :genre
validates :name, uniqueness: true
validates :image, presence: true
validates :description, presence: true
validates :capacity , presence: tr... | true |
2d7bf307cb60497cea32d5862699450c49577d58 | Ruby | killme2008/coding-practice | /ruby_under_a_microscope/ch8/incr_decr.rb | UTF-8 | 244 | 2.890625 | 3 | [] | no_license | # coding: utf-8
i = 0
##共用一份复制的栈帧
incr = lambda do
puts "Increment from #{i} to #{i+1}."
i += 1
end
decr = lambda do
puts "Decrement from #{i} to #{i-1}."
i -= 1
end
incr.call
decr.call
incr.call
incr.call
decr.call
| true |
cd9e4554337e2c08a9c15929f49f965059e0cacc | Ruby | richgeog/A_Well_Grounded_Rubyist | /Part_1_Examples/Chapter_5_self_scope_and_visibility/5.3/private_methods.rb | UTF-8 | 1,311 | 3.78125 | 4 | [] | no_license | ############ DEPLOYING METHOD ACCESS RULES ###############
############ PRIVATE METHODS EXAMPLE###############
# class Cake
# def initialize(batter)
# @batter = batter
# @baked = true
# end
# end
# class Egg
# end
# class Flour
# end
# class Baker
# def bake_cake
# @batter = []
# pour_flour
#... | true |
9fb67ef2a0770426a28d616d9fde049ab70ccb35 | Ruby | subratrout/depot-old | /test/models/product_test.rb | UTF-8 | 2,097 | 2.828125 | 3 | [] | no_license | require 'test_helper'
class ProductTest < ActiveSupport::TestCase
test "product attributes should not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.error... | true |
f238c11b4aca5fb398cd7e0c4bb641e3db203d82 | Ruby | justinko/database | /database_prompt.rb | UTF-8 | 1,631 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
require 'singleton'
class DatabasePrompt
include Singleton
PROMPT = '>> '
def self.start
print PROMPT
while (input = gets.chomp)
command, *args = input.split
case command
when 'SET'
instance.set(*args)
when 'GET'
puts instance.get... | true |
7eeb9abed98a15f818358f28020710c5882dcc91 | Ruby | carden-code/metaprog | /automatic/101_index_elements_more_left_elem.rb | UTF-8 | 504 | 3.46875 | 3 | [] | no_license | # frozen_string_literal: true
# Дан целочисленный массив. Вывести индексы элементов,
# которые больше своего левого соседа, и количество таких чисел.
array = [1, 2, -15, 23, 4, 0, -2, 4, 88, -2, 12, 11]
product = []
array.each_with_index { |elem, index| product << array.index(elem) if array[index - 1] < array[index] }... | true |
71ca42e792ace6c71ce0590ba8d0f4e03b871557 | Ruby | sapjunior/cafe-grader | /web/branches/contest/app/models/user.rb | UTF-8 | 1,607 | 2.671875 | 3 | [] | no_license | require 'digest/sha1'
class User < ActiveRecord::Base
has_and_belongs_to_many :roles
has_many :test_requests, :order => "submitted_at DESC"
validates_presence_of :login
validates_presence_of :full_name
validates_length_of :full_name, :minimum => 1
validates_presence_of :password, :if => :password_req... | true |
22985a42a3949ea86833a2d80a9f1b889a04c2eb | Ruby | PatriceH7/ExoVal_Wk2_Tues | /exo_12.rb | UTF-8 | 219 | 3.78125 | 4 | [] | no_license | # exo_12.rb
# demande un nombre à l'utilisateur, puis qui compte jusqu'à ce nombre.
puts "Merci d'entrer un nombre entier:"
print "> "
number_by_user = gets.chomp
(number_by_user.to_i).times do |i|
puts i + 1
end
| true |
d91b1c92689de6ae9913001e63c6d00a485f521d | Ruby | Swirrl/dclg_stats_selector | /app/models/dclg_stats_selector/csv_builder.rb | UTF-8 | 3,025 | 3 | 3 | [
"MIT"
] | permissive | require 'csv'
module DclgStatsSelector
class CSVBuilder
DEFAULT_HEADER_ROW_STRATEGIES = {
dataset: { display: :uri, padding: :blank },
measure_property: { display: :label, padding: :blank },
dimension_value: { display: :label, padding: :duplicate },
blank: { display... | true |
f1ef7b8f97329c692eec2978876418860a564305 | Ruby | kyrylo/pry-note | /lib/pry-note/commands.rb | UTF-8 | 6,670 | 2.90625 | 3 | [] | no_license | Pry::Commands.create_command "note" do
description "Note stuff."
banner <<-USAGE
Usage: note [OPTIONS]
Add notes to classes and methods.
e.g note add Pry#repl -m "this is my note" #=> add a note without opening editor
e.g note add Pry#repl #=> add a note (with editor) to Pry#repl method
e.g ... | true |
3e89b43af95c66747a977c04c3b772b7c2fa6e75 | Ruby | leetran2001/larry_shopping_cart | /app/models/order.rb | UTF-8 | 552 | 2.578125 | 3 | [] | no_license | class Order < ApplicationRecord
belongs_to :user
belongs_to :product
belongs_to :billing, optional: true
def self.total_items
pluck(:quantity).sum
end
def self.get_total
where(nil).map { |order| order.price * order.quantity }.sum
end
def self.to_paypal_items
where(nil).map do |order|
... | true |
f4bbb3dc441512e4e005fb7ef7f949cee2c508b7 | Ruby | k2052/beard | /lib/beard/settings.rb | UTF-8 | 3,905 | 2.5625 | 3 | [] | no_license | class Beard
def self.template_path
@template_path ||= inheritable_config_for :template_path, '.'
end
def self.template_path=(path)
@template_path = File.expand_path(path)
@template = nil
end
def template_path
@template_path ||= self.class.template_path
end
de... | true |
224aee82ecead57179be16b6b1f2ff6ad5990dfd | Ruby | iron-io/abt | /notifiers/console_notifier.rb | UTF-8 | 142 | 2.546875 | 3 | [] | no_license | class ConsoleNotifier
def initialize(notifier_details)
end
def send_message(message)
puts 'CONSOLE RESULTS: ' + message
end
end | true |
bb9adbf77c4031c338fcf5b8c1b670003abdff8b | Ruby | genxhero/W3D5_Solo | /ActiveRecordLite/lib/01_sql_object.rb | UTF-8 | 2,629 | 3.171875 | 3 | [] | no_license | require_relative 'db_connection'
require 'active_support/inflector'
require 'byebug'
# NB: the attr_accessor we wrote in phase 0 is NOT used in the rest
# of this project. It was only a warm up.
class SQLObject
def self.columns
# debugger
return @cols if @cols.nil? == false
cols = DBConnection.execute2... | true |
030545d70ec3166a42318a54ca713bdd3d447b11 | Ruby | CodesAFK/square_array-v-000 | /square_array.rb | UTF-8 | 116 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # ~~~HAVICK WAS HERE~~~
def square_array(array)
newArray = []
array.each {|num| newArray << num **2}
newArray
end
| true |
fc423effc1f628ee2a491b4e211c7ec0ea8d7d3a | Ruby | ian-ramos/guessing-cli-prework | /guessing_cli.rb | UTF-8 | 499 | 4.09375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Code your solution here!
def run_guessing_game
user_input = ""
while user_input != "exit"
puts "Guess a number between 1 and 6."
user_input = gets.chomp
random = rand(1..6)
if user_input.to_i == random
puts "You guessed the correct number!"
else
puts "The computer guessed #{random}... | true |
3f2402c37aba914c4b430b4b88dcdf03c3d30b34 | Ruby | leneehe/ruby-fundamentals1 | /exercise2.rb | UTF-8 | 494 | 4.5625 | 5 | [] | no_license | ## Exercise 2
#How would you calculate a good tip for a 55 dollar meal?
puts "1. A good tip for $55 meal is times by 15% which is $#{55 * 0.15}."
#add string and interger with + operator, convert integer to string
puts "2. Hello world! " + 123.to_s
#the result of 45628 multiplied by 7839 in a sentence by using strin... | true |
b0ad36847c97fa85379417a9da99efb030d5f6b1 | Ruby | elisklarin/BEWDiful_Students | /05_Classes_Objects/exercises/ex_secret_number_objects/HW/lib/player.rb | UTF-8 | 104 | 3.65625 | 4 | [] | no_license | class Player
attr_accessor :name
def initialize(name)
@name = name
puts "Hello #{@name}"
end
end
| true |
2016444cf36fa75c4578171a9f62d7cebd7741c9 | Ruby | qianthinking/process_command | /lib/process_command/base_receiver.rb | UTF-8 | 806 | 2.5625 | 3 | [] | no_license | module ProcessCommand
class BaseReceiver
class << self
def init
init_listener
Thread.new do
init_handler
end
end
def add_command_block(command, block)
@command_blocks ||= {}
@command_blocks[command.to_s] = block
end
def run_comm... | true |
8f4ee230ea94f7e506d2452e39d60a894139cc7e | Ruby | karuna/Payroll | /app/controllers/admin/total_work_hours_chart_controller.rb | UTF-8 | 1,922 | 2.5625 | 3 | [] | no_license | # This controller serves incoming requests to display Employee Total Hours Worked Chart.
class Admin::TotalWorkHoursChartController < Admin::AdminController
# Display the main page.
# GET /workhours/chart
def index
@month_hash = month_options
respond_to do |fmt|
fmt.html { render :layout => ... | true |
64eace4ed25671d597bfa46b168db55e1f785d4d | Ruby | tsgreenberg1217/WOD_HYPE_SERVER | /db/seeds.rb | UTF-8 | 1,361 | 2.796875 | 3 | [] | no_license | # Wod.create(cat: 1,name:'Fran', time:360000,date:1530303308000,notes:'super intense')
# Wod.create(cat: 2, name:'Snatch', weight: 100,rounds:3,reps:1,time:360000,date:1530303308000,notes:'that was heavy')
# Wod.create(cat: 2, name:'Clean and Jerk', weight: 80,rounds:1,reps:20,time:360000,date:1530303308000,notes:'star... | true |
2c1cc12620189548ede241eb867d153704b7e43f | Ruby | cireficc/yada | /app/controllers/api/v1/users_controller.rb | UTF-8 | 8,450 | 2.5625 | 3 | [] | no_license | module Api
module V1
# @restful_api 1.0
class UsersController < ApplicationController
before_action :set_user, only: [:show, :update, :destroy]
# @url /api/users
# @action GET
#
# View list of all users
#
# @response [Array<User>] List of users
def index
... | true |
4b1f11273423d2825334209440c78f6ede8ba92d | Ruby | jzohrab/SpanishTools | /core_5000/polly_unknowns.rb | UTF-8 | 1,403 | 3.09375 | 3 | [] | no_license | # Sample call:
# $ ruby polly_unknowns.rb 501 600
# Gets entries from 501 to 600
# Get all of the unknowns,
# generate polly files and play them, generating a file snippet
# to substitute in the unknowns.txt.
require_relative 'get_words'
require_relative '../lib/Polly'
require_relative '../lib/Config'
from = 0
f... | true |
54e7cf961d272b8831c207bc963f54f3b5e56040 | Ruby | IdenTiclla/Ruby-programs | /inheritance.rb | UTF-8 | 746 | 3.984375 | 4 | [] | no_license | class Chef # the super class
def make_chicken
puts "The chef makes chicken"
end
def make_salad
puts "The chef makes salad"
end
def make_special_dish
puts "The chef makes bbq ribs"
end
def make_silpancho
puts "The chef makes silpancho"
end
end
class ... | true |
e070aaef6409e465c0410d98fec5a9cb86daef91 | Ruby | rhomobile/rhodes | /res/build-tools/ruby-standalone/212/usr/local/lib/ruby/gems/2.1.0/gems/templater-1.0.0/lib/templater/capture_helpers.rb | UTF-8 | 2,112 | 2.765625 | 3 | [
"MPL-1.1",
"BSD-3-Clause",
"GPL-2.0-only",
"MIT"
] | permissive | module Templater
# Stolen from merb-core. Merb-core is licensed under the MIT license as follows:
# Copyright (c) 2008 Ezra Zygmuntowicz
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in ... | true |
4961531c8ac7e6bf79bda0d2e5da4e6387ff0bcd | Ruby | fjaeckel/gdash | /lib/graphite_graph.rb | UTF-8 | 3,923 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | # title "this is a title"
# vtitle "v label"
# width 100
# height 100
# from "-2days"
# area :none
# description
#
# field :foo, :data => "some.data.item",
# :derivative => false,
# :color => "yellow"
#
# s... | true |
c1c015ca91be462d06323d8c12f4c3311730422c | Ruby | insomenia/practice-rails | /spec/integration/item_spec.rb | UTF-8 | 4,079 | 2.625 | 3 | [] | no_license | require "swagger_helper"
ITEM_PROPERTIES = {
id: { type: :integer },
user_id: { type: :integer },
category_id: { type: :integer },
name: { type: :string },
list_price: { type: :integer },
sale_price: { type: :integer },
image_path: { type: :string },
category: {
type: :object,
properties: {
... | true |
a36bca3a3f99768253fc913ba65dcb06173dbb1a | Ruby | adamki/ticketly | /test/models/user_test.rb | UTF-8 | 1,121 | 2.515625 | 3 | [] | no_license | require_relative '../test_helper'
class UserTest < ActiveSupport::TestCase
test "user is invalid" do
user = users(:one)
assert_equal "bigfred", user.username
end
test "user is invalid without name" do
user = users(:one)
user.name = nil
refute user.valid?
end
test "user is invalid withou... | true |
97d1660bc46ed17be177249a8c58cceee31401fb | Ruby | nordcap/rubyrush | /lesson18/solve.rb | UTF-8 | 230 | 3.359375 | 3 | [] | no_license | puts "Сколько сейчас стоит 1 доллар в рублях?"
kurs = gets.to_f
puts "Сколько у вас рублей?"
count = gets.to_i
print "Ваши запасы равны: $#{(count / kurs).round(2)}"
| true |
55acbe8e497fb80340c7a57dfa0cec89d7272c97 | Ruby | thewmking/ruby-chess | /lib/chess/piece.rb | UTF-8 | 327 | 2.90625 | 3 | [] | no_license | module Chess
class Piece
attr_accessor :color, :symbol, :position, :id
def initialize(color, position, id)
@color = color
@position = position
@id = id
end
def name
self.class.name.to_s.downcase.gsub('chess::', '')
end
def dest_path(origin, dest)
nil
end
e... | true |
c37198493ab482f9b3c0d91a6c7424b9c0ec08a9 | Ruby | gadgetguy82/bus_scenario_classes_lab | /specs/BusStop_specs.rb | UTF-8 | 524 | 2.84375 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../BusStop')
require_relative('../Person')
class BusStopTest < MiniTest::Test
def setup
@person1 = Person.new("Harry", 24)
@person2 = Person.new("Jerry", 34)
@person3 = Person.new("Peter", 44)
@bus_stop1 = BusStop.new("Morningside"... | true |
e578549a0f15eeae174620c77e6dd0ffe78b9a6b | Ruby | ratchetcat/i-ching | /samples/simple_cast.rb | UTF-8 | 519 | 3.234375 | 3 | [
"MIT"
] | permissive | #!/usr/env/ruby -w
require File.expand_path(File.dirname(__FILE__) + "../../lib/iching")
puts
puts "Example Cast:"
cast = IChing::Cast.new
cast.hexagrams.each do | hexagram |
puts hexagram.to_s
puts hexagram.description[:name]
hexagram.moving_lines.each { | line | puts "Lines #{ line }" }
puts
end
puts "Exam... | true |
fba866fb1270a142233350d00cf8a10615e499db | Ruby | aleksanderbrymora/sei-36 | /lawrence_carreon/w4/ruby_mta/mta.rb | UTF-8 | 2,059 | 3.40625 | 3 | [] | no_license | require "colorize"
@stations = {
"N" => ["Times Square", "34th", "28th", "23rd", "Union Square", "8th"],
"L" => ["8th", "6th", "Union Square", "3rd", "1st"],
"6" => ["Grand Central", "33rd", "28th", "23rd", "Union Square", "Astor Place"],
}
def plan_trip start_line, start_station, end_line, end_station
... | true |
f248f8bf14cb5f1be029d03ea8057b141393008c | Ruby | nathanvda/moreapp-api | /lib/moreapp_api/form.rb | UTF-8 | 2,569 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative 'submission'
class MoreappAPI
class Form
attr_accessor :id, :name, :raw_data
def initialize(moreapp_api, customer_or_id, form_id, form_name = "", raw_data = nil)
@moreapp_api = moreapp_api
if customer_or_id.is_a?(MoreappAPI::Customer)
@customer = customer_or_id
... | true |
c6789306f68b21dfce167d4bd348ccee2c39d081 | Ruby | olwend/Oystercard | /spec/oystercard_spec.rb | UTF-8 | 2,921 | 2.671875 | 3 | [] | no_license | require './lib/Oystercard'
describe Oystercard do
let(:station) {double :kings_cross}
let(:station_2) {double :victoria}
it 'should have starting balance of zero' do
expect(subject.balance).to eq(0)
end
it 'should have no journey_history' do
expect(subject.journey_history).to be_empty
end... | true |
b25da2244e10516e0714e6af1c7cf74b51bcbf19 | Ruby | billy1339/wdi_1_ruby_hw_mbta_simplified | /subway.rb | UTF-8 | 3,058 | 3.84375 | 4 | [] | no_license | # Program has the subway system defined with appropriate data structures - DONE
# Program can find the distance between two stops on the same line - DONE
# Program can find the distance between two stops on different lines
# Program gives the correct distance in edge cases (e.g. route starts and ends at the same stop, ... | true |
82c3a15426632a33eaaeea58807be5fd40907936 | Ruby | nemostatus/ruby-collaborating-objects-lab-online-web-pt-120919 | /lib/mp3_importer.rb | UTF-8 | 263 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
def files
@files ||= Dir.entries(@path).select{|song|!File.directory?(song) && song.end_with?(".mp3")}
end
def import
files.each{|song|Song.new_by_filename(song)}
end
end | true |
dcdee45e22a118381f467e6a1e3e57093f399647 | Ruby | bnv2103/NGS | /RNA_seq/fastq_extractSeq.rb | UTF-8 | 1,082 | 2.984375 | 3 | [] | no_license | require 'csv'
$VERBOSE = nil
def main
seq = ARGV[0] #pdf file
fq = ARGV[1] # sampl.fastq
fq3 = ARGV[2] # sampl.fastq3 if there is
seq = "CTGTAGGCACCATCAATAGATCGGAAGAGCTCGTATGCCGTCTTCTGCTTG"
extract = File.new("#{fq}_extracted.fastq", "w")
remaining = File.new("#{fq}_remaining.fastq", "w")
numReads =... | true |
098428f267159121c79d0c60b3ed5e9860d0eb62 | Ruby | RobbieDumbrell/chris-pine-ruby-tutorials | /english_number.rb | UTF-8 | 3,045 | 4.34375 | 4 | [] | no_license | def english_number number
# We accept integers from 0 to 100:
if number < 0
return "Please enter a number zero or greater."
end
if number > 100
return "Please enter a number 100 or less."
end
num_string = "" # This is the string we will return.
# "left" is how much of the number we still have l... | true |
f31cbae8457a4011b3527051c2ddc80e7ea0f41e | Ruby | hugopassos/Bubble-Sort | /main.rb | UTF-8 | 908 | 3.59375 | 4 | [] | no_license | # frozen_string_literal: true
array = [4, 3, 78, 2, 0, 2]
def bubble_sort(array)
is_finished = false
while is_finished == false
is_finished = true
counter = 1
array.each_with_index do |_e, i|
next unless array[i + 1] && array[i] > array[i + 1]
aux = array[i]
array[i] = array[i + 1... | true |
94c6c5aabcd11f212214bfb8b9e07b9b43254a6b | Ruby | emalfano/ls_exercises | /ruby_basics/arrays/a5.rb | UTF-8 | 197 | 4.28125 | 4 | [] | no_license | #Use Array#each to iterate over colors and print each element.
#Expected output:
#I'm the color red!
colors = ['red', 'yellow', 'purple', 'green']
colors.each { |x|
puts "I'm the color #{x}!"
} | true |
9c312eca2a107a27a8552b0c9b892a106ff9608c | Ruby | TataSher/Process_Reviews | /Process_review_5/lib/report.rb | UTF-8 | 434 | 3.453125 | 3 | [] | no_license | class Report
attr_reader :log
def initialize
@green = 0
@amber = 0
@red = 0
end
def add_result(test_result)
test_result.split(', ').each do |mark|
if mark === 'Green'
@green += 1
elsif mark === 'Amber'
@amber += 1
elsif mark === 'Red'
@red += 1
... | true |
6d87cf1d49c9da7a06136fca1e718798d0625595 | Ruby | JordanaN/ruby-orientacao-objetos | /animal.rb | UTF-8 | 112 | 2.765625 | 3 | [] | no_license | class Animal
attr_accessor :name, :weight, :paws
def initialize(name, weight)
end
end | true |
5f86867bea84f275774fb0f3a3ae425c96a7ee8c | Ruby | ElvinEfendi/distributed-calendar-app-ruby | /token_server.rb | UTF-8 | 756 | 2.515625 | 3 | [
"Unlicense"
] | permissive | require './xml_rpc_client'
class TokenServer
# this method periodically calls pass_token method to circulate the token
def self.run(config)
re_try = 0
while true
begin
sleep 2
xml_rpc_client(config["local_host"], config["path"],
config["local_port"], config["credentials"])... | true |
7ed2ef61bcf0f52ef7146b91582d48556a7522a4 | Ruby | fearoffish/chatter | /spec/models/daily_spec.rb | UTF-8 | 3,763 | 2.8125 | 3 | [] | no_license | describe 'Daily' do
before do
class << self
include CDQ
end
cdq.setup
end
after do
cdq.reset!
end
def valid_day_summary
valid_attributes = {
timestamp: Time.parse("2010-12-13T17:00:00Z"),
enter_the_room: 0,
leave_the_room: 0,
high_five_another_user: 0,
... | true |
f131b43b625da8daac38aa9aae8fe0cd0f15cb81 | Ruby | Rakoth/quasilinearization | /lib/graphic.rb | UTF-8 | 728 | 2.65625 | 3 | [] | no_license | require 'gruff'
require 'fileutils'
class Graphic
def initialize params = {}
g = Gruff::Line.new
g.hide_legend = params[:hide_legend]
g.margins = params[:margins] || 25
g.left_margin = params[:left_margin] || 70
g.dot_radius = params[:dot_radius] || 0
g.line_width = params[:line_width] || 1
... | true |
8a35af7fbe3ddeebcb37f256e130334422ae548b | Ruby | unstablereality/ieee_store | /app/models/transaction_part.rb | UTF-8 | 2,916 | 2.671875 | 3 | [] | no_license | class TransactionPart < ActiveRecord::Base
belongs_to :part
belongs_to :parts_kit
belongs_to :transaction
validates :part_quantity, :numericality => true
before_destroy :return_inventory
attr_accessor :item_id
before_create :populate_item_id
before_create :check_uniqueness
before_create :check_avail
... | true |
66be51bb275bcd27f8f8288bfb6cf45ffc940658 | Ruby | RamonHossein/validate_cnpj | /lib/validate_cnpj/cnpj.rb | UTF-8 | 1,945 | 2.84375 | 3 | [
"MIT"
] | permissive | module ValidateCnpj
class Cnpj
def initialize(document)
@validate = validation(document)
end
def validation(document)
return true if document.blank?
return false if regex(document) == false
return false if verify_blacklist(document) == true
return validate?
end
def ... | true |
82a672df2fd328fd620ed831f32e6fe55f7a1a36 | Ruby | joejknowles/Challenges | /method-calc-implicit.rb | UTF-8 | 1,027 | 3.5625 | 4 | [] | no_license | def zero
return 0 unless block_given?
yield 0
end
def one
return 1 unless block_given?
yield 1
end
def two
return 2 unless block_given?
yield 2
end
def three
return 3 unless block_given?
yield 3
end
def four
return 4 unless block_given?
yield 4
end
def five
return 5 unless block_given?
yield 5
e... | true |
eb32159e7850f84f101eea567795503b6825d7a5 | Ruby | hasrthur/pay_with_me | /lib/pay_with_me/models/config.rb | UTF-8 | 1,230 | 2.671875 | 3 | [
"MIT"
] | permissive | module PayWithMe
module Models
class Config
def self.create(allowed_options)
new(allowed_options).tap do |c|
generate_methods_for! c, with_allowed: allowed_options
yield c if block_given?
end
end
def self.generate_methods_for!(config, with_allowed: [])
... | true |
66c8270eb3191d8ac4ef15e4451b664b192cfa16 | Ruby | anaisofia/intro_a_ruby | /unidad1/sesion2/mayor4/mayor_de_4.rb | UTF-8 | 679 | 2.796875 | 3 | [] | no_license | numero1 = ARGV[0].to_i
numero2 = ARGV[1].to_i
numero3 = ARGV[2].to_i
numero4 = ARGV[3].to_i
if ARGV[3].to_i == nil
if numero1 >= numero2 && numero1 >= numero3
puts numero1
elsif numero2 >= numero1 && numero2 >= numero3
puts numero2
else numero3 >= numero1 && numero3 >= numero2
puts numero3
end
else... | true |
a311ed6549c8e9adcd3dac259747025a3a349598 | Ruby | luchrist777/ruby-methods-readme-onl01-seng-pt-050420 | /lib/example.rb | UTF-8 | 204 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def
say_hello_ten_times
phrase = "Hello World!"
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
puts phrase
end
say_hello_ten_times | true |
44c7b934606c76da7dd0b1061435aa4fb925513b | Ruby | d0c-s4vage/funder | /fields.rb | UTF-8 | 10,789 | 2.625 | 3 | [] | no_license | # Copyright (c) 2010, Nephi Johnson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of
# ... | true |
4f8ec298aaffe8e9719c4db569451f0c71d39a51 | Ruby | snakedoc23/nba55 | /lib/tasks/games.rake | UTF-8 | 1,736 | 2.515625 | 3 | [] | no_license | desc "Fetch games"
task :fetch_games => :environment do
require 'nokogiri'
require 'open-uri'
# (25).each do |x|
x = 30
month = "201210"
day = x.to_s
day = "0#{x.to_s}" if x < 10
day = "#{month}#{day}"
url = "http://www.sbrforum.com/nba-basketball/odds-scores/#{day}/"
doc = Nokogiri::... | true |
a1b355f3bd65ffd0b847b250992d568a175b92a2 | Ruby | h3rald/glyph | /spec/lib/bookmark_spec.rb | UTF-8 | 2,262 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
#!/usr/bin/env ruby
require File.join(File.dirname(__FILE__), "..", "spec_helper")
describe Glyph::Bookmark do
before do
@b = Glyph::Bookmark.new :id => :test, :file => "test.glyph"
end
it "should be initialized with at least an id" do
expect { Glyph::Bookmark.new }.to raise_error
expect ... | true |
c294b2d3a6ace0ed0e736f41ae0aa9765858107d | Ruby | shunsuke227ono/algorithm_questions | /sorting_and_searching/ruby/merge_sort.rb | UTF-8 | 1,087 | 3.734375 | 4 | [] | no_license | # 2017/05/04
# 普通のマージソートの実装
# inplaceで
def merge_sort(arr,si,ei)
return if si == ei
mi = (si+ei)/2
merge_sort(arr,si,mi)
merge_sort(arr,mi+1,ei)
merge(arr,si,mi,ei)
end
def merge(arr,si,mi,ei)
left_copy = []
(si..mi).each { |i| left_copy << i }
left_i = si # leftの中での最先端のポインタ
right_i = mi+1 # rightの... | true |
9dfb56ab8a438f1f797265b0dc5a79a8695164b4 | Ruby | jjfarlinger/hard_way | /ex11.rb | UTF-8 | 961 | 4.40625 | 4 | [] | no_license | #Prompting Users
#Prompts user for age.
print "How old are you?"
#The age variable is going to take in the user input (gets) and remove the newline (.chomp)
age = gets.chomp
print "How tall are you?"
height = gets.chomp
print "How much do you weigh?"
weight = gets.chomp
puts "So, you're #{age} old, #{height} tall an... | true |
0568f9e914d9678ad3b9a9aea0547037a79f7d5b | Ruby | shunfan/woola-api | /woola.rb | UTF-8 | 3,455 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'redis'
require 'resque'
require 'sinatra/base'
require './config'
require './lib/url'
require './lib/wot'
require './lib/virustotal'
class Woola < Sinatra::Base
$r = Redis.new
Resque.redis = $r
Resque.redis.namespace = 'resque:woola'
# ALLOW cross domain access for ajax.
before do
... | true |
c8fbb05c00206c07f43c4e476696823e1bd5ecba | Ruby | nirojsapkota/sales_tax_demo | /utils/utility_functions.rb | UTF-8 | 371 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
module Utils
# Utility functions for number formatting
module UtilityFunctions
require 'csv'
# round to nearest 0.05
# algorithm used
# round(x / precision)) * precision
def round_to_nearest(val)
(val * 20).round / 20.0
end
def format_number(float)
... | true |
c4a7ac9bc73fcc39100ed87127d2cc4da258a8bf | Ruby | m-negishi/ruby_training | /TeachYourselfRuby/section10/10.3.2.rb | UTF-8 | 191 | 3.15625 | 3 | [] | no_license | print 'file> '
filename = gets
filename.chomp!
if File.exist?(filename)
File.delete(filename)
puts "#{filename} を削除しました"
else
puts "#{filename} が存在しません"
end
| true |
b9be6ccabf92dae6fb7841ddf085cb99be0ce43d | Ruby | kaiomagalhaes/ruby-exercism | /ruby/word-count/word_count.rb | UTF-8 | 289 | 3.484375 | 3 | [] | no_license | class Phrase
def initialize(phrase)
@words = phrase.downcase.scan(/[\w']+/)
end
def word_count
@word_count ||= words_counted
end
private
def words_counted
@word_count = @words.each_with_object(Hash.new(0)) do |word, hash|
hash[word] += 1
end
end
end
| true |
b093d92011a60df0fdd63b96c9e5be9619c83617 | Ruby | yhara/esquis | /lib/esquis/type.rb | UTF-8 | 1,818 | 2.625 | 3 | [
"MIT"
] | permissive | module Esquis
module Type
# Returns it is allowed to pass a value of arg_ty as a parameter of
# param_ty. Needed for current (ad-hoc) numeric type coersion rule.
def self.acceptable?(param_ty, arg_ty)
if compatible?(param_ty, arg_ty)
true
elsif param_ty == TyRaw["i32"] && arg_ty == Ty... | true |
f3cfcc4356d67bdd3002d6640a559b3c86c267b9 | Ruby | jasonnoble/capy | /lib/capy.rb | UTF-8 | 1,747 | 2.625 | 3 | [
"MIT"
] | permissive | require "capy/version"
require "slop"
require "colored"
require 'capybara/dsl'
module Capy
class << self
attr_reader :opts
def run(args)
@opts = Slop.parse!(args, :help => true) do
banner "capy [script.capy]\n"
on :n, :nonstop
end
exit if opts.help?
Capybara.register... | true |
f27d421d2da3593b39cda4db0fca1a803b9f91cb | Ruby | marisol-lopez/run_safe | /lib/run_notifier.rb | UTF-8 | 1,291 | 3.046875 | 3 | [] | no_license | class RunNotifier
def initialize(run_id)
puts "*****I made it inside of the RunNotifier method*****"
@run_id = run_id
end
def run_not_ended
puts ">>> In run_not_ended, time is #{Time.now}"
run = Run.find(@run_id)
run_end_time = Time.parse(run.end_time)
time_now = Time.now
puts "My run... | true |
ad4f00813d6fd624131aedceb097ec09f2ffb82b | Ruby | UnnemotionalHyena/IPP | /Lab_1-2/star.rb | UTF-8 | 1,054 | 3.015625 | 3 | [] | no_license | class Star
attr_reader :x, :y
def initialize(color)
@animation = Gosu::Image::load_tiles("media/star.png", 25, 25)
@color = Gosu::Color::BLACK.dup
case color
when 1 then color_l = [255,0,0]
when 2 then color_l = [0,255,0]
when 3 then color_l = [0,0,255]
end
@color.red = co... | true |
239de29093e9cc5aef72a5bd9b74fef325bfc00f | Ruby | gwolf/sistop | /codigo/process_e2fsdump | UTF-8 | 3,636 | 3.03125 | 3 | [
"CC-BY-4.0"
] | permissive | #!/usr/bin/ruby
# coding: utf-8
require 'chunky_png'
filename = ARGV.shift or raise Exception, 'Specify a file with the output of dumpe2fs!'
width = ARGV.shift.to_i
width = 1024 if width==0
@debug = ARGV.shift.to_i rescue 0
def fill(from, to, with)
(to - from + 1).times {|b| @map[from+b] = with}
end
def log(level,... | true |
d513e0453ddfc483e1f218fe8b22c70cbc6c5ee9 | Ruby | kangkyu/learn_to_program2 | /12_01_example.rb | UTF-8 | 303 | 3.515625 | 4 | [] | no_license | time = Time.new
time2 = time + 60 # one minute later.
puts time
puts time2
puts Time.local(2000,1,1)
puts Time.local(1975,3,2,4,16)
# parentheses are to group the parameters
# to local together, otherwise,
# puts might start thinking those are its parameters.
puts Time.gm(1955,11,5)
puts time2-time | true |
1d308b87f8ee06bcdeb05c261e168175d122cb2f | Ruby | davidlares/ruby-overview | /matrices.rb | UTF-8 | 507 | 3.546875 | 4 | [
"MIT"
] | permissive | # matrices en ruby - diferente del arreglo por la cantidad de dimensiones
# matrices = 2 dimensiones
# tienen que ser del mismo tamano (arreglos internos)
require 'matrix' #importamos la clase matrix
matriz = Matrix[[1,8,2],[6,2,3], [1,1,1]]
matriz.each do |i|
puts i
end
matriz.each(:diagonal) do |i| # 1 2 1
put... | true |
756ab82549f69c3f98b655161e6ac96d1540a30c | Ruby | adam12/rack-unpoly | /lib/sinatra/unpoly.rb | UTF-8 | 1,486 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
require "rack/unpoly/middleware"
require "delegate"
module Sinatra
# The Unpoly extension for Sinatra provides a little bit of sugar to make
# Unpoly work seamlessly with Roda.
#
#
# = Example
#
# require "sinatra/base"
# require "sinatra/unpoly"
#
# class App <... | true |
f6dca249f8a8e6271af2621024de486db217307b | Ruby | chconnor82/essential_ruby | /challenge_1.rb | UTF-8 | 706 | 4.1875 | 4 | [] | no_license | # ===========
# CHALLENGE 1
# ===========
# Suppose we are building a loan payment calculator.
# The method should return the size of each payment given these three things.
# Before we can teach the computer how to automate a task,
# we usually have to do some research on how the task is done:
# http://en.wikiped... | true |
5b522af5f6c119cc885c7380fa56f670516080dd | Ruby | tferraro/TADP | /ruby/PrototypedObject.rb | UTF-8 | 907 | 3.546875 | 4 | [] | no_license | class Object
def clone_object
PrototypedObject.new self #Podemos usar CUALQUIER OBJETO, como prototipo gorda!
end
end
class PrototypedObject
attr_accessor :protoptype
def initialize(protoptype= Object.new)
self.protoptype = protoptype
end
def set_property(sym, value)
self.singleton_class.send :attr_acces... | true |
9d7b5c0e376953dd927dcebe8715aeb273549c03 | Ruby | hoshinotsuyoshi/euler | /lib/euler051.rb | UTF-8 | 1,035 | 3.140625 | 3 | [] | no_license | require 'prime'
module IntegerRefine
refine Array do
def position(x)
pos = []
each_with_index do |e, i|
pos.push i if e == x
end
pos
end
def full_combination
ful_comb = []
(1..size).each do |n|
ful_comb = ful_comb + combination(n).to_a
end
f... | true |
6ca1dc23e3bd7b0ccf9867b69f7db7bcc84222e2 | Ruby | kamyu104/effrb | /coverage/widget.rb | UTF-8 | 745 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | ################################################################################
# This file is part of the package effrb. It is subject to the license
# terms in the LICENSE.md file found in the top-level directory of
# this distribution and at https://github.com/pjones/effrb. No part of
# the effrb package, including... | true |
456fc4dce430ee1a5a835e4b3cdd2c6c28c00968 | Ruby | AVzayats/ruby | /page/base_page.rb | UTF-8 | 506 | 2.734375 | 3 | [] | no_license | require_relative '../helper/driver'
class BasePage
USER_ACCOUNT = {xpath: "//li[@class ='nav-item identifier']"}
HOME = {xpath: "//div[@class ='logo']//a"}
def initialize
web_driver = Driver.new
@@driver = web_driver.get_instance
end
def user_account_drop_down
@@driver.find_element(USER_ACCOUNT... | true |
75be1901027763ac36d0c4e92a81e56b6393a3d9 | Ruby | jarretmoses/coderbyte-ruby | /easy_challenges/first_reverse.rb | UTF-8 | 331 | 3.84375 | 4 | [] | no_license | #Using Ruby built in reverse in place for higher efficiency
def FirstReverse(string)
return str.reverse!
end
#Manual reverse in place
# def FirstReverse(str)
# front , back = 0, str.size-1
# while front < back
# str[front], str[back] = str[back], str[front]
# front+=1
# back-=1
# end
# str ... | true |
3d705dea66d21fb6fa81504455fea745f0f5bc85 | Ruby | Coderdotnew/intro_web_apps_bs | /05_class/03_challenges/code/02_emails/spec/emails_spec.rb | UTF-8 | 663 | 2.609375 | 3 | [] | no_license | require_relative './spec_helper'
require_relative '../emails.rb'
describe "firstname_from_email" do
coderdotnew_emails = ["michael@coderdotnew.com", "stephan@coderdotnew.com", "natalie@coderdotnew.com"]
it 'returns an array of first names that comes before the @ symbol for each email in the coderdotnew array' do
... | true |
8afb4f2561a31a645cefb26864ba73e95799be64 | Ruby | paidlabs/reaction | /lib/reaction/has_attributes.rb | UTF-8 | 1,460 | 2.828125 | 3 | [
"MIT"
] | permissive | module Reaction
module HasAttributes
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def attribute(name)
attr_accessor name
eval(getter_code(name))
attributes << name
end
def attributes
if self == Reaction::Action
... | true |
ef7f999122ea28b07efb9beb4e8eb85b9f330611 | Ruby | heapsource/scarlett | /examples/producer.rb | UTF-8 | 286 | 2.703125 | 3 | [
"MIT"
] | permissive | $:.unshift(File.expand_path("../../lib", __FILE__))
require "scarlett"
class Job
def initialize(name)
@name = name
end
def run
sleep 5
puts @name
end
end
queue = Scarlett::Queue.new("jobs_queue")
(1..10).each do |name|
job = Job.new(name)
queue.push(job)
end
| true |
ad4397b647e0d8add2b11147581f628184f1b2ab | Ruby | aweber212/phase-0-tracks | /practice-assessments/calculator.rb | UTF-8 | 867 | 3.703125 | 4 | [] | no_license |
def calculate(x, y, z)
if y == '+'
ans = x + z
elsif y == '-'
ans = x - z
elsif y == '*'
ans = x * z
elsif y == '/'
ans = x / z
end
end
# calculate(3, '+', 5)
# calculate(4, '-', 2)
# calculate(3, '*', 10)
# calculate(21, '/', 7)
terminate = "done"
user_calc = ""
answers = []
... | true |
9f1cac52303b937f026514589463ec3f00575bac | Ruby | SidharthNambiar/Launch-School | /course_101_programming_foundations/lesson_4/example_4.rb | UTF-8 | 527 | 4.0625 | 4 | [] | no_license | # Course 101 Programming Foundations
# Lesson 4: Ruby Collections
# Selection and Transformation: Example 4
# For example, let's create a method called multiply
# that can take an additional argument to determine
# the transformation criteria.
def multiply(numbers, multiplier)
counter = 0
result = []
lo... | true |
85d11b174c400b0cf183a420b07b8a03a95deafc | Ruby | kjell-fjeldsaunet/mastermind | /lib/mastermind.rb | UTF-8 | 802 | 3 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'game'
require_relative 'loading_screen'
playing = true
games_played = 0
player_name = ''
while playing
print 'Booting up the AI '
game = nil
LoadingScreen.show_loading_dots { game = Game.new }
unless games_played.positive?
puts game.welcome
puts game.ins... | true |
11fa06cde9e931eba37aed623c7e3f74cb74545a | Ruby | MalekYmn/Intro-to-programming-with-ruby | /flow_control/exercise3.rb | UTF-8 | 446 | 4.3125 | 4 | [] | no_license | puts "Give a number between 0 and 100"
a = gets.chomp.to_i
if (a >= 0) && (a < 50)
puts 'the number is between 0 and 50'
elsif (a >= 50) && (a < 100)
puts 'the number is between 50 and 100'
else
puts 'the number provided is not between 0 and 100'
end
#also
if a < 0
"you can't put negative numbers"
elsif a <= ... | true |
6eeb20fa37de77eb1d59ec774f94b4ae830fe638 | Ruby | Mattia46/boris_bikes | /spec/docking_station_spec.rb | UTF-8 | 2,324 | 3.578125 | 4 | [] | no_license | require 'docking_station.rb'
# we can indicate all the path, if we run the rspec file
# from a spec subdirectory. (we can indicate through ../lib/name_file.rb)
describe DockingStation do # capitol letter because is a class
it 'each instance begins with 20 bikes' do
expect(subject.bike_counter.size).to eq 2... | true |
063d7e5c0e7cb3262a8e2e9a7bebc168b4929e44 | Ruby | dagezi/vector_be_winding | /spec/vector_be_winding/spatial_tree_spec.rb | UTF-8 | 1,364 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module VectorBeWinding
class DummyRect < Rect
include SpatialTree
def bounding_rect
Rect.new(left, top, right, bottom)
end
end
describe "SpatialTree" do
let (:rect0) { DummyRect.new(10, 10, 100, 100) }
let (:rect00) { DummyRect.new(10, 10, 50, 50) }
let (:rec... | true |
75998568618d4b7294bdd49236d12a817a00b3ec | Ruby | pmahoney/mini_aether | /lib/mini_aether/config.rb | UTF-8 | 819 | 2.640625 | 3 | [
"MIT"
] | permissive | module MiniAether
MAVEN_CENTRAL_REPO = 'http://repo1.maven.org/maven2'.freeze
class LoggerConfig
attr_reader :level
def initialize
@level = 'INFO'
end
def level=(level)
@level = case level
when Symbol, String
level.to_s.upcase
when Logger... | true |
7d07ba2ee65951fe6dff9d2dbed88f17371cee54 | Ruby | dball1126/W2D2 | /class_inheritance/manager.rb | UTF-8 | 708 | 3.3125 | 3 | [] | no_license | require_relative "employee"
class Manager < Employee
attr_reader :employees
def initialize(name, title, salary, boss)
@employees = []
super
end
def bonus(multiplier)
self.collect_salaries * multiplier
end
def collect_salaries
# return employee.salary un... | true |
e2286ffaaf63f0ed70701180cd356cd735562ab0 | Ruby | jalyna/oakdex-battle | /lib/oakdex/battle/status_conditions/base.rb | UTF-8 | 661 | 2.8125 | 3 | [
"MIT"
] | permissive | module Oakdex
class Battle
module StatusConditions
# Represents Abstract Class Base
class Base
attr_reader :pokemon
def initialize(pokemon)
@pokemon = pokemon
end
def before_turn(turn); end
def after_turn(turn); end
def after_fainted(battle... | true |
191e067ffe6eb68b7ab10582bf190422e4a14896 | Ruby | Dchyk/LS-Intro-to-Programming | /the_basics/3.rb | UTF-8 | 655 | 3.0625 | 3 | [] | no_license | # 3. Movie titles
release_dates = {
"Star Wars" => 1977,
"The Empire Strikes Back" => 1980,
"Return of the Jedi" => 1983,
"The Phantom Menace" => 1999,
"Attack of the Clones" => 2002,
"Revenge of the Sith" => 2005,
"The Force Awakens" => 2015,
"The Last Jedi" ... | true |
90a7326a154fef75fe1b6ed2eb662420afba1485 | Ruby | rphaeh/mx | /DevScripts/elementsHUsingFile.rb | UTF-8 | 1,580 | 2.65625 | 3 | [
"MIT"
] | permissive |
def elementsHUsingFile( alias_symbol, actual_symbol )
# one off stupid files for using statements
File.open("../Sourcecode/mx/core/elements/#{alias_symbol}.h", "w") do |stupid_one_off_file|
stupid_one_off_file << "// MusicXML Class Library v0.1.1" << "\n"
stupid_one_off_file << "// Copyright (c) 2015 - 2016 by ... | true |
cb64f4e41885925cf358a786653235a712696890 | Ruby | Spatterjaaay/Scrabble | /specs/tilebag_spec.rb | UTF-8 | 1,502 | 2.65625 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
require_relative '../lib/score'
require_relative '../lib/letter'
require_relative '../lib/player'
require_relative '../lib/tilebag'
Minitest::Reporters.use!
Minitest::Reporters::SpecReporter.new
... | true |
4368598bdbd2384a3a5c87af58e7e548161b5845 | Ruby | dxsfung/hair-salon | /spec/client_spec.rb | UTF-8 | 1,588 | 2.75 | 3 | [] | no_license | require('spec_helper')
describe(Client) do
describe(".all") do
it("starts off with no clients") do
expect(Client.all()).to(eq([]))
end
end
describe("#name") do
it("tells you its name") do
client = Client.new({:name => "David Storemanager", :id => nil})
... | true |
c57cdc7c8ced15f1172e4cb30f7c536afd6e7bdd | Ruby | POXZASY/CodeForFun | /Project_Euler_Solutions/Solution_60.rb | UTF-8 | 2,539 | 4.125 | 4 | [] | no_license | require "set"
#lowest sum of a set of 5 primes for which any two primes concatenate to product another prime
#solution: 13 5197 5701 6733 8389, sum 26033
$primes = Set.new
def isPrime(n)
$primes.each do |p|
return false if n%p == 0
break if p > Math.sqrt(n)
end
return true
end
def numDigits(n)
digits = 0
w... | true |
c646fab66e76adafefca878baefa71f0c8fa6b26 | Ruby | jljardon/sql-library-lab-v-000 | /lib/querying.rb | UTF-8 | 1,004 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
'select b.title, b.year from books b where b.series_id = 1 order by b.year;'
end
def select_name_and_motto_of_char_with_longest_motto
'select name, motto from characters order by length(motto) desc limit 1;'
end
def select_value_and_count_of_most_p... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.