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
7d502bcf5cb242f8b12ca71d9c7cc4f6efce5bb2
Ruby
maynkj/valuta
/lib/valuta.rb
UTF-8
860
3.203125
3
[ "MIT" ]
permissive
require_relative "valuta/version" class Valuta FORMAT = /(\d{3})(?=\d)/ SEPARATOR = ".".freeze DEFAULTS = { delimiter: ",", separator: ".", suffix: nil, prefix: nil } def self.convert(number, options={}) return new(options).convert(number) end def initialize(options = {}) @opti...
true
c1b38e614fd27de36c342eb67291be31270584c8
Ruby
SSDany/rack-acceptable
/lib/rack/acceptable/language_tag.rb
UTF-8
13,740
2.6875
3
[ "MIT" ]
permissive
require 'rack/acceptable/utils' module Rack #:nodoc: module Acceptable #:nodoc: # inspired by the 'langtag' gem (author: Martin Dürst) # http://rubyforge.org/projects/langtag/ # http://www.langtag.net/ # class LanguageTag GRANDFATHERED_TAGS = { 'art-lojban' => 'jbo' , 'ce...
true
40ff6bf2033e789220a382c4a55d4d4e25f13f41
Ruby
christoomey/plugin-ruby
/test/class.rb
UTF-8
840
2.59375
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Pret module Tier # object documentation class Object; end # second object # documentation class Object end # third object # documentation class Object attr_accessor :foo end class Object < BasicObject; end class Object < B...
true
48a015c400f9421f83d35a328e9588e94d6b8c1c
Ruby
jmchilton/msi_software_accounting
/vendor/plugins/flotomatic/lib/flot.rb
UTF-8
5,236
2.96875
3
[ "MIT" ]
permissive
# Author:: Michael Cowden # Copyright:: MigraineLiving.com # License:: Distributed under the same terms as Ruby =begin rdoc == Flot This class acts as a ruby wrapper for the flot javascript object. It is the class used in your model / controller to setup your data sets. It is then the object used in the <tt><%=...
true
25eeef2222dc5fae24efc92f4c0b1512b2f65cf5
Ruby
hoppergee/algorithm_practice
/bubble_sort2.rb
UTF-8
299
3.578125
4
[]
no_license
def bubble_sort(a) n = a.size for i in 0...n-1 swapped = false for j in 0...n-i-1 if a[j] > a[j+1] a[j], a[j+1] = a[j+1], a[j] swapped = true end end if swapped == false break end end return a end p bubble_sort [3,4,65,7,8,4,245,78,23]
true
363b70bb8b7d9f72831a27eb515d000933c109b3
Ruby
EdCrux/Tic-Tac-Toe-game
/lib/logic.rb
UTF-8
568
3.4375
3
[ "MIT" ]
permissive
module Logic def self.winner(arr) 3.times do |ite| return true if rows(arr, ite) return true if columns(arr, ite) end return true if tl_rb(arr) || tr_lb(arr) false end def self.rows(arr, ite) (arr[ite * 3] == arr[(ite * 3) + 1]) && (arr[ite * 3] == arr[(ite * 3) + 2]) end de...
true
07b0c06546b1861f2f638189d89765e1f9a36797
Ruby
evgeniy-kunitsa/dip
/logical_operations/image.rb
UTF-8
2,018
3.625
4
[]
no_license
require 'rmagick' require './pixel' class Magick::Image def |(other_image) rows = min_rows(other_image) columns = min_columns(other_image) (0...rows).each do |i| (0...columns).each do |j| self_pixel = self.get_pixels(j, i, 1, 1).first other_image_pixel = other_image.get_pixels(j, i,...
true
014ecdf51254f2e2801c0e37a94c54659b063cce
Ruby
karoster/AppAcademy
/Data_structs/tictactoe_tree/lib/super_computer_player.rb
UTF-8
802
3.40625
3
[]
no_license
require_relative 'tic_tac_toe_node' class SuperComputerPlayer < ComputerPlayer def move(game, mark) node = TicTacToeNode.new(game.board, mark) position = winning_move(node) position = stall_move(node) if position.nil? position end ###Helper Fxns### def winning_move(node) pos = nil node.chil...
true
f6a5de9bb2045692083ff76c258af3ecd592a9d3
Ruby
Lilaro/OO-Art-Gallery-dumbo-web-071519
/app/models/artist.rb
UTF-8
827
3.296875
3
[]
no_license
class Artist attr_reader :name, :years_experience @@all = [] def initialize(name, years_experience) @name = name @years_experience = years_experience @@all << self end def self.all @@all end def paintings Painting.all.select do |piece| piece.artist == self end end ...
true
81d3906e4f66406df64a6f3785a6156f2b3bdb3f
Ruby
akud/mtg_trader
/app/models/card_population/generator.rb
UTF-8
388
2.71875
3
[]
no_license
module CardPopulation class Generator def initialize opts={} @collection = opts[:collection] || GathererCollection.new @writer = opts[:writer] || SeedWriter.new @filter = opts[:filter] || ExcludeCommonsFilter.new end def generate @collection.each_card do |card| @writer.wri...
true
3417ea1d0ac0fd296407fc8a4a5b22c798616905
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/cs169/800/spectral_cluster/recluster/cluster_3/13642/21942.rb
UTF-8
1,056
3.671875
4
[]
no_license
def combine_anagrams(words) if (words == nil or words.length < 2) return words end results = Hash.new {|h,k| h[k] = Array.new} words.each do |word| worddown = word.to_s.downcase.chars.sort.join results[worddown].push(word) results[worddown] end return results.values end p combine_anagrams(nil) p combin...
true
f9ee22c7f179eb6f881af2fd80b08f0c985c3dbe
Ruby
kinoppyd/reading-metaprogramming-ruby
/04_block/03_simple_bot.rb
UTF-8
1,974
3.421875
3
[ "WTFPL" ]
permissive
# 次の仕様を満たすSimpleBotクラスとDSLを作成してください # # # これは、作成するSimpleBotクラスの利用イメージです # class Bot < SimpleBot # setting :name, 'bot' # respond 'keyword' do # "response #{settings.name}" # end # end # # Bot.new.ask('keyword') #=> 'respond bot' # # 1. SimpleBotクラスを継承したクラスは、クラスメソッドrespond, setting, settingsを持ちます # 1. sett...
true
55f739c0d2fa42921527335177d5b67e07ceee54
Ruby
JuHambre/adiserver
/datos/UsuarioDAO.rb
UTF-8
263
2.640625
3
[]
no_license
require_relative '../dominio/usuario' class UsuarioDAO def listar_usuario(login) Usuario.get(login) end def login(email, password) Usuario.first(:password => password) end def registrar_usuario(usuario) Usuario.create(usuario) end end
true
59d2d737dde3a213083c9dcaf80010bfd551af79
Ruby
krschacht/nebel
/test/lib/lesson_part_splitter_test.rb
UTF-8
4,188
3.171875
3
[]
no_license
require "test_helper" require "lesson_part_splitter" class LessonPartSplitterTest < ActiveSupport::TestCase setup do @string_with_parts = "Part 1. Wash\nWash the dishes\nPart 2. Rinse\nRinse the dishes" @string_without_parts = "Wash and rinse the dishes" end test ".new replaces 'Parts' with 'Part'" d...
true
2aef611618d537453deecca7c320acd7a809c399
Ruby
quiteliderally/codeine
/examples/flexible.rb
UTF-8
542
2.625
3
[ "MIT" ]
permissive
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' require 'codeine' module FooModule class A codeine_inject :logger def initialize puts logger.inspect end end end module BarModule class A codeine_inject :logger def initialize puts logger.inspect end end end Codeine.c...
true
1bb549cffa2f4d9b043d28936d993928379296d5
Ruby
annejohnson/euler
/28.rb
UTF-8
171
2.828125
3
[]
no_license
# PROBLEM 28 GRID_SIZE = 1001 sum = 1 inc = 2 next_num = 1 (GRID_SIZE / 2).times do 4.times do next_num += inc sum += next_num end inc += 2 end puts sum
true
7b9be632d3fa9862cfd65792b506e86d05a6b623
Ruby
druplar/dotfiles
/bin/git-cleanup-remotes
UTF-8
978
2.90625
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'shellwords' puts "=> git fetch --all --prune" system 'git fetch --all --prune' branches = `git branch -r --merged master`.lines.map(&:chomp).select{|b| !(b =~ /master$/)}.map{|b| b[2..-1].split('/', 2)} remotes = branches.reduce(Hash.new{|h, k| h[k] = []}) {|h, b| h[b[0]].push b[1];h } r...
true
2e7910c7563393b25fdf7b587cf72f32ed9e9a9d
Ruby
Gerula/interviews
/CareerCup/up_down_array.rb
UTF-8
865
3.21875
3
[ "MIT" ]
permissive
require 'test/unit' extend Test::Unit::Assertions def generate size = Random.rand(5..12) return Array.new(size) { Random.rand(1..30) } end class Array def up_down? 0.upto(self.size - 2).each { |i| return false if i % 2 == 0 && self[i] > self[i + 1] || i % 2 == 1 && self[i] ...
true
ac02ddc8f44159745f4dd052d52236264f4f9219
Ruby
envato/event_sourcery
/lib/event_sourcery/event_store/subscription.rb
UTF-8
2,552
2.875
3
[ "MIT" ]
permissive
module EventSourcery module EventStore # This allows Event Stream Processors (ESPs) to subscribe to an event store, and be notified when new events are # added. class Subscription # # @param event_store Event store to source events from # @param poll_waiter Poll waiter instance used (su...
true
7b3d7155fa8f1cbaf84c75b8aac82592c4d18cac
Ruby
ericcf/deadbolt
/app/models/ability.rb
UTF-8
633
2.515625
3
[]
no_license
class Ability include CanCan::Ability def initialize(user=nil) if user if user.admin? can :manage, :all end add_dynamic_abilities user end end private def add_dynamic_abilities(user) user.roles.each do |role| role.role_permissions.each do |role_permission| ...
true
c288f0a1dff8335990c9cbd5289eec1340b0e623
Ruby
radiospiel/sinatra-sse
/lib/sinatra/sse/marshal.rb
UTF-8
1,778
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
# This file is part of the sinatra-sse ruby gem. # # Copyright (c) 2011, 2012 @radiospiel # Distributed under the terms of the modified BSD license, see LICENSE.BSD require "expectation" # # packing/unpacking SSE events module Sinatra::SSE::Marshal FIXED_ORDER = { :event => 1, :id => 2, :data => ...
true
df166858f2dfd07c411a1612abca1be8dc09a1da
Ruby
sambeca/phrasepalette
/app/models/phrase.rb
UTF-8
167
2.578125
3
[]
no_license
class Phrase < ApplicationRecord belongs_to :user before_save :downcase_phrase def downcase_phrase first_word.downcase! second_word.downcase! end end
true
e34656e40ec4aa4aa6b9c0fb1b7f48fbdb53034d
Ruby
micahbales/Launch-Academy
/challenges/phase-2/dice-game/advanced_dice.rb
UTF-8
418
3.875
4
[]
no_license
input = "" while input != "n" do puts "How many sides do your dice have?" sides = gets.chomp.to_i puts "How many times would you like to roll your dice?" rolls = gets.chomp.to_i rolls.times do die1 = rand(sides) + 1 die2 = rand(sides) + 1 total = die1 + die2 puts "You rolled a #{die1} and a...
true
48f2d5641577513a06324fec16eab97cd84ffc53
Ruby
massud/battleships_mvp_sequence
/spec/submarine_spec.rb
UTF-8
1,312
3.265625
3
[]
no_license
require 'submarine' describe Submarine do let(:sub){Submarine.new 'A2', :north} let(:sub_north){Submarine.new 'B2', :north} let(:sub_east){Submarine.new 'B2', :east} let(:sub_south){Submarine.new 'B2', :south} let(:sub_west){Submarine.new 'B2', :west} it 'has size 2' do expect(sub.size).to eq 2 end...
true
bfc7db964748a555d0288e6dd1b4c1d8659a9a19
Ruby
emrekilinc/narsil
/lib/helpers/string_helper.rb
UTF-8
1,825
2.984375
3
[]
no_license
# encoding: utf-8 class StringHelper def self.generate_code(length) rand(36**length).to_s(36) end def self.generate_safe_string(input) output = input.strip.downcase regexes = [ { regex: /\s*&\s*/, replace: "" }, { regex: /[\\ş]/i, replace:"s" }, { regex: /[\\ğ]/i, replace:"g" }, ...
true
3a82e232159f84a820074698688c76e0b75ec9f0
Ruby
Xaavvii/Mod-One-Project-
/db/seeds.rb
UTF-8
2,563
3.046875
3
[]
no_license
require_relative "../lib/models/pizza.rb" require_relative "../lib/models/topping.rb" #Toppings beef = Topping.find_or_create_by(name: "Beef".colorize(:brown)) #1 extra_cheese = Topping.find_or_create_by(name: "Extra Cheese".colorize(:yellow))#2 sausage = Topping.find_or_create_by(name: "Sausage".colorize(:brown)) #3 ...
true
5fff32d9208ef57448bbde7021a4a41e518b2ebe
Ruby
cflipse/rom-yaml
/lib/rom/yaml/repository.rb
UTF-8
1,664
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'yaml' require 'rom/repository' require 'rom/yaml/dataset' module ROM module YAML # YAML repository # # Connects to a yaml file and uses it as a data-source # # @example # ROM.setup(:yaml, '/path/to/data.yml') # # rom = ROM.finalize.env # # repository = rom.repo...
true
7c702d07fb0fd3cb0cd0313c8d1f425fe98ef1b6
Ruby
learn-co-curriculum/hs-gnomes-v-flamingos
/spec/1_garden_gnome_spec.rb
UTF-8
1,038
3
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require_relative './spec_helper' describe "Garden Gnome" do before do @test_gnome = GardenGnome.new @test_flamingo = LawnFlamingo.new end it "can create individual instances of the garden gnome" do expect(@test_gnome).to be_an_instance_of(GardenGnome) end it "has a name attribute" do @test...
true
508958740e3ca30f5efa1e2500f99caceaf67a6e
Ruby
reqshark/commandlinetools
/sysadmin/backup/rubycookbook/08-Object-Oriented-Programming/04 - Writing an Inherited Class.rb
UTF-8
792
3.734375
4
[]
no_license
class String def scramble (split //).sort_by { rand }.join end end "I once was a normal string.".scramble # => "i arg cn lnws.Ioateosma n r" #--- class UnpredictableString < String def scramble (split //).sort_by { rand }.join end def inspect scramble.inspect end end str = Unpredictable...
true
f6e8de34d8bae4398d65f961b8043bc7980858aa
Ruby
alejandro-medici/retrospectiva
/vendor/plugins/packr/lib/packr/regexp_group.rb
UTF-8
3,663
2.96875
3
[ "MIT" ]
permissive
class Packr class RegexpGroup attr_accessor :values IGNORE = "\\0" BACK_REF = /\\(\d+)/ ESCAPE_CHARS = /\\./ ESCAPE_BRACKETS = /\(\?[:=!]|\[[^\]]+\]/ BRACKETS = /\(/ KEYS = "~" def initialize(values, flags = nil) @values = [] values.each { |key, value| @value...
true
e3393eb1a8d39665bdc84baf82ede641353c0bc2
Ruby
apomata/tdd
/triangle.rb
UTF-8
981
3.71875
4
[]
no_license
require_relative 'Rectangle' require 'pry' class Triangle attr_accessor :c1, :c2, :c3 def initialize(x, y, z) if (x.class == Point && y.class == Point && z.class == Point) @c1 = x @c2 = y @c3 = z else raise ArgumentError end end def area #area of outside triangles #(the tria...
true
335fa25dbea6d72d977734014108f7f649b4e893
Ruby
pencilcheck/tab-sync-websocket
/middlewares/backend.rb
UTF-8
1,443
2.546875
3
[]
no_license
require 'faye/websocket' require 'json' $stdout.sync = true def symbolize_keys(hash) hash.inject({}){|result, (key, value)| new_key = case key when String then key.to_sym else key end new_value = case value when Hash then symbolize_keys(value) ...
true
5166e4251037c6051b31a812c76d9efd107adfce
Ruby
loschtreality/App_Academy
/Algo_Projects/BST_AVL/lib/bst.rb
UTF-8
4,644
3.296875
3
[]
no_license
require 'byebug' class BSTNode attr_accessor :left, :right attr_reader :value def initialize(value) @value = value @left = left @right = right end end class BinarySearchTree def initialize @root = nil end def insert(value) if @root.nil? @root = BSTNode.new(value) else ...
true
c526131fcd4d1bb4df46c64d803c6140d94bf25a
Ruby
andrewlarssen/bitmap_editor
/app/bitmap_editor.rb
UTF-8
2,323
3.90625
4
[]
no_license
# Main program controller class BitmapEditor def run @running = true puts 'type ? for help' while @running print '> ' input = gets.chomp command, *arguments = input.split(' ') execute_command(command, arguments) end end def execute_command(command, arguments) case comm...
true
cacc3c2d834f6356ab6b9973365030b072a08844
Ruby
Hareramrai/bowling-game
/app/models/games/frame_score.rb
UTF-8
853
3.21875
3
[]
no_license
# frozen_string_literal: true class Games::FrameScore PINS = 10 class << self def find_scores(frames, frame_number) frame_score = 0 if strike?(frames, frame_number) frame_score = score(frames, frame_number, 3) frame_number += 1 elsif spare?(frames, frame_number) fram...
true
90df99ad622f21d6312f0b365bfd2441f935f3cb
Ruby
PhillipDMorrisJr/babble
/tests/tile_group/test_hand.rb
UTF-8
711
2.90625
3
[]
no_license
require "minitest/autorun" require_relative "../../tile_group.rb" class TileGroup::TestHand < Minitest::Test def setup @tiles = TileGroup.new end def test_convert_empty_group_to_string assert_equal "", @tiles.hand end def test_convert_single_tile_group_to_string @tiles.append(:Z) assert_equal "Z", @til...
true
57fbfface3b9a6561364cdef8fd32ccb54749549
Ruby
mituba38/furima_28356
/spec/models/user_spec.rb
UTF-8
4,102
2.625
3
[]
no_license
require 'rails_helper' describe User do before do @user = FactoryBot.build(:user) end describe 'ユーザー新規登録' do context '新規登録がうまくいくとき' do it '全てのデータがあれば保存できること' do expect(@user).to be_valid end end context '新規登録がうまくいかないとき' do it 'nicknameが空だと登録できない' do @user.nickna...
true
53622069862fa5f91ff1daec2418950ca10a7f26
Ruby
ryanhouston/share-brew
/app/models/beer_xml/acts_as_beer_importer.rb
UTF-8
1,934
2.75
3
[]
no_license
module BeerXml def self.included(base) base.send :extend, ClassMethods end module ClassMethods def acts_as_beer_importer_of type cattr_accessor :beer_importer_type, :attr_map, :method_map self.beer_importer_type = type send :include, InstanceMethods self end def translate...
true
ed20b1021c7b71b8533aa085be8011978161a3e4
Ruby
yukiyao119/ruby-objects-belong-to-lab-dumbo-web-82619
/lib/song.rb
UTF-8
239
3.171875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :title, :artist def initialize @title = "7/11" end end # song = Song.new("title") # I have access to song.artist => instance beyonce # I also have access to song.artist.name => "Beyonce "
true
54988cea9d21b1b9bc3e589fe573c38031f23318
Ruby
SephoraM/LS-small-problems
/easy5/after_midnight2.rb
UTF-8
479
3.390625
3
[]
no_license
require 'date' MINS_PER_HR = 60 HRS_PER_DAY = 24 def after_midnight(time) hrs, mins = time.split(':') ((hrs.to_i % HRS_PER_DAY) * MINS_PER_HR) + mins.to_i end def before_midnight(time) hrs, mins = time.split(':') -((-(hrs.to_i % HRS_PER_DAY) * MINS_PER_HR) + mins.to_i) end p after_midnight('00:00') == 0 p b...
true
6dc946bc14e6449186fac7aaf1fae39d309838ff
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/filtered-submissions/950ae0c298634aa6841fb346f3667562.rb
UTF-8
300
3.25
3
[]
no_license
def compute(source, dest) return nil unless source.kind_of?(String) and dest.kind_of?(String) distance = 0 max_length = source.length > dest.length ? dest.length : source.length 0.upto(max_length - 1) do |idx| distance += 1 if source[idx] != dest[idx] end distance end
true
e25232364ae948224017ad49ef77ded18bc52206
Ruby
sunspot82/605.484
/project1/test/document_set_test.rb
UTF-8
2,734
2.515625
3
[]
no_license
require "test/unit" require "project1/src/document_set" #**************************************************************** # Test the DocumentSet object. #**************************************************************** class DocumentSetTest < Test::Unit::TestCase #*************************************************...
true
c906c50389a572f3faea47c178a9ad40a8e423d8
Ruby
MI3Guy/Math-Seminar-Project--The-Prime-Detective
/prime-analysis.rb
UTF-8
577
3.328125
3
[]
no_license
require "constants.rb" primes = File.read("primes.txt").split("\n").collect { |n| n.to_i } composites = File.read("composite.txt").split("\n").collect { |n| n.to_i } puts "Prime: #{primes.length}, #{primes.length.to_f/(primes.length + composites.length)}" part_size = MAX_PRIME/20 parts = [] count = 0 primes.each do ...
true
383b294bf9c487293efe035d62f5f2fa2f0defc2
Ruby
Q-Win/battleship
/test/guess_test.rb
UTF-8
1,202
3.03125
3
[]
no_license
require 'simplecov' SimpleCov.start require 'minitest/autorun' require 'minitest/pride' require './lib/board' require './lib/ship' require './lib/guess' class BoardTest < Minitest::Test def test_it_exists guess = Guess.new(4) assert_instance_of Guess, guess end def test_it_has_a_board guess = Gues...
true
2934b8838401ee5444451d5599d5d98a204e3057
Ruby
dojopiaui/conversor-de-moedas
/spec/moeda_spec.rb
UTF-8
1,488
2.96875
3
[]
no_license
require File.dirname(__FILE__) + '/spec_helper' describe "Moeda" do it "deve converter de euro para dolar" do valor = 10 moeda = Moeda.new(valor, "EUR") moeda2 = moeda.converter("USD") moeda2.quantia.should == 14.20 moeda2.moeda_base.should == "USD" moeda2.class.should == Moeda end it "d...
true
21e9e514764b15328587fe3d1e4b282adba50066
Ruby
mikisvaz/rbbt-util
/lib/rbbt/util/simpleopt/parse.rb
UTF-8
1,808
2.796875
3
[ "MIT" ]
permissive
require 'rbbt/util/simpleopt/accessor' module SOPT def self.fix_shortcut(short, long) return short unless short and shortcuts.include?(short) current = shortcuts.select{|s,l| l == long}.collect{|s,l| s }.first return current if current chars = long.chars.to_a current = [chars.shift] short =...
true
34a05007681572c8fe8fc47ea3ed6ad40afa7362
Ruby
noahskang/Portfolio
/w1d2 2/MemoryGame/AIPlayer.rb
UTF-8
300
3.671875
4
[]
no_license
class AIPlayer def initialize(name = "Bob") @name = name end def get_guess puts "Pick a card. e.g. 2, 3: " user_guess = arr_conversion(gets.chomp) user_guess end def arr_conversion(user_guess) user_guess.split(", ").map(&:to_i) end def to_s @name end end
true
66cd8a3fa5dff0c752b84627c756f83965e78429
Ruby
pombredanne/neo4j-perf
/wrapper.rb
UTF-8
882
2.703125
3
[]
no_license
include Java require 'model' DB_PATH = "tmp/neo4j" class Neo4jTraversal attr_reader :traversed def visit_ref_node @traversed = 1 rel = Neo4j.ref_node._rel(:outgoing, 'root') root = rel._end_node traverse(root) end def traverse(folder) size = folder[:size] || 0 folder.in...
true
96d19769e85d0015b442648704fcfc8426e41e55
Ruby
mmorast/ha_demoqa
/poms/index_page.rb
UTF-8
904
2.546875
3
[]
no_license
require_relative './account_page' require_relative './base_page' class IndexPage < BasePage def initialize(webdriver) super() @driver = webdriver goto_page end def goto_page @driver.get(@url_base) unless @driver.current_url == "#{@url_base}" self end def login_as(username, password) ...
true
e09107327d3c12b6707231b9f3f31cf4773e3e5c
Ruby
luca-montaigut/Archives_THP
/4.4_morpion/lib/app/game.rb
UTF-8
2,094
3.328125
3
[]
no_license
# frozen_string_literal: true # Gestion d'une partie class Game attr_accessor :current_player, :status, :board, :players def initialize(player1, player2) # cree 2 joueurs, un board, etc... @players = [] @players << player1 @players << player2 @status = 'on going' @board = Board.new ...
true
35ff721bcb18d56a6ceb03421dfb10e5f0cafbcb
Ruby
jamesonbass1987/sql-crowdfunding-lab-v-000
/lib/sql_queries.rb
UTF-8
1,838
3.21875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Write your sql queries in this file in the appropriate method like the example below: # # def select_category_from_projects # "SELECT category FROM projects;" # end # Make sure each ruby method returns a string containing a valid SQL statement. def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe...
true
afffaaaf571a925a583aad3c83fa811673ad061d
Ruby
justingaylor/rng
/lib/rng/name_file_loader.rb
UTF-8
968
2.984375
3
[]
no_license
module Rng class NameFileLoader attr_reader :segmenter def initialize(segmenter=Rng::Segmenters::FantasyNameSegmenter) reinitialize(segmenter) end def load(path) reinitialize(segmenter) raise Rng::FileLoadError.new("File '#{path}' does not exist.") unless File.exists?...
true
1f411a954e58a5ddc6238303e4c820d2464b4fc6
Ruby
mikedao/httpyykm
/lib/word_search.rb
UTF-8
270
3.109375
3
[]
no_license
class WordSearch DICTIONARY = File.read("/usr/share/dict/words").split("\n") def result(word) dict = DICTIONARY dict.include?(word) if dict.include?(word) "#{word} is a known word." else "#{word} is not a known word." end end end
true
4c3fc00b75ad21125f43f9fbe980197068332fc9
Ruby
seldomatt/playlister-rb
/lib/song.rb
UTF-8
415
3.296875
3
[]
no_license
require_relative 'genre' class Song attr_accessor :name, :artist attr_reader :genre @@songs = [] def initialize @@songs << self end def self.all @@songs end def genre=(genre) @genre = genre genre.songs << self end def artist=(artist) @artist = artist artist.add_song(s...
true
a92035b3b60ee9cb6d1d1fbd3de8edb544d9f67b
Ruby
poymanov/railswinter2017
/np2/lesson31/task-31-01/main.rb
UTF-8
233
3.1875
3
[]
no_license
# encoding: utf-8 require_relative "lib/hashtags" puts "Введите строку с хэштегами:" user_input = STDIN.gets.chomp result = hashtags(user_input) puts "Нашли вот такие хэштеги: #{result}"
true
6dd3ec9594531969301bc483afcc94a94035c095
Ruby
ramblex/euler
/euler-42.rb
UTF-8
1,017
3.828125
4
[]
no_license
# # The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so # the first ten triangle numbers are: # 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... # By converting each letter in a word to a number corresponding to its # alphabetical position and adding these values we form a word value. For example, #...
true
4dea2498f5ae4ae3988e2eb6ac5944264403f42d
Ruby
TheAlgorithms/Ruby
/sorting/merge_sort.rb
UTF-8
827
3.578125
4
[ "MIT" ]
permissive
def merge_sort(array) return array if array.length <= 1 mid = array.length / 2 first_array = array.slice(0..mid - 1) second_array = array.slice(mid..-1) first_array = merge_sort first_array second_array = merge_sort second_array # merge result = [] until first_array.empty? && second_array.empty? ...
true
62037dc68e42c044fb511adb76f637e757611d76
Ruby
aastronautss/ruby-projects
/binary-search-tree/binary-search-tree.rb
UTF-8
2,988
3.953125
4
[]
no_license
class Binary_Search_Tree attr_accessor :root def build(ary = []) shuffled_ary = ary.shuffle @root = Node.new(shuffled_ary.pop) until shuffled_ary.empty? new_node = Node.new(shuffled_ary.pop) insert(new_node) unless new_node.value.nil? end end def insert(new_node, curr...
true
3cfe2569bbf66fd7f36e26912cfc3f83a564783f
Ruby
corinneling/apprentice-notes
/Project List/pi-to-the-nth.rb
UTF-8
347
4.1875
4
[]
no_license
# Find PI to the Nth Digit # Enter a number and have the program generate PI up to that many # decimal places. Keep a limit to how far the program will go. def chosen_digit return gets.chomp.to_i end def get_pi return Math::PI end def find_pi_to_digit p get_pi.round(chosen_digit) end print 'Find PI to what n...
true
5bf4484f28e1f5dd9fcba1ebf746633efb760558
Ruby
mshopsin/Checkers
/player.rb
UTF-8
756
3.609375
4
[]
no_license
require './board' require './token' class Player attr_reader :color attr_accessor :board def initialize(color,board) @color = color @board = board end def take_turn raise 'Not implemented' end end class Human < Player def initialize(color,board) super(color,board) end def take_turn invalid_move = ...
true
bd880d0d0d49f2469a66e8715611213cb1363cc3
Ruby
r-fujiwara/hima-wo-moteamashita-kamigami-no-asobi
/clients/multi_client.rb
UTF-8
581
2.890625
3
[]
no_license
# copy paste from http://morizyun.github.io/blog/parallel-process-ruby-gem/ require "net/http" require 'open-uri' require 'thread' url = "http://localhost:8000" urls = [] 100000.times{|i| urls.push(url) } urls.push(nil) q = Queue.new urls.each { |url| q.push(url) } max_thread = 8 Array.new(max_thread) do |i| Thr...
true
6d9ff7f408c3647cf869ca832203a2b217da8a13
Ruby
emilianolowe/launch-school-exercises
/Ruby/ruby-basic/methods/greeting_through_methods2.rb
UTF-8
109
3.1875
3
[]
no_license
# Exercise 4 def hello 'Hello' end def world 'World' end def greet "#{hello} #{world}" end p greet
true
53fc28021d00ea68d4ae17832785b449252dd523
Ruby
urbas/budPage
/app/helpers/pages.rb
UTF-8
2,431
2.65625
3
[]
no_license
module Pages class Page def initialize(name, *sub_pages, **options) @name = name @sub_pages = Rails.env.production? ? sub_pages.select { |sub_page| !sub_page.is_draft? } : sub_pages @parent_page = nil @is_draft = options.fetch(:is_draft, false) sub_pages.each { |sub_page| sub_page.pa...
true
2c837245771bcb9e9910ce6c2d200762be7bc59d
Ruby
vbsteven/req
/lib/req-cli/variable_interpolator.rb
UTF-8
326
3.140625
3
[]
no_license
class VariableInterpolator attr_reader :variables def initialize(variables = {}) @variables = variables.map { |key, value| [key.to_sym, value] }.to_h end def interpolate(input) input.gsub(/\${[a-zA-Z0-9\-_]*}/) do |m| var = m.scan(/[a-zA-Z0-9\-_]+/).first.to_sym variables[var] end en...
true
c3ad2f62779e2af08935e08df1d73a910ba1a5e4
Ruby
boldport/boldport-club-community
/bin/twitter_harvest/harvest.rb
UTF-8
3,160
2.609375
3
[]
no_license
#!/usr/bin/env ruby $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require "twitter" require "t/rcfile" require "post" require 'optparse' def get_twitter_client rcfile = T::RCFile.instance if rcfile.empty? puts "use `t authorize` to initialize ~/.trc first.." exit(1) end Twitter::R...
true
ebcb573367ef41b0132e14bbc864d5c2d0f26397
Ruby
KellyPT/betsy
/test/models/merchant_test.rb
UTF-8
2,245
2.5625
3
[]
no_license
require 'test_helper' class MerchantTest < ActiveSupport::TestCase test "A new merchant is built with the auth_hash from GitHub" do merchant = Merchant.build_from_github({ uid: "12345", "info" => { "nickname" => "kelly", "email" => "kelly@we.com" } }) assert merchant.valid? end test "Create a Merchant ...
true
e1ce2bf00547f9ddcab93fe9f63df8febab37e52
Ruby
mpazcarvacho/Rails_w1_d2
/usuario.rb
UTF-8
534
3.609375
4
[]
no_license
#Desafío 2 - María Paz Carvacho #Ejercicio 1 class Usuario attr_accessor :nombre, :cuentas def initialize(nombre, cuentas = []) @nombre = nombre @cuentas = cuentas if cuentas.empty? raise RangeError, "El usuario debe tener por lo menos una cuenta bancaria" end end def saldo_total...
true
19bf4f28fae94c9d97b61f38f00866aef47f79db
Ruby
dianorlova/Ruby
/Ruby_practice/labWork-2/lib/apartment.rb
UTF-8
1,195
3.140625
3
[]
no_license
# frozen_string_literal: true require_relative '../lib/parameters' require_relative '../lib/address' # The class describes the apartment class Apartment attr_reader :footage, :number_rooms, :address, :floor, :house_type, :number_of_floors, :cost, :list_param include Comparable def initialize(lst...
true
b65f6bda25ced4db42b04d987353e15c617cb506
Ruby
backpackerhh/exercism
/ruby/word-count/word_count.rb
UTF-8
260
3.28125
3
[]
no_license
class Phrase attr_reader :phrase def initialize(phrase) @phrase = phrase.downcase end def word_count phrase.scan(/[\w]+(?:'[\w]+)*/).each_with_object({}) do |word, counter| counter[word] ||= 0 counter[word] += 1 end end end
true
f8d7c7ef759dbdd35b828e0432f0a9a26fcde6a2
Ruby
tbuehlmann/ponder
/lib/ponder/user.rb
UTF-8
1,558
2.625
3
[ "MIT" ]
permissive
module Ponder class User < Recipient attr_reader :nick def initialize(nick, thaum) super @nick = nick end # Updates the properties of an user. def whois connected do fiber = Fiber.current callbacks = {} # User is online. callbacks[311] = @th...
true
6eaba3b2c600d1e7b37ea1b30eafb118891074d3
Ruby
stevielum1/App_Academy_Homeworks
/w2d4/big_octopus.rb
UTF-8
974
3.796875
4
[]
no_license
fish = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh'] # O(n^2) def sluggish_octopus(fish) longest_fish = "" fish.each do |fish1| fish.each do |fish2| length1 = fish1.length length2 = fish2.length length1 > length2 ? longest_fish = fish1 : longest_f...
true
eb71258422bbaf97e9297938677d998e12a17ead
Ruby
JMoore89/LRubyTHW
/ex15.rb
UTF-8
767
4.125
4
[]
no_license
# Assign the argument from from the cmd line in the ARGV Array filename = ARGV.first # Asking for user input. prompt = "> " # Assigns a File open call with the variable filename as the argument. txt = File.open(filename) # Print a line saying what the filename is. puts "Here's your file: #{filename}" # Prints out wha...
true
efa826f0ac190ee2c0eaaf34a8bb96c35e6a16df
Ruby
maksym-bielyshev/rubylearningcom-tutorial
/p049instvarinherit.rb
UTF-8
176
3.703125
4
[ "Apache-2.0" ]
permissive
class C def initialize @n = 100 end def increase_n @n *= 20 end end class D < C def show_n puts "n is #{@n}" end end d = D.new d.increase_n d.show_n
true
a7b3f908a27403f748b53d2c4836ad5c4dfcb91d
Ruby
JazzyMussels/OO-Auto-Shop-nyc-clarke-web-082619
/app/models/mechanic.rb
UTF-8
356
3.3125
3
[]
no_license
class Mechanic attr_reader :name, :specialty @@all = [] def initialize(name, specialty) @name = name @specialty = specialty @@all << self end def self.all @@all end def cars Car.all.select{|car| car.mechanic == self} end def clients cars.map{|car| car.owner} end def client_names clients.map{...
true
f353da20fed84e7b0f3c47edf74a154dd9846e3a
Ruby
trottomv/botest
/lib/botest.rb
UTF-8
2,945
2.5625
3
[ "MIT" ]
permissive
require 'dotenv' require 'telegram/bot' require 'xkcd' require 'rss' require 'feed-normalizer' require 'open-uri' require 'simple-rss' require 'open-uri' # require 'curb' class Botest Dotenv.load token = ENV['TOKEN'] xkcd = FeedNormalizer::FeedNormalizer.parse open('http://xkcd.com/rss.xml') turnoffus = FeedNormalizer...
true
b0539145525d262b768f202441dab900f729d662
Ruby
jjb/ruby-gc-heap-growth-factor-benchmark
/code.rb
UTF-8
524
2.703125
3
[]
no_license
require 'get_process_mem' puts puts "-------- #{ENV["RUBY_GC_HEAP_GROWTH_FACTOR"]} --------\n" GET_PROCESS_MEM = GetProcessMem.new s = [] start = Time.now GC.compact 50_000_000.times do |i| # if 0 == i % 1_000_000 # print "[#{i/1_000_000}]" # # GC.start # end s << "abcdefabcdefabcdefabcdefabcdefabcdefab...
true
4d873682c4ffc712fa862458828dc9ed03e9d5fe
Ruby
pytong/algorithms
/binary_trees/iterative_inorder_traversal.rb
UTF-8
729
3.71875
4
[]
no_license
def inorder_traversal(root) # empty tree if !parent return end # prev = nil # next = nil curr = root while curr if !prev || prev.left == curr || prev.right == curr # at root or at child nodes if curr.left # has left nodes next = curr.left else puts curr.value ...
true
9f9d93c76d3e8637932bbd5d8bab1affc6f970a5
Ruby
theodi/content_api
/test/unit/fake_pagination_test.rb
UTF-8
785
2.578125
3
[]
no_license
require "test_helper" require "pagination" class FakePaginationTest < MiniTest::Spec include Pagination describe "FakePaginatedResultSet" do it "gives the appropriate response when given an array" do p = FakePaginatedResultSet.new([1, 2, 3, 4, 5]) assert_equal [1, 2, 3, 4, 5], p.results as...
true
43be18c22bc43f8b7290e8228e3b767b292d290d
Ruby
baezdiazm/parrot-ruby-onl01-seng-pt-030220
/parrot.rb
UTF-8
132
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# Create method `parrot` that outputs a given phrase and # returns the phrase def parrot(ph = "Squawk!") puts ph return ph end
true
e6b28f5fe5fc65c1a45121600db6c2246ed048fe
Ruby
anicholson44/dependencies
/logger.rb
UTF-8
336
3.109375
3
[]
no_license
class Logger def initialize(max_depth = nil, indent = 2) @max_depth = max_depth @log = [] @indent = indent end def log(string, depth = 0) log_string = "#{' ' * @indent}#{string}" unless @max_depth && depth > @max_depth @log << log_string puts log_string if log_string end def read ...
true
0d1f1f53e3be60a6477636a60994ddb8b477ea06
Ruby
icanprogram/fedoracoin-irc-bot
/plugins/hashrateformatter.helper.rb
UTF-8
297
2.9375
3
[]
no_license
module HashrateFormatter def format_hashrate hashrate prefixes = ["k", "M", "G", "T", "P", "E", "Z", "Y"] prefix = "" unit = "h/s" value = hashrate.to_f while value > 1000 value = value/1000 prefix = prefixes.shift end "#{value.round(2)} #{prefix}#{unit}" end end
true
e67f21bc3f3cdf0fc750a2f7a7aef5f4af6dd0ae
Ruby
Rocky-R/battleship_reborn
/classes/computerplayer.rb
UTF-8
712
3.53125
4
[]
no_license
class ComputerPlayer < Player def initialize super @name = "HAL 9000" end def ships board.ships end def name @name end def place_ships(lengths) lengths.each do |l| ship_placed = false until ship_placed == true do ship_placed = place_ship(l) end end ...
true
862004e688d65e8bef9a35786ee1b7546b62e2aa
Ruby
Wizcorp/NagiosForCouchbase
/lib/wizcorp/couchbase/connection.rb
UTF-8
2,827
2.828125
3
[ "MIT" ]
permissive
module Wizcorp module Couchbase # Class to establish connection and handle communication with # Couchbase server HTTP API. # # This is parent class for all others, they are inheric connection # setting from this class. # class Connection require 'net/http' require 'json' ...
true
1da0c47aea44f290303c6756cd0b4223bb822ae3
Ruby
HatAndBread/pleasant_news
/models/article.rb
UTF-8
848
3.140625
3
[]
no_license
require 'nokogiri' require 'open-uri' require_relative 'words_list' require_relative 'emoji' class Article @@id = 0 attr_accessor :url, :title, :body, :date, :emoji, :id def initialize(attributes = {}) @@id += 1 @id = @@id @url = attributes[:url] @title = attributes[:title] @body = attribut...
true
8c7a71e08fe513e97849b6359425466d0388b992
Ruby
dtvthethe/ruby_training
/varriable_practice.rb
UTF-8
1,224
4.25
4
[]
no_license
#Global variables =begin $global = 0 class C puts "in a class: #{$global}" def my_method puts "in a method: #{$global}" $global = $global + 1 $other_global = 3 end end C.new.my_method puts "at top-level, $global: #{$global}, $other_global: #{$other_global}" =end #Global variables =begin color = "Red" d...
true
1c26e5403db1b60163ab86025510a1433331f8b2
Ruby
fkazgithub/tech_ruby
/3.rb
UTF-8
175
3.4375
3
[]
no_license
fruits_box = ["apple","orange","cherry"] puts "何がでるかな?取り出したい要素の順番を入力してください" input = gets.to_i puts fruits_box[input-1]
true
6ea89fc9c345a765267596abf8332474d8861c05
Ruby
nmarley/rate-service
/rate.rb
UTF-8
2,464
2.5625
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
require 'sinatra/base' require 'sinatra/json' require 'sinatra/cross_origin' require 'json' require 'bigdecimal' require 'bigdecimal/util' require 'pp' require 'awesome_print' require 'byebug' require File.expand_path('config/application', __dir__) require 'rate_helpers' require 'rate_service' # TODO: class with all t...
true
a3e239258fb8c8d3447861698382e19d1d517d6c
Ruby
insoul/dooly
/lib/dooly/attachment/base.rb
UTF-8
2,854
2.5625
3
[ "MIT" ]
permissive
module Dooly module Attachment class Base < HashWithIndifferentAccess attr_accessor :body def add(k, value = nil, options = {}) if key?(k) warn_duplicated(k); return fetch(k) end if value store(k, value) if block_given? self.as_json_p...
true
7d583f55e92a3c41511aaa16f60ad03f4b28bd79
Ruby
ymagoon/scraper
/imdb_top_250.rb
UTF-8
2,447
3.0625
3
[]
no_license
require 'nokogiri' require 'rest-client' require 'csv' require 'pry' def scrape_data movies = [] puts "starting..." top_250_url = "https://www.imdb.com/chart/top" top_250_doc = Nokogiri::HTML(RestClient.get(top_250_url)) puts "finished getting Nokogiri doc..." cnt = 0 top_250_doc.search('.titleColumn a'...
true
3f8f66a453bbaef970e1af015419e80bf75b1edc
Ruby
hvenables/advent_of_code_2019
/day_1/day_1_part_1.rb
UTF-8
104
3.125
3
[]
no_license
input = File.read('./input1.txt').split("\n") result = input.sum { |i| (i.to_i / 3) - 2 } puts result
true
68358569c11509dcffb5fcf9450f0d884892a77e
Ruby
Virus-Hunter/Ruby
/lib/modules/events/sprits sprits.rb
UTF-8
2,064
2.78125
3
[ "MIT" ]
permissive
module Bot module DiscordEvents # Sprits Sprits # Punish ruby for being dum module SpritsSprits extend Discordrb::EventContainer message(contains: /💦 🐱|💦🐱|sprits sprits|Sprits Sprits|spritssprits|SpritsSprit|Sprits sprits/) do |event| event.respond ["https://my.mixtape.moe/jbisds.png", '_**HIS...
true
76488a09e3ea097f60bd6035beead8e4b5640f23
Ruby
jonisavo/MK-Starter-Kit
/ruby/scripts/tempdebug/tileset4.rb
UTF-8
1,810
2.578125
3
[]
no_license
# Creates a new tileset (normally loaded from a file) tileset = MKD::Tileset.new(4) tileset.name = "Water" tileset.graphic_name = "water" # 0 = impassable # 1 = passable down # 2 = passable left # 4 = passable right # 8 = passable up # 11 = passable down, left, up # etc. # 15 = passable all tileset.passabilities = [ ...
true
a7dc3473813f28e97ef930cd6602e7795768cdef
Ruby
MaxfieldLewin/checkers
/game_solver.rb
UTF-8
1,469
3.5
4
[]
no_license
require_relative 'board.rb' require_relative 'piece.rb' class GameSolver def initialize(board, color, depth=3) @board = board @color = color @depth = depth end def solve_n_moves_ahead(gen=0, board=@board) return {} if gen > @depth move_table = Hash.new { |h,k| h[k] = 0 } step_moves, ...
true
ff213fe96227b467636093e5f93b44814b8f2cdd
Ruby
micahmosley/ruby-enumerables-reverse-each-word-lab-atx01-seng-ft-071320
/reverse_each_word.rb
UTF-8
180
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def reverse_each_word(sentence) sentence_array=sentence.split(" ") sentence_array=sentence_array.collect do |word| word.reverse end sentence_array.join(" ") end
true
71dc80832ee53fc208b5fadcb65b7166d10ee779
Ruby
macournoyer/llvmruby
/test/test_basic.rb
UTF-8
9,689
2.53125
3
[ "MIT" ]
permissive
require 'test/unit' $:.unshift File.dirname(__FILE__) + "/../ext" require 'llvm' include LLVM class BasicTests < Test::Unit::TestCase def function_tester(expected) m = LLVM::Module.new("test_module") type = Type::function(MACHINE_WORD, []) f = m.get_or_insert_function("test", type) yield(f) Exec...
true
c7170b2285f2c2ec360cce70be1388c9c0d51e37
Ruby
CGTrader/traceparts
/lib/traceparts/part_details.rb
UTF-8
1,394
2.515625
3
[ "MIT" ]
permissive
module Traceparts class PartDetails attr_reader :title, :description, :long_description, :big_picture, :manufacturer_id, :manufacturer_name, :manufacturer_picture, :manufacturer_description, :manufacturer_emails, :manufacturer_websites, :manufacturer_address, :version def initi...
true
d92b06d6fbf256fa89bc577ab44970c2b3719014
Ruby
boldport/boldport-club-community
/bin/lib/post.rb
UTF-8
2,313
3.015625
3
[]
no_license
require "pathname" class Post attr_accessor :id, :created_at, :title, :date_ymd attr_accessor :source_url attr_accessor :author_name, :author_url attr_accessor :body attr_accessor :images attr_accessor :youtube_ids attr_accessor :twitter_id def initialize(title=nil, date_ymd=nil, id=nil, created_at=n...
true
5a0f05eb606bf466b21b5be43af1713b1e570cf0
Ruby
bittn/BVM
/gem/lib/bittn.rb
UTF-8
1,252
2.671875
3
[ "MIT" ]
permissive
require "bittn/version" require "parslet" module Bittn class BaseParser < Parslet::Parser end class Version < Gem::Version end class BaseLang attr_reader :name, :version, :kinds, :obj, :type, :finish def initialize @name = nil @version = nil @parser = nil @kinds = nil ...
true
04086e0d1c81cbc27883fde7e431d2e065fa0048
Ruby
MattLok/ruby_collection
/Euler/specpythag.rb
UTF-8
265
3.34375
3
[]
no_license
a =1 b = 2 cont = true while cont #(a < 500) while b < 500 c = 1000 - b -a if (a*a) + (b*b) == (c *c) puts "found #{a} + #{b} + #{c} = 1000!" cont = false end print '.' b += 1 end a += 1 b = (a +1) puts a end
true
becaba8d005ab4b8141b17ac4863687d58bb55a9
Ruby
jess-alejo/ruby
/spec/swap_and_join_strings_spec.rb
UTF-8
612
3.71875
4
[]
no_license
# frozen_string_literal: true # For every character in string a swap the casing of every occurrence of the # same character in string b def work_on_strings(string1, string2) [swap_letters(string1, string2), swap_letters(string2, string1)].join end def swap_letters(string1, string2) string1.chars.map { |c| string...
true