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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ad8021d370e5bd9a69e048c502d169a4f92b636a | Ruby | mattbeedle/davinci | /vendor/plugins/flex_image/test/mock_file.rb | UTF-8 | 172 | 3.09375 | 3 | [
"MIT"
] | permissive | class MockFile
attr_reader :path
def initialize(path)
@path = path
end
def size
1
end
def read
File.open(@path) { |f| f.read }
end
end | true |
f31eefe70a0aa1a28b4e582095ec650b27609b85 | Ruby | cmingxu/hotel | /vendor/plugins/captcha/lib/captcha_image_generator.rb | UTF-8 | 2,658 | 2.75 | 3 | [
"MIT"
] | permissive | begin
require 'RMagick'
rescue Exception => e
puts "Warning: RMagick not installed, you cannot generate captcha images on this machine"
end
require 'captcha_util'
module CaptchaImageGenerator
@@eligible_chars = %w(A B C D E F G H J K L M N P Q R S T U V X Y Z)
#insub @@eligible_chars = (2..9).to_a +... | true |
7ea56431f26ab8d51c9272ea08d7ae13e88eaeb4 | Ruby | rmake/cor-engine | /packages/experimentals/experimental_projects/set_on_enter_callback/resources/start.rb | UTF-8 | 848 | 2.6875 | 3 | [
"MIT"
] | permissive |
class MyObject
def self.create
# nd3.pngの一番左上の画像からspriteを作成する
f0 = SpriteFrame.create "nd3_anim.png", Rect.create(0, 0, 64, 64)
sprite = Sprite.create_with_sprite_frame f0
# sceneに追加されて最初に呼ばれる(add_childのあとくらい?) <- なくていい
#sprite.set_on_enter_callback do
sprite.run_action Ro... | true |
7ffff83aa5cc4622b753dc739586aff448b58c95 | Ruby | kevinlo123/code-wars-challenge | /problems-24.rb | UTF-8 | 431 | 3.90625 | 4 | [] | no_license | =begin
Return the number (count) of vowels in the given string.
We will consider a, e, i, o, and u as vowels for this Kata.
The input string will only consist of lower case letters and/or spaces.
=end
def getCount(inputStr)
count = 0
arr = inputStr.split("");
arr.each do |item|
if item == 'a' || item == 'e'... | true |
ce8ab8751e7792b9190680a22cf0a9698b2d18ce | Ruby | Timdavidcole/Oystercard-1 | /lib/oystercard.rb | UTF-8 | 1,747 | 3.4375 | 3 | [] | no_license | require 'pry'
require_relative 'journey.rb'
class Oystercard
DEFAULT_MAX_BALANCE = 90
MIN_FAIR = 1
attr_reader :balance, :max_balance, :money, :journeys, :current_journey
def initialize(balance = 0, max_balance = DEFAULT_MAX_BALANCE)
@balance = balance
@max_balance = max_balance
@journeys = []
... | true |
e846b49dc018000bbf4ea5e0f67c19b27aa5f0ea | Ruby | chinnu21131/day3 | /classes2.rb | UTF-8 | 354 | 3.59375 | 4 | [] | no_license | class Book
attr_reader :title, :author, :price
attr_writer :title, :author, :price
def is_price_high?
if @price>1000
return true
else
return false
end
end
end
b1=Book.new
b1.title='The coven'
b1.author="Prashanth"
puts "Enter the book price : "
b1.price=gets.chomp.to_i
puts b1.title
puts b1.author
put... | true |
927f01ff43ba3b719442c86202b47a7079becc74 | Ruby | Jojograndjojo/learn_to_program | /ch09-writing-your-own-methods/roman_numerals.rb | UTF-8 | 670 | 3.4375 | 3 | [] | no_license | def roman_numeral n
thousand = n / 1000
hundreds = n % 1000 / 100
tens = n % 100 / 10
units = n % 10
thousand_to_s = 'M' * thousand
if hundreds == 9
hundreds_to_s = 'CM'
elsif hundreds == 4
rhundreds_to_s = 'CD'
else
hundreds_to_s = 'D' * (n % 1000 / 500) + 'C' * (n % 500 / 100)
end
if tens... | true |
849340f858177c25d0a0499c9e2d630bf48a2491 | Ruby | kaljt/live_sessions | /etl_test.rb | UTF-8 | 634 | 2.796875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'etl'
class ScrabbleScoreTest < MiniTest::Unit::TestCase
def setup; end
def test_empty
old = {}
assert_equal({}, ScrabbleScore.convert(old))
end
def test_one
old = {1=> ['A','E','I','O','U']}
assert_equal({'a' => 1, 'e' => 1,
... | true |
89bd45586f3a50f6e144721ca79182fcfccf38fe | Ruby | matanco/MathLib | /lib/math_lib.rb | UTF-8 | 1,655 | 3.671875 | 4 | [
"MIT"
] | permissive | require "math_lib/version"
class String
def is_number?
true if Float(self) rescue false
end
##= move all expressions to same side in equation and equal it to 0
def orginize_equation
gsub!(' ','')
##TODO:: orginaize
end
end
module MathLib
class MathValidator
##= Validate the all input a... | true |
12033b9049a866bc3683445c853aca7ec4d122b2 | Ruby | mdsol/mauth-client-ruby | /exe/mauth-client | UTF-8 | 8,433 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
require 'faraday'
require 'logger'
require 'mauth/client'
require 'mauth/faraday'
require 'yaml'
require 'term/ansicolor'
# OPTION PARSER
require 'optparse'
# $options default values
$options = {... | true |
2e8a315d2023e33005c2cc8fb0fce8a94de91039 | Ruby | nickborromeo/edx-saas | /OOP/spec/jelly_bean_spec.rb | UTF-8 | 586 | 2.515625 | 3 | [] | no_license | require "spec_helper"
describe "JellyBean" do
describe "#delicious?" do
it "black-licorice should not be delicious" do
jelly_bean = JellyBean.new("jelly bean", "250", "black-licorice")
jelly_bean.delicious?.should == false
end
it "all other flavors should be delicious" do
jelly_bean = ... | true |
ebae5b10ab7886fcba59b4fcc86d071c721ebf2c | Ruby | chienleow/ruby-collaborating-objects-lab-online-web-sp-000 | /lib/song.rb | UTF-8 | 529 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.new_by_filename(file_name)
# binding.pry
split_file_name = file_name.split(" - ")
song = self.new(split_file_name[1])
... | true |
062c6e57d9671a4ed53d5e3e3cb05a33b8104a68 | Ruby | malbrecht0792/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 628 | 4.125 | 4 | [] | no_license | #write your code here
def echo(word)
return word
end
def shout(word)
return word.upcase
end
def repeat(word, num = 2)
num.times do |x|
return word + (" " + word) * (num - 1)
end
end
def start_of_word(word, num)
return word[0..num-1]
end
def first_word(word)
word.split[0]
end
def titleize(word)
non_cap_arr... | true |
e701c02bf33992f6f067386f9203a53288bfe38f | Ruby | ryangreenberg/welder | /spec/board_spec.rb | UTF-8 | 7,896 | 3.4375 | 3 | [] | no_license | require 'spec_helper'
describe Welder::Board do
it "has a coordinate system zero-indexed from the top-left" do
letters = <<-EOS
abcd
efgh
ijkl
mnop
EOS
tiles = get_tiles_for_string(letters)
board = get_board_for_tiles(tiles)
tiles.each_with_index do |row, y|
row.eac... | true |
805790fa8300812157057340d8f1c36879d7d5b1 | Ruby | purpleD17/pairwise-api | /vendor/cache/rails-e53a9789b873/actionmailer/lib/action_mailer/vendor/tmail-1.2.7/tmail/vendor/rchardet-1.3/lib/rchardet/hebrewprober.rb | UTF-8 | 12,871 | 2.96875 | 3 | [
"LGPL-2.1-only",
"MIT",
"LGPL-2.0-or-later",
"BSD-3-Clause"
] | permissive | ######################## BEGIN LICENSE BLOCK ########################
# The Original Code is Mozilla Universal charset detector code.
#
# The Initial Developer of the Original Code is
# Shy Shalom
# Portions created by the Initial Developer are Copyright (C) 2005
# the Initial Developer. All Rights Reserved.
#... | true |
23317f6d4ee9151dfd161bfbb7f7e1a79f1a1c52 | Ruby | cyber-dojo/start-points-base | /app/src/from_script/check_image_name.rb | UTF-8 | 1,145 | 2.8125 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative 'show_error'
require_relative 'well_formed_image_name'
module CheckImageName
include ShowError
include WellFormedImageName
def check_image_name(url, filename, json, error_code)
ok = json['image_name']
ok &&= image_name_is_string(url, filename, json, error_code)
ok && image_name_is_... | true |
dc19d5a4ad095068417ae7d98b313843efdbbf29 | Ruby | rranelli/advisor | /spec/advisor/factory_spec.rb | UTF-8 | 1,381 | 2.5625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | describe Advisor::Factory do
subject(:factory) { described_class.new(advice_klass) }
let(:advice_klass) do
Struct.new(:obj, :method, :call_args, :args) do
define_method(:call) { 'overridden!' }
define_singleton_method(:applier_method) { 'apply_advice_to' }
end
end
let(:advice_instance) do
... | true |
2ca18a9086cb57c023b8a81acd07ce826d6d65f4 | Ruby | jtuchscherer/super-simple-load-generator | /load_generator.rb | UTF-8 | 1,197 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby
$stdout.sync = true
$stderr.sync = true
require 'open-uri'
require 'openssl'
base_url = ENV["base_url"]
time_start = ENV["lower_bound"]
time_end = ENV["upper_bound"]
paths = ENV["url_paths"].split(",") unless ENV["url_paths"].nil? || ENV["url_paths"].empty?
username = ENV["username"]
password = ENV["... | true |
4101b82b160d0e0e6cfb85fbbe9ab6da2d748838 | Ruby | gdhaworth/lua-table_reader | /spec/lib/lua/table_reader/lua_parser_spec.rb | UTF-8 | 3,127 | 2.890625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | require 'spec_helper'
describe Lua::TableReader::LuaParser do
subject(:parser) { Lua::TableReader::LuaParser.new }
context 'when parsing tables' do
let(:rule) { parser.table }
it 'consumes empty tables' do
rule.parse('{ }')
end
context 'with only key-value pairs' do
it 'co... | true |
89d7f16bdf48a36b4cdf434c08645c2012ccfa7c | Ruby | lucanioi/exercism-ruby | /resistor-color/resistor_color.rb | UTF-8 | 188 | 2.515625 | 3 | [] | no_license | module ResistorColor
COLORS = %w[black brown red orange yellow
green blue violet grey white]
module_function
def color_code(color)
COLORS.index(color)
end
end
| true |
fdcaf1c8c7492fd543062a02ff0b3bcfb9dc4704 | Ruby | cwkarwisch/RB101 | /small_problems/easy_9/exer_05.rb | UTF-8 | 1,096 | 4.09375 | 4 | [] | no_license | =begin
Input: string
Output: boolean
Explicit Reqs:
Returns true if all alpha characters are uppercase
False otherwise
Ignore non slphs characters
Implicit Reqs
Empty string should return true
Validate for non-string input?
- return nil
Look througyh every character in the string
- If the character is alphabeti... | true |
02c6e602de47d65ab859af089a5227d6063c464b | Ruby | scottzero/sweater_weather_api | /app/models/background_poro.rb | UTF-8 | 159 | 2.546875 | 3 | [] | no_license | class BackgroundPoro
attr_reader :id, :url
def initialize(img)
@id = img[:photos][:photo][0][:id]
@url = img[:photos][:photo][0][:url_o]
end
end
| true |
4532340f54ee6f25098af2002ad3d6ffce3383b7 | Ruby | conf/dotfiles | /bin/balance | UTF-8 | 1,051 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'httparty'
require 'nokogiri'
def osx_password(domain)
res = %x(find-internet-password #{domain}).strip.split(':')
end
def get_html
login, pass = osx_password('cabinet.st.uz')
form = { 'LoginForm' => { username: login, password: pass } }
res = HTTParty.post('https://cabinet.st.uz'... | true |
83f84231cc897623b659aedd43387702020e5992 | Ruby | lsylvain1726/Launch_School2017 | /methods/exercise4.rb | UTF-8 | 226 | 3.875 | 4 | [] | no_license | #methods exercise4.rb
def scream(words)
words = words + "!!!!"
return
puts words
end
scream("Yippeee")
#It will print nothing because the return in the
#middle of the method stops the method from
#executing any further | true |
b2229e051cff0f3a52acd9192d609ae5b039f358 | Ruby | RailsEventStore/rails_event_store | /ruby_event_store/lib/ruby_event_store/correlated_commands.rb | UTF-8 | 918 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module RubyEventStore
class CorrelatedCommands
def initialize(event_store, command_bus)
@event_store = event_store
@command_bus = command_bus
end
class MiniEvent < Struct.new(:correlation_id, :message_id)
end
def call(command)
correlation_id = eve... | true |
8a666073920904c347cbd9dbb3d1b48ec9906600 | Ruby | livash/AppAcademy_work | /Poker/lib/hand.rb | UTF-8 | 796 | 3.09375 | 3 | [] | no_license | require_relative 'deck'
require_relative 'card_suits_faces'
class Hand
include CardSuitsFaces
attr_accessor :cards
def initialize(*cards)
@cards = cards
puts "cards = #{cards.class}"
end
#private
def suits_hash
return_hash = {}
cards.each do |card|
if return_hash[card.suit].n... | true |
f5de01be9636f46643eb102f5431c65f602e21d7 | Ruby | rkh/travis-lite | /lib/travis/lite/views/repositories.rb | UTF-8 | 1,212 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'travis/lite/views/layout'
module Travis
module Lite
module Views
class Repositories < Layout
def repositories
@repositories.map do |repository|
{
slug: repository.slug,
last_build_number: repository.last_build_number,
last_bui... | true |
14d84b738c2c30d5cdecc8338a2a9fd3eeb164fc | Ruby | crest-cassia/ID_Module | /simulator/example1.rb | UTF-8 | 623 | 2.796875 | 3 | [] | no_license | #!/home/osaka/.rvm/rubies/ruby-1.9.3-p551/bin/ruby
require 'json'
def norm_rand(mu=0,sigma=1.0)
r1,r2=Random.rand(),Random.rand();
Math::sqrt(-1*Math::log(r1))*Math::cos(2*Math::PI*r2)*sigma+mu
end
# x0=ARGV[0].to_f
# x1=ARGV[1].to_f
# x2=ARGV[2].to_f
# x3=ARGV[3].to_f
# x4=ARGV[4].to_f
# x5=ARGV[5].to_f
# x6=AR... | true |
870e66e6fd82c567ef64e53dea1640acefecbccf | Ruby | prashulsingh/COEN_278_Fall_2020 | /Assignment/1/Problem5.rb | UTF-8 | 1,012 | 2.765625 | 3 | [] | no_license |
class Webpage
attr_accessor :template
def initialize(str)
@template = str
end
def filter
newStr = ""
@template.split("\n").each do |line|
tempLine = line.strip
# ^<% starts with % ans %>$ ends with , similary ^% means start of string contains %s
... | true |
0c49182e5dece5dfca32cb66bd7f8acb6fab871b | Ruby | eay/ruby-scripts | /projecteuler.net/euler-76-80.rb | UTF-8 | 5,285 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env ruby
# Taken from http://projecteuler.net
require_relative 'primes.rb'
require_relative 'groupings.rb'
# Brute force recursive - 3m.
# This is a customised version of Integer#groupings
# There must be a better way.
# 190569291
def problem_76a
num = 100
solve = lambda do |a,off,max|
n = 0
whi... | true |
1bdcf5c9beb37e349d36c48e35f085c546b7920c | Ruby | RafaelAlonso/batch-446-mvc-class | /view.rb | UTF-8 | 352 | 3.21875 | 3 | [] | no_license | class View
def ask_task_name_for_user
# perguntar para o usuário qual o nome da task que ele quer adicionar
puts "Qual o nome da tarefa que deseja adicionar, mestre?"
return gets.chomp
end
def show_all_tasks(all_tasks)
all_tasks.each_with_index do |task, pos|
puts "#{pos + 1} - #{task.name... | true |
a38da056cc6b80110ceb8d2f4e2edc6df7e4908c | Ruby | salmanhoque/ruby_oop_rspec_test | /rspec/test_movie.rb | UTF-8 | 931 | 3.015625 | 3 | [] | no_license | require File.expand_path('lib/movie.rb')
require File.expand_path('lib/store.rb')
describe "#MovieClass" do
describe "initilizing the movie class" do
before :each do
@a = Movie.new("Super Man",2013,8.5)
end
context "its a movie instance" do
it { @a.should be_an_instance_of Movie }
end
context "its... | true |
c9e41fd577233e5a072e167b9620a7f0df2b156f | Ruby | n0918k/Dokosukagram | /spec/models/user_spec.rb | UTF-8 | 3,158 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
before do
@user = FactoryBot.build(:user)
end
describe 'ユーザー登録' do
context 'ユーザー登録できるとき' do
it '全て入力されていたら登録できる' do
expect(@user).to be_valid
end
end
context 'ユーザー登録できないとき' do
it 'ニックネームがないと登録できない' do
@... | true |
1cf8992363a88e445fb38b1085b89eec5aa3e840 | Ruby | mqgmaster/uam-eps-das | /Exe1/Exe1/domain/message/ConferenceMessage.rb | UTF-8 | 422 | 3 | 3 | [] | no_license | require "domain/message/Message"
#conferenceDate
#conferenceLocation
class ConferenceMessage < Message
def initialize(author, topic, date, location)
super(author, topic)
@conferenceDate = date
@conferenceLocation = location
end
def to_s
return super.to_s +
" | Fecha de la reunión:... | true |
cd5fc9ecce15fea719a303eac73cb9e018403688 | Ruby | getschomp/email_scraper | /lib/email_scraper_app/email_collection.rb | UTF-8 | 330 | 2.828125 | 3 | [] | no_license | require 'valid_email'
class EmailCollection
attr_reader :all
def initialize
@all = []
end
def all=(collection)
@all = collection
validate_email_domains
end
def validate_email_domains
@all.select! do |email|
ValidateEmail.valid?(email)
ValidateEmail.mx_valid?(email)
end
... | true |
4e8f8b0f19f74ef7b13bfde107123b082b7cf45b | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz51_sols/solutions/Anthony Moralez/discard_player.rb | UTF-8 | 329 | 2.90625 | 3 | [
"MIT"
] | permissive | class DiscardPlayer < Player
def initialize
@data = ""
super
end
def show( game_data )
@data << game_data
end
def move
if @data.include?("Draw from?")
"n"
else
if @data =~ /Hand: (.+?)\s*$/
"d#{$1.split.first.sub(/nv/,"")}"
end
end
ensure
@data = ""
... | true |
409a8018c10802cb34c8bbb32a42ed113564891b | Ruby | KillerDesigner/mzl | /spec/collections_spec.rb | UTF-8 | 4,906 | 2.875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'Class.mzl' do
let(:klass) { Class.new { mzl.override_new } }
let(:child_klass) {
Class.new(klass) do
mzl.def(:i_am) { |val| @identity = val }
mzl.def(:who_am_i?, persist: true) { @identity }
def initialize(opts = {}) @opts = opts; end
attr_reader :opts
... | true |
9addccc444e9fa6c1b63fda27bb559101d313ef8 | Ruby | paulorades/synthea | /lib/generic/logic.rb | UTF-8 | 8,758 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | module Synthea
module Generic
module Logic
class Condition
include Synthea::Generic::Metadata
include Synthea::Generic::Hashable
metadata 'condition_type', ignore: true
def initialize(condition)
from_hash(condition)
end
def compare(lhs, rhs, opera... | true |
272c1b229c67a88ba4f6526491f7d92b12d52657 | Ruby | lazoxco/national_parks_california | /lib/national_parks_california/cli.rb | UTF-8 | 314 | 2.84375 | 3 | [
"MIT"
] | permissive | class NationalParksCalifornia::CLI
def call
puts "Welcome to the National Parks Gem"
puts "You can look up National Parks by State.\n"
puts "Please pick a state to learn more about it's National Parks:"
list_states
end
def list_states
State.all
end
end | true |
6ff056b53f46b47a6fdb6f2c76a169b1dc925586 | Ruby | marlonsingleton/crimson-stone | /practice/ttt_game.rb | UTF-8 | 4,913 | 4 | 4 | [] | no_license | class CellMoves
attr_accessor :moves, :human_wins, :computer_wins
def initialize
@moves = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
@human_wins = ["X", "X", "X"]
@computer_wins = ["O", "O", "O"]
end
end
class Board < CellMoves
def ttt_board
puts ""
puts " #{moves[0]} | #{move... | true |
32e0006f872b0b50dbb1a2bd56b40831597dfc7e | Ruby | khoomelvin/bitrise-step-ipa-info | /step.rb | UTF-8 | 4,612 | 2.78125 | 3 | [] | no_license | require 'json'
require 'ipa_analyzer'
require 'optparse'
require 'zip'
require 'zip/filesystem'
require 'pngdefry'
# -----------------------
# --- functions
# -----------------------
def fail_with_message(message)
puts "\e[31m#{message}\e[0m"
exit(1)
end
def get_ios_ipa_info(ipa_path)
parsed_ipa_infos = {
... | true |
3733d78ff155aa66b40e08c104a65764551a4d97 | Ruby | Seraff/pandoraea | /ko_parser.rb | UTF-8 | 1,404 | 3.0625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'csv'
class Organism
attr_accessor :name, :kos
def initialize(name)
@name = name
@kos = []
load_data
end
def load_data
f = File.open(filename, 'r')
result = []
f.read.each_line do |line|
ko = parse_ko(line)
result << ko if ko
end
@kos = re... | true |
c9f2c4b687ea7e12dde1b1f2297aaa5c6eadea59 | Ruby | davemaurer/ruby-practice | /turing_resources/mythical-creatures/medusa/person.rb | UTF-8 | 227 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative 'medusa'
class Person
attr_reader :name
attr_accessor :victims
def initialize(name)
@name = name
@stoned = false
@victims = []
end
def stoned?
@victims.include?(self)
end
end
| true |
7b9f9e75606fc696a5fe755d413ccc212c86031d | Ruby | bloopletech/retryable | /lib/reretryable.rb | UTF-8 | 631 | 2.796875 | 3 | [] | no_license | module Retryable
def retryable(options = {}, &block)
opts = { :tries => 1,
:on => StandardError,
:sleep => 0,
:matching => /.*/ }.merge(options)
return nil if opts[:tries] == 0
retry_exception = [opts[:on]].flatten
tries = opts[:tri... | true |
33c45c2b1fbfac30bf6d6a9e65bb05543760cc36 | Ruby | jalyna/oakdex-pokemon | /lib/oakdex/pokemon/growth_events/base.rb | UTF-8 | 671 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'forwardable'
class Oakdex::Pokemon
module GrowthEvents
# Represents Base GrowthEvent
class Base
def initialize(pokemon, options = {})
@pokemon = pokemon
@options = options
end
def read_only?
possible_actions.empty?
end
def possible_actions
... | true |
0347aa8a731cfa2b9fb90eaea4722d45bfc732dd | Ruby | nbielak/event_site | /db/seeds.rb | UTF-8 | 12,101 | 2.625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
711431a5bdf082a237167414fc77ef3142e6ab8b | Ruby | newfront/dailyhacking | /word_problems/strstr.rb | UTF-8 | 664 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env ruby
def strstr(haystack, needle)
# haystack is of a particular length
# needle is of a particular length
h_len = haystack.size
n_len = needle.size
unless h_len >= n_len
return false
end
# continue
# how many test cycles must we run to compare hayst... | true |
688bda0c1144c8416d79316aeb781613e11424fd | Ruby | matbgn/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 2,432 | 3.171875 | 3 | [] | no_license | require 'open-uri'
require 'json'
class GamesController < ApplicationController
def new
@letters = generate_grid(10)
end
def score
@attempt = params[:attempt]
@letters = params[:letters].delete(' ').chars
@result = final_score(@attempt, @letters)
end
private
def generate_grid(grid_size)
... | true |
5227b6b2f0e5cb73b6bfe13af50cba8f86ca0cd0 | Ruby | ShelbyTV/shelby_gt | /app/helpers/roll_helper.rb | UTF-8 | 480 | 2.5625 | 3 | [] | no_license | module RollHelper
# This is used in the context: "Dan is following your <title_for_roll_on_follow>"
def title_for_roll_on_follow(roll)
case roll.roll_type
when Roll::TYPES[:special_watch_later]
"Likes Roll"
when Roll::TYPES[:special_public_real_user], Roll::TYPES[:special_public], Roll::TYPES[:sp... | true |
6a70bd875a94b988b446bdfe72e4cd46c2beb86d | Ruby | Naveen1789/ruby_code | /leetcode/algorithms/length_of_last_word_58.rb | UTF-8 | 157 | 3.265625 | 3 | [] | no_license | # @param {String} s
# @return {Integer}
def length_of_last_word(s)
arr = s.split(" ").compact
return arr.size < 1 ? 0 : arr[arr.size - 1].length
end
| true |
1e03e3e1bc08ad5e990739e1aa01cbab80148da4 | Ruby | mgoodhart5/sorting_cards | /lib/guess.rb | UTF-8 | 322 | 3.59375 | 4 | [] | no_license | require 'pry'
class Guess
attr_reader :response, :card
def initialize(response, card)
@response = response
@card = card
end
def correct?
@response.split(" of ") == [ @card.value, @card.suit ]
end
def feedback
if correct?
"You win!"
else
"You're wrong."
end
end
en... | true |
5bcbb2fafa270d7d98353848b42782d281be0574 | Ruby | Algorithms-DrBaharav/alg-ramanujan1729-student-cyoce | /ramanujan.rb | UTF-8 | 211 | 3.046875 | 3 | [] | no_license | def ramanujan(n=1729)
out = []
(1..Math.cbrt(n).floor).each do |i|
(i..Math.cbrt(n).floor).each do |j|
out << [i,j].sort! if i**3 + j**3 == n
end
end
out
end
| true |
ba4de4acab4091723a7bcc4218ac0d8fc5cf8ce8 | Ruby | Sevos83/Lesson-10 | /cargo_carriage.rb | UTF-8 | 444 | 3.1875 | 3 | [] | no_license | # frozen_string_literal: true
class CargoCarriage
attr_reader :total_volume, :filled_volume, :free_volume
def initialize(number, total_volume)
@number = number
@type = :cargo
@total_volume = total_volume
@free_volume = total_volume
end
def fill_volume(volume)
self.filled_volume += volume
... | true |
f980f580b133530269a1abdd505494be72a430e5 | Ruby | velvelshteynberg/rubymethods | /rubymethodassignmentintro.rb | UTF-8 | 651 | 4.3125 | 4 | [] | no_license | # # Question-what does the command class do to an integer and to a string
#puts "pragramming".class
#puts 12.class
# #question- When do you use a = and when do you use ==?
# def my_first_method
# return 1 + 1
# end
# puts my_first_method
# def reverse_sign (num)
# return num * 8 /8
# end
# puts reverse_s... | true |
5a2460000a4cf0e7545aa65b487f262f90e9fcde | Ruby | dailybeast/subreddit_analysis | /app/models/base.rb | UTF-8 | 880 | 2.703125 | 3 | [
"MIT"
] | permissive | class Base
def initialize(props = {})
props.each { |name, value| instance_variable_set("@#{name}", value) }
end
def self.quote(s)
if s.nil?
return 'null'
elsif s.is_a? Numeric
return s
else
return "'#{s.gsub("'", "''")}'"
end
end
def quote(s)
Base.quote(s)
end
d... | true |
7a4c9c1e9297d2d545135abafa10e9276f3c8a49 | Ruby | Mariana-21/Enigma | /test/shift_test.rb | UTF-8 | 908 | 3.078125 | 3 | [] | no_license | require './test/test_helper'
require './lib/enigma'
require './lib/shift'
require 'date'
require 'minitest/autorun'
require 'minitest/pride'
require 'mocha/minitest'
class ShiftTest < Minitest::Test
def setup
@shift = Shift.new('020320', '15234')
end
def test_it_exsits
assert_instance_of Shift, @shift
... | true |
0c0e8e2066999daf10142c8bcb73be1371370d9a | Ruby | 19WH1A0578/BVRITHYDERABAD | /CSE/Scripting Languages Lab/18WH1A05A0/LabProgram4.rb | UTF-8 | 378 | 3.109375 | 3 | [] | no_license | #file = "/home/sravani/Desktop/SL/LabProgram3.rb"
puts "Enter the file name"
file = gets.chomp
#file name
fbname = File.basename file
puts "File Name : "+fbname
#base name
bname = File.basename file,".rb"
puts "Base Name : "+bname
#file extension
fextn = File.extname file
puts "File Extension : "+fextn
#path name
... | true |
c680cacc169c63ce2b5d84fda1c64f79e44db8d6 | Ruby | sploving/shogun | /examples/undocumented/ruby_modular/library_fisher2x3_modular.rb | UTF-8 | 568 | 2.84375 | 3 | [] | no_license | # this was trancekoded by the awesome trancekoder
require 'narray'
require 'modshogun'
require 'load'
require 'pp'
x=array([[20.0,15,15],[10,20,20]])
y=array([[21,21,18],[19,19,22]])
z=array([[15,27,18],[32,5,23]])
parameter_list = [[x,concatenate((x,y,z),1)],[y,concatenate((y,y,x),1)]]
def library_fisher2x3_modula... | true |
c928f1f2d489cc6995a6bded59f6438299791471 | Ruby | nchambe2/phase-0 | /week-8/ruby-review/ruby_review.rb | UTF-8 | 6,122 | 4.5 | 4 | [
"MIT"
] | permissive | # Create a Bingo Scorer (SOLO CHALLENGE)
# I spent [#] hours on this challenge.
# Pseudocode
#CREATE a class called BingoScorer
#CREATE a method called initialize which takes in a nested collection object of numbers
# Create a method to generate a letter ( b, i, n, g, o) and a number (1-100)
#Select a random let... | true |
78be4ec99d0c9dc18c1f50325e396899f6842b31 | Ruby | imarkwick/rock_paper_scissors | /spec/game_spec.rb | UTF-8 | 792 | 3.078125 | 3 | [] | no_license | require 'game'
describe Game do
let(:game) { Game.new }
let(:player) { double :player }
it "can have a player" do
game.add_player(player)
expect(game.player).to eq (player)
end
it "knows how many move options" do
expect(game.move_count).to eq 3
end
it "the robot move is either - rock pape... | true |
d9f2e1eafcb420abb10693d455990d9772bd3da2 | Ruby | OrangeCrush/pluralizer.rb | /heuristic.rb | UTF-8 | 3,238 | 3.6875 | 4 | [
"MIT"
] | permissive | # This class is used as a base class for heuristics
# determining whether or not a word is plural
class Heuristic
# @data will be the training set in the following format
# [...[singular_word, plural_word], ...]
# Rules will be /regexp1/ => [ /regexp2/, replace_str]
# Where
# regexp1 is the regex def... | true |
e11f4fcc38bd759960461e63f82e23614213f92b | Ruby | Project-ShangriLa/shangrila-sdk-ruby | /lib/shangrila/sora.rb | UTF-8 | 2,777 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'uri'
require 'json'
require 'httpclient'
module Shangrila
class Sora
def initialize(hostname = 'api.moemoe.tokyo')
@url = "http://#{hostname}/anime/v1/master"
end
# @param [Int] year データ取得対象のアニメの年
# @param [Int] cours データ取得対象のアニメの年のクール番号 1-4
# @return [JSON] ア... | true |
b7562c6019d1c3f1f3ef8a22ee340cb1e12325d9 | Ruby | OwenKLenz/Codewars | /4_kyu/count_squares_on_chess_board.rb | UTF-8 | 8,812 | 3.90625 | 4 | [] | no_license | # Input: a 2d array representing a chess board (of varying sizes)
# Output: a hash with keys representing the dimensions of the squares, contained
# in the board (a key of 2 would represent a 2 x 2 square). The value is an
# integer representing the number of squares of key size.
# Rules: Find all of the squares (... | true |
9deac4f4f0f52a0da572d6c604fbc814867e78b4 | Ruby | andrely/Norwegian-NLP-models | /scripts/processors/test/normalization_processor_test.rb | UTF-8 | 1,674 | 2.65625 | 3 | [] | no_license | require 'test/unit'
require_relative '../normalization_processor'
require_relative '../../test/data_repository'
require_relative '../../sources/array_source'
class NormalizationProcessorTest < Test::Unit::TestCase
def test_normalization_processor
proc = NormalizationProcessor.new(proc_map: { :form => lambda { |... | true |
266d22a34ba58549eb150301e3ed85afac0c8ab6 | Ruby | brennancheung/prie | /lib/prie/main_parser.rb | UTF-8 | 8,099 | 3.53125 | 4 | [] | no_license | require "prie/parser"
module Prie
class MainParser < Prie::Parser
attr_accessor :words
def run(input_text)
result = self.parse(input_text)
self.execute_loop(result)
end
def return(input_text)
self.run(input_text)
@stack.pop
end
# Mechanism to allow words to be decl... | true |
2b577640cff9fb99b9503c1041c873decc886976 | Ruby | jclif/ruby-primitives | /iteration/factors.rb | UTF-8 | 158 | 3.453125 | 3 | [] | no_license | def factors(number)
factors = []
1.upto(number) do |factor|
factors << factor if number % factor == 0
end
factors
end
p factors(8)
p factors (13) | true |
18e5d60e34077f1406469cbee9cd570030f2a26f | Ruby | chrisvel/Dijkstra-maze-solver | /lib/mazesolver.rb | UTF-8 | 7,320 | 3.78125 | 4 | [] | no_license | ##
# 2d matrix maze solver
#
# The story:
# The program parses the maze as a string when the object is initialized and
# saves it in an array. The nodes are saved in series, so we need to reverse
# the table in order to use the matrix as a table [x,y].
#
# For the calculations to be easier, the reversed table's nodes a... | true |
2b3b03a5aec628b634833af045ab8b01b73ba088 | Ruby | afrikanhut/smsbazar | /lib/tasks/add.rake | UTF-8 | 1,210 | 2.625 | 3 | [] | no_license | desc "Console Gateway"
task :add => :environment do
require "config/environment"
require "lib/sms_session_tracker"
require "lib/menu_browser"
session_tracker = SmsSessionTracker.new
menu_browser = MenuBrowser.new
print "Enter your phone number "
phone = STDIN.gets.chomp
print "Enter your sms messa... | true |
7603bc3338a699fb62d200a943409ce680053fd8 | Ruby | EliasGolubev/stack_overflow | /app/models/search.rb | UTF-8 | 439 | 2.625 | 3 | [] | no_license | class Search
RESOURSES = %w[All Questions Answers Comments Users].freeze
def self.find(query, resourse)
return nil if query.try(:blank?) || !RESOURSES.include?(resourse)
query = ThinkingSphinx::Query.escape(query)
resourse == 'All' ? ThinkingSphinx.search(query) : ThinkingSphinx.search(query, classes: ... | true |
d43bca6a4287a9264930b49dab636e97aa93363c | Ruby | reddavis/NLP-Backpack | /lib/nlp_backpack/classifiers/base.rb | UTF-8 | 563 | 2.515625 | 3 | [
"MIT"
] | permissive | module NLPBackpack
module Classifier
class Base
class << self
def load(db_path)
data = ""
File.open(db_path) do |f|
while line = f.gets
data << line
end
end
Marshal.load(data)
end
end
attr_accessor :d... | true |
b70c1dd780492ad858ab5a5ac4ca4a658e9cb147 | Ruby | fajarachmadyusup13/Playgrounds-Web | /Ruby/Intro/strings.rb | UTF-8 | 1,166 | 3.921875 | 4 | [] | no_license | # puts "Add Them #{4+3} \n\n"
# puts 'Add Them #{4+3} \n\n'
# multiline_string = <<EOM
# this is a very long string
# that contains interpolation
# like #{4 + 5} \n\n
# EOM
# puts multiline_string
# -----------------------------------------------
first_name = "Boo"
last_name = "Zoo"
middle_name = "Moo"
# full_name... | true |
a8f684ed43430a19e08a2eba0abcd1db9d26930f | Ruby | alinadin09/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 2,281 | 4.53125 | 5 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# set default quantity to 1
# print the list to the console [can you use one of your methods here?]
# output: [what data type goes here, array or hash?] a hash
def create_list(items)
# Make an ... | true |
6b8d55651cce68c1ed27d5f6d49aa98f35e2d2cb | Ruby | FranklinZhang1992/unity-learning | /ruby/demo_tests/array_test.rb | UTF-8 | 544 | 3.578125 | 4 | [] | no_license | arr = nil
begin
puts "arr = nil, empty?: #{arr.empty?}"
rescue => err
puts "arr = nil, empty?: #{err}"
end
arr = []
puts "arr = [], empty?: #{arr.empty?}"
str = nil
begin
arr = str.split(' ')
p arr
rescue => err
puts "error: #{err}"
end
str = ""
arr = str.split(' ')
p arr
str = "0 1 2"
arr = str.spl... | true |
ea6846bc65b516e4c626fca5353eddb18fc0234a | Ruby | kg-coderta/atcoder | /abc/153.rb | UTF-8 | 265 | 3.25 | 3 | [] | no_license | A
a,b = gets.split.map(&:to_i)
if a % b == 0
puts a/b
else
puts (a/b) +1
end
B
a,b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
d = c.length
attack = 0
for num in 0..d-1 do
attack += c[num]
end
if a <= attack
puts "Yes"
else
puts "No"
end
C
D
E
F | true |
4d0b97b59ec3c4d0bb16bc4561a7451d46dbd9ce | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w02/d02/Emmanuel_Tucker/homework_d01_w02/sinatra_1.rb | UTF-8 | 649 | 2.84375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
get '/' do
'Hello world'
end
get '/name/:name' do
"hello #{params[:name]}"
end
# Example:
# Request: '/tea/neel/omar'
# Response: 'neel and omar are having a lovely tea ceremony'
# Request: '/battle/matt/omar'
# Response: omar beats neel.
# note: the winner should be ... | true |
ee0549bd5f7163c2023dc78aaa7c7f79106c2841 | Ruby | beslnet/desafiosruby | /3.rb | UTF-8 | 149 | 3.0625 | 3 | [] | no_license | a = [1,2,3]
b = [:azul, :rojo, :amarillo]
c = ["Tacos", "Quesadillas", "Hamburguesas"]
abc = [a, b, c]
nuevo_arreglo = abc.flatten
p nuevo_arreglo | true |
ebdb1b6ca569ccb261b9ca34dea7c9a62e25c6fd | Ruby | GabrielRMorales/hangman | /hangman.rb | UTF-8 | 2,062 | 3.84375 | 4 | [] | no_license | require "csv"
require "yaml"
class Hangman
def initialize
list=File.readlines "5desk.csv"
@word=list.sample
while @word.length<5 || @word.length>12
@word=list.sample
end
@display_word=String.new
(@word.length-1).times do
@display_word<<"_"
end
@wrong_letters... | true |
42bd9122b2ab259ad3f213672f3baa1ddb1f96ae | Ruby | JLHill84/firstDayTest | /mod1/aug8/self.rb | UTF-8 | 298 | 3.546875 | 4 | [] | no_license | class Dog
attr_accessor :name, :owner
def initialize(name)
@name = name
end
def get_adopted(owner_name)
self.owner = owner_name
end
end
fido = Dog.new("fido")
# adopted(fido, "Steve")
puts fido.get_adopted("Cheesus")
# puts fido.name = "FIDO" | true |
0ba6c57816ddf8316479a406f0c188c322af53b8 | Ruby | halogenandtoast/nhk-reader | /lib/base64_image.rb | UTF-8 | 310 | 2.953125 | 3 | [] | no_license | class Base64Image
def initialize(content_type, data)
@content_type = content_type
@data = data
end
def to_s
"data:#{content_type};base64,#{encoded_content}"
end
private
attr_reader :content_type, :data
def encoded_content
@_encoded_content ||= Base64.encode64(data)
end
end
| true |
8e2cd566562714a47b6895101cbcd7bafebdc3b4 | Ruby | gee-forr/mentoring_with_citizen428 | /exercise01_card_game/card_dealer_tests.rb | UTF-8 | 1,922 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
# Need a newer version of minitest for assert_output, these two lines do that.
require 'rubygems'
gem 'minitest'
require 'minitest/autorun'
require './card_dealer'
class TestCardGame < MiniTest::Unit::TestCase
def setup
srand(1) # Seed the randomizer so that deck shuffles are always t... | true |
76dcc58033efc6911179f896b763532e4d117112 | Ruby | rodhilton/console_table | /examples/stocks.rb | UTF-8 | 1,490 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'console_table'
require 'json'
require 'net/http'
require 'open-uri'
require 'colorize'
symbols = ["YHOO", "AAPL", "GOOG", "MSFT", "C", "MMM", "KO", "WMT", "GM", "IBM", "MCD", "VZ", "HD", "DIS", "INTC"]
params = symbols.collect{|s| "\"#{s}\"" }.join(",")
url = "http://query.yahooapis.com/v1/public/yql?q=sele... | true |
1f15bdd0810fb65a2dd623a2f2e12e323eda1052 | Ruby | ellehallal/ruby-refresher | /modules/length-conversions.rb | UTF-8 | 440 | 3.6875 | 4 | [] | no_license | module LengthConversions
WEBSITE = "http://website.com" #constant
def self.miles_to_feet(miles) #method
miles * 5280
end
def self.miles_to_inches(miles)
feet = miles_to_feet(miles)
feet * 12
end
def self.miles_to_cm(miles)
inches = miles_to_inches(miles)
inches / 2.5
end
end
puts L... | true |
0463cf42663d37d985e279335761f660b2160847 | Ruby | Dexter1210/Rubyidea | /metaprogramming/finders.rb | UTF-8 | 1,968 | 3.140625 | 3 | [] | no_license |
require "active_support/inflector"
$db={
users: [{id:1,username:"user1"},
{id:2,username:"user2"}],
tasks:[
{id:1,title:"task1",completed:true},
{id:2,title:"task1",completed:false},
{id:3,title:"task3",completed:true}
],
projects: [
{ id: 1, title: "Project... | true |
1f6eaa2f1648e60fe7970e0eafc7966f32b828a8 | Ruby | XohoTech/RubyTest | /spec/word_list/count_frequency_spec.rb | UTF-8 | 838 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative '../../word_list/word_list.rb'
require_relative '../../helpers/words_from_string.rb'
RSpec.describe WordList, "#count_frequency" do
before(:each) do
raw_text = %{Array of multiple string values from string of words.}
word_list = words_from_string(raw_text)
@word_list = WordList.new(word... | true |
6f5c3f6fdc66af12bb710a18eb123f6dad2b4362 | Ruby | greytape/learn_to_program_exercises | /program_logger.rb | UTF-8 | 511 | 3.515625 | 4 | [] | no_license | $nesting_depth = 0
def log block_description, &block
$nesting_depth += 1
$nesting_depth.times {print" "}
puts "Block Started!"
output = block.call
$nesting_depth.times {print" "}
puts "Block finished!"
$nesting_depth -= 1
end
log "outer_block" do
log "little block" do
$nesting_depth.times {pr... | true |
d2484792654b6cea592adea1f68d8425c2f17db9 | Ruby | dineshkummarc/ads | /sales.iheart.com/_lib/dump.rb | UTF-8 | 231 | 2.671875 | 3 | [] | no_license | require 'yaml'
conf = YAML.load_file("_config.yml")
type = ARGV[0]
if type == 'css' || type == 'js'
conf[type].each do |i|
print File.open("_site/assets/#{type}/#{i}").read
end
else
puts "C'mon, give me something here!"
end
| true |
1fcbdc50e4787ac3de87a7063745d3e7fdaef7d5 | Ruby | sandrods/legenda | /app/models/legendas.rb | UTF-8 | 623 | 2.59375 | 3 | [] | no_license | require 'open-uri'
class Legendas
def self.destaques
ret = extract("http://www.legendas.tv/destaques.php")
ret << extract("http://www.legendas.tv/destaques.php?start=24")
ret.flatten
end
private
def self.extract(url)
doc = Hpricot(open(url))
leg = []
(doc/"div.Ldestaque").each... | true |
c36f80f4f5a8f01ab9eea31adfd66e05235d7942 | Ruby | pkb4112/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 606 | 3.484375 | 3 | [] | no_license | #write your code here
def add(a,b)
return a + b
end
def subtract (a,b)
return a-b
end
def sum (ray)
ray_sum = 0
if ray[0]==nil
return 0
else
ray.each do |i|
ray_sum=ray_sum+i
end
return ray_sum
end
end
def multiply (a)
product = 1
if a[0] != nil
a.each do |i|
product = prod... | true |
af5637834abed355de54fcb07853eab85131b301 | Ruby | todesking/power_assert-ruby | /lib/power_assert.rb | UTF-8 | 1,868 | 2.71875 | 3 | [] | no_license | require 'ripper'
require 'patm'
require 'typedocs'
module PowerAssert
include Typedocs::DSL
tdoc.typedef :@AST, 'Array'
tdoc.typedef :@Bool, 'TrueClass|FalseClass'
def self.current_context
Thread.current[:power_assert_context] ||= Context.new
end
class Context
def add(expr, value)
end
end
... | true |
6c922c77cfd97a7243a20faf1a14c0e27ce26363 | Ruby | tuzz/pbrt | /lib/pbrt/statement/variadic.rb | UTF-8 | 305 | 2.515625 | 3 | [
"MIT"
] | permissive | module PBRT
class Statement
class Variadic
def initialize(directive, kind, parameter_list)
@directive = directive
@kind = kind
@parameter_list = parameter_list
end
def to_s
%(#@directive "#@kind" #@parameter_list).strip
end
end
end
end
| true |
6f28c4a508d80c1e3cb959f4197de06cfb8a1597 | Ruby | ksolomon7/ruby-oo-object-relationships-my-pets-nyc04-seng-ft-071220 | /lib/cat.rb | UTF-8 | 145 | 2.703125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Cat
attr_accessor :name,:owner
def initialize(name_par,owner_par)
@name=name_par
end
end
# binding.pry
0 | true |
e7bf38c7790681dfb5beea1e0a6337a432d10f91 | Ruby | vickiticki/ruby-exercises | /ruby_basics/11_nested_collections/exercises/nested_array_exercises.rb | UTF-8 | 2,658 | 3.921875 | 4 | [
"MIT"
] | permissive | def blank_seating_chart(number_of_rows, seats_per_row)
# return a 2d array to represent a seating chart that contains
# number_of_rows nested arrays, each with seats_per_row entries of nil to
# represent that each seat is empty.
# Example: blank_seating_chart(2, 3) should return:
# [
# [nil, nil, nil],
... | true |
a46a2de54bfb579b3ad8f4739ed016d99a54da31 | Ruby | Krolmir/ruby-exercises | /intro_to_programming/methods/greeting.rb | UTF-8 | 211 | 4.46875 | 4 | [] | no_license | #Program that prints a greeting message after asking a user to input their name
def greeting(name)
puts "Welcome #{name} to my greeting program!"
end
puts "Please enter your name:"
n = gets.chomp
greeting(n) | true |
522632dffd622c5370a1fd43726eec1a6b12580d | Ruby | djones/pound-append | /pound_append | UTF-8 | 4,896 | 3.375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# == Synopsis
# Allows you to programmatically add new sites to a pound configuration file
#
# == Examples
# This will add a new site to the configuration file running port 10200 matching requests "(www\.|)site\.com"
# So this would link both requests coming from www.site.com and site.com t... | true |
9418cfe1c921782fe7b7a506282581605c236c80 | Ruby | sforsell/phase-0-tracks | /ruby/gps6/my_solution.rb | UTF-8 | 4,421 | 3.890625 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself].
# I spent [3] hours on this challenge.
# EXPLANATION OF require_relative
# file exists in same directory hence the "relative"
# fetches the file in qoutes.
require_relative 'state_data'
class VirusPredictor
# pulls in data for each instance upon initial... | true |
f19341e58fff9beb7655e1eac58832b2677431c8 | Ruby | dalspok/LS101-lesson-2 | /rps_advanced.rb | UTF-8 | 2,184 | 4.0625 | 4 | [] | no_license |
CHOICES_TO_KEYS = { "r" => ["Rock", 5],
"p" => ["Paper", 3],
"s" => ["Scissors", 1],
"l" => ["Lizard", 2],
"o" => ["spOck", 4] }
VALID_CHOICES = CHOICES_TO_KEYS.values.map { |item| item[0] }
VALID_INPUTS = CHOICES_TO_KEYS.keys
score = [0,... | true |
25cc6864d11c3ce3547a0626241e9f03f00a7961 | Ruby | alex-choy/a-A_notes | /01_week/03_day/nauseating_numbers/test/04_nn_test.rb | UTF-8 | 1,801 | 3.984375 | 4 | [] | no_license | require "../lib/04_nauseating_numbers"
### mersenne_prime
p "Mersenne Prime"
p mersenne_prime(1) # 3
p mersenne_prime(2) # 7
p mersenne_prime(3) # 31
p mersenne_prime(4) # 127
p mersenne_prime(6) # 131071
### triangular_word
puts "\n\nTriangular Word"
p triangular_word?("abc") # true
p triangular_word?("ba") ... | true |
08027036f97474bebc4e0a0778c4210b2012131c | Ruby | enogrob/axe-engine | /lib/axe_engine.rb | UTF-8 | 2,299 | 2.6875 | 3 | [] | no_license | #!C:\Program Files\ruby-1.8\bin\ruby.exe
#--
# Copyright (C) 2006 by Ericsson, GSDC Brazil, SW Deployment C.C.
# KSTool : Ruby Programming community
# Prepared : EBS/HD/SB Roberto Nogueira
# Date : 2006-08-07
# Version : 0.0.1
# Ruby : 1.8.4
# Windows : 2000
# File : axe_engine.rb
# Purpose :... | true |
0ba51e5e4759519580296e069e7dbcdbecacc127 | Ruby | denvercm/serviceinch-rails | /app/models/user.rb | UTF-8 | 1,554 | 2.515625 | 3 | [] | no_license | require 'digest/sha1'
class User < ActiveRecord::Base
include Authentication
include Authentication::ByPassword
include Authentication::ByCookieToken
cattr_reader :per_page
@@per_page = 10
has_one :user_access
validates :login, :presence => true,
:length => {:within => 3..40},
... | true |
87e7467329899aa8bbff298ba301c14f43930217 | Ruby | sadah/AtCoder | /BeginnersSelection/abs/abc085b/Main.rb | UTF-8 | 191 | 2.65625 | 3 | [] | no_license |
def solve(n, y)
ret = [-1, -1, -1]
(0..n).each do |i|
(0..(n - i)).each do |j|
k = n - i - j
if()
end
end
end
n, y = gets.strip.split.map(&:to_i)
puts solve(n, y)
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.