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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cd714e6b18b75f89072cd1467737551242bd5962 | Ruby | kc17/jgit | /lib/jgit.rb | UTF-8 | 5,327 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'jgit/common'
require 'jgit/group'
require 'jgit/desc'
require 'jgit/version'
require 'thor'
module Jgit
class Project < Thor
PROMPT_TASK = "key in project name:"
desc 'add <path> <name> [-g GROUP]', 'add new project'
method_option :group, :aliases => '-g', :desc => "group to ope... | true |
bfee0b547be314c9f7fe03f8d7df5340a2dbe3e9 | Ruby | caspian311/gosu-ball-game | /lib/enemy.rb | UTF-8 | 693 | 2.71875 | 3 | [] | no_license | require_relative './player'
class Enemy < Player
attr_reader :speed
OffscreenBuffer = 5
def initialize(initial_x, initial_y, ground, speed)
super(initial_x, initial_y, ground)
@speed = speed
end
def color
case speed
when 1
Gosu::Color::WHITE
when 2
Gosu::Color::GREEN
wh... | true |
eecad2a852d0612430672241d778b3333a0b5a21 | Ruby | bucknermr/algorithms | /hackerrank_problems/plus_minus.rb | UTF-8 | 585 | 4 | 4 | [] | no_license | # https://www.hackerrank.com/challenges/plus-minus/problem
#!/bin/ruby
def plusMinus(arr)
# Complete this function
pos_count = 0
neg_count = 0
zero_count = 0
arr.each do |num|
if num < 0
neg_count += 1
elsif num > 0
pos_count += 1
else
z... | true |
9c3e65251d9f65b6def194234ef47d069814382b | Ruby | rranelli/ci-scripts | /build-scripts/gitlab-notifiers/format-build-status-message.rb | UTF-8 | 1,040 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
# This script relies on the following environment variables being set:
# - failure_step # exported by build-scripts/build
#
# - build_url # exported by jenkins
# - build_display_name # exported by jenkins
# - job_name # exported by jenkins
# Build environme... | true |
16fc995263bcc3eb90cead001c488551f0fc768b | Ruby | ronstarling9/pg | /app/controllers/guess_confirmations_controller.rb | UTF-8 | 1,653 | 2.5625 | 3 | [] | no_license | class GuessConfirmationsController < ApplicationController
def new
@guess_confirmation = GuessConfirmation.new
@guess_confirmation.height = params[:height]
@guess_confirmation.weight = params[:weight]
@guess_confirmation.guess = params[:guess]
@guess_confirmation.algorithm = p... | true |
3c758ed9487603f800c7ee21cd57bdd85a4fc37c | Ruby | CharlieKenny/battleships | /spec/feature/feature_test_spec.rb | UTF-8 | 465 | 3.0625 | 3 | [] | no_license | require 'board'
require 'ship'
require 'player'
feature '2 players enter the game' do
scenario 'board setup with size' do
board = Board.new ('J')
expect(board.size).to eq 'J'
end
scenario 'player submits name' do
player1 = Player.new 'Rocco'
expect(player1.name).to eq 'Rocco'
end
end
# scenario 'I can ... | true |
748b3006caaa5f876e1b0fd52f53ce2c6d8d15b7 | Ruby | javierojeda94/daily-coding-problems | /spec/problem_1_spec.rb | UTF-8 | 1,120 | 3.03125 | 3 | [] | no_license | require 'problem_1'
RSpec.describe Problem1 do
context 'with naive solution' do
it 'should be true with [10, 15, 3, 7] and 17' do
numbers = [10, 15, 3, 7]
k = 17
expect(Problem1.solve(numbers, k)).to be true
end
it 'should be true with [1, 2, 3, 4, 5] and 8' do
numbers = [1, 2,... | true |
f5820d8c0179ba4c50c3e87393c9d824e34e9984 | Ruby | anshuj11/CTCI | /Ch1_array/move_zero.rb | UTF-8 | 659 | 4.15625 | 4 | [] | no_license | def manhattan(pt1, pt2)
(pt1[0]-pt2[0]).abs + (pt1[1]-pt2[1]).abs
end
def min_swaps(matrix)
count = 0
matrix.each_with_index do |row, i|
row.each_with_index do |cell, j|
# (i + 1) * row.length
correct_i = cell / row.length
correct_j = cell % row.length
# iterati... | true |
186e47a90f5bb22be58f543074bb5f6638b11507 | Ruby | Salvero/coderbyte_challenges | /ruby_exercises/first_factorial.rb | UTF-8 | 337 | 4.03125 | 4 | [] | no_license | # First Factorial
# Using the Ruby language, have the function FirstFactorial(num) take the num parameter being
# passed and return the factorial of it (ie. if num = 4, return (4 * 3 * 2 * 1)). For the test cases,
# the range will be between 1 and 18.
def FirstFactorial(num)
(1..num).reduce(:*) || 1
end
FirstFacto... | true |
1449d3f2cf4844762970537d3e5a93fdb67e7331 | Ruby | BLSQ/orbf-rules_engine | /lib/orbf/rules_engine/builders/spans/spans.rb | UTF-8 | 5,048 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Orbf
module RulesEngine
module Spans
def self.matching_span(name, rule_kind)
RulesEngine::Rule::Kinds.assert_valid(rule_kind)
SPANS.find do |span|
span.supports?(rule_kind) && span.frequencies(name).any?
end
end
class Span
... | true |
37a0a350efdf02a0a0dd67f274a9412cb615a299 | Ruby | ddd-ruby/hashcast | /lib/hashcast/casters/array_caster.rb | UTF-8 | 744 | 3.09375 | 3 | [
"MIT"
] | permissive | class HashCast::Casters::ArrayCaster
def self.cast(value, attr_name, options = {})
raise HashCast::Errors::CastingError, "should be an array" unless value.is_a?(Array)
return value unless options[:each]
cast_array_items(value, attr_name, options)
end
private
def self.cast_array_items(array, attr... | true |
f03798981599cc4d34b5e987e50620f72bb5b0be | Ruby | jacquelynoelle/hotel | /spec/reservation_spec.rb | UTF-8 | 1,772 | 3.0625 | 3 | [] | no_license | # Jacquelyn Cheng - Nodes
# Tests for reservation.rb
require 'date'
require_relative 'spec_helper.rb'
describe "Reservation" do
before do
@checkin_date = Date.parse("2019-02-01")
@checkout_date = Date.parse("2019-02-05")
end
let (:room1) {
Hotel::Room.new(1)
}
let (:res) {
Hotel::Reservat... | true |
54d8880583a58bde08cb7a9725aa44800716e3b8 | Ruby | James-Jones/Helpful-scripts | /lcm.rb | UTF-8 | 470 | 3.625 | 4 | [] | no_license | =begin
Given positive non-zero numbers find the Lowest Common Multiple.
=end
def gcm(a, b)
while(b!=0)
temp = b
b = a % b
a = temp
end
return a
end
def lcm2(a, b)
return a * b / gcm(a, b)
end
def lcm3(a, b, c)
return lcm2(a, lcm2(b, c))
end
if ARGV.length == 0
return
elsif ARGV.length == 1
puts ARGV[0]... | true |
14ce9849aa8cd343ea72865725cf7f6b6bbb87f7 | Ruby | wratterman/class_warmupd | /Warmups/Devpairingschedule/lib/pairing_mixer.rb | UTF-8 | 899 | 3.171875 | 3 | [] | no_license | class PairingMixer
attr_reader :paired_teams, :team_one, :team_two, :team_three, :team_four
def initialize
@paired_teams = []
@team_one = []
@team_two = []
@team_three = []
@team_four = []
end
def dev_list
["Alex", "Bernadette", "Charles", "Dana", "Eddie", "Fernando", "Gus", "Hiro"]
... | true |
4e7eaadbd2cbc081e0bdcffb7fc851209c287e79 | Ruby | nmacawile/tictactoe | /lib/launcher.rb | UTF-8 | 350 | 3.0625 | 3 | [
"MIT"
] | permissive | require "./tictactoe"
require "colorize"
print "Player 1, please enter your name: "
player1 = Tictactoe::Player.new(gets.chomp.colorize(:red), "X".colorize(:red))
print "Player 2, please enter your name: "
player2 = Tictactoe::Player.new(gets.chomp.colorize(:blue), "O".colorize(:blue), true)
game = Tictactoe::Board.n... | true |
ec1a702e1f8772dc4a17c5b5082c6cbc71e74ae4 | Ruby | VyacheslavSapsay/RoR-Ruby-Basics | /1_Lesson/90.rb | UTF-8 | 262 | 3.609375 | 4 | [] | no_license | #Дан целочисленный массив. Найти количество нечетных элементов.
numbers=[3,543,25,6,753,96,100,53,50]
new_list=[]
numbers.each do |numb|
if numb.odd?
new_list.push(numb)
end
end
puts(new_list.length)
| true |
920ba0de9005347ae953621d5f9e3c5e157b0f4f | Ruby | kennethkufluk/UglifyJS.rb | /lib/uglifyjs/ast_mangle.rb | UTF-8 | 3,345 | 2.640625 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive |
# /* -----[ mangle names ]----- */
require "uglifyjs/ast_walker"
require "uglifyjs/scope"
class Mangler
include Scope
include Util
def initialize(ast, options=nil)
@ast = ast
@w = ASTWalker.new(@ast)
@walk = @w.walk
@options = options || {}
@scope = nil
end
def getAST
return @w.w... | true |
3b5c42ef93c9bd2a1bb00ab9ebc6056504b427fd | Ruby | cmaher92/launch_school | /exercises/small_problems/medium_2/bubble_sort.rb | UTF-8 | 1,313 | 4.6875 | 5 | [] | no_license | # bubble sort
# medium 2, problem 9
# A bubble sort works by making multiple passes through an array
# on each pass, each pair of consecutive elements is compared
# if the first element is greater than the second, they are swapped
# repeated until no more swaps are made
# input: array
# output: array; sorted
# rules:... | true |
82ecf74cf657165f4e481201682e5be7d40267cb | Ruby | jhsu802701/generic_gem | /lib/generic_gem.rb | UTF-8 | 9,398 | 2.625 | 3 | [
"MIT"
] | permissive | require 'generic_gem/version'
require 'string_in_file'
require 'replace_quotes'
require 'line_containing'
#
module GenericGem
def self.create(gem_name)
puts '**********************'
puts 'Welcome to Generic Gem'
puts "GEM NAME: #{gem_name}"
ENV['DIR_MAIN'] = File.expand_path('../../', __FILE__)
... | true |
73765a34bd33b8367e58748e766c1fc0959dbbdf | Ruby | jcpny1/flatiron-store-project-v-000 | /app/models/cart.rb | UTF-8 | 671 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cart < ActiveRecord::Base
belongs_to :user
has_many :line_items
has_many :items, through: :line_items
def add_item(item_id)
line_item = self.line_items.find_or_initialize_by(item_id: item_id)
line_item.quantity += 1
# line_item.save
line_item
end
def checkout
self.line_items.each ... | true |
4a2190014c81a5765bf2d0db6336b206db26c9ec | Ruby | Rockster160/Games | /easy_yml_parser.rb | UTF-8 | 2,445 | 3.0625 | 3 | [] | no_license | require "/Users/rocco/code/games/tokenizer.rb"
# SurveyName
# Question1
# Answer1
# result: 1
# Answer2
# result: 2
# Question2
# Answer1
# result: 1
# Answer2
# result: 2
module EasyYmlParser
module_function
def parse(raw_data, indent=0)
return if (raw_data.nil? ||... | true |
a3fdd2445a84796b71fc07438773d9d65ab3ff17 | Ruby | SMERM/TR-2016-2017 | /A.A.-2016-2017/20170622/nota_melodia_lezione.rb | UTF-8 | 3,924 | 3.078125 | 3 | [
"Unlicense"
] | permissive | class Nota
attr_reader :at,:lgt,:vol,:ptch,:tmbr
def initialize(at,lgt,vol,ptch,tmbr)
@at = at
@lgt = lgt
@vol = vol
@ptch = ptch
@tmbr = tmbr
end
def et
self.at + self.lgt
end
def to_csound
"i%02d %8.4f %8.4f %+5.2f %8.4f" % [self.tmbr,self.at,self.lgt,self.vol,self.ptch]
... | true |
76bbb8341652608c32aa365aa5e70328a228bceb | Ruby | SamuelBoyce/reverse-each-word-001-prework-web | /reverse_each_word.rb | UTF-8 | 148 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word (string)
sentence_array = string.split
sentence_array.collect do |x|
x.reverse!
end
sentence_array.join(" ")
end | true |
4253cdcaa27cccc46117fe7632e1dadb48ba800c | Ruby | acasasayas/IronHack_exercises | /PreWork/FizzBuzz3.rb | UTF-8 | 311 | 3.40625 | 3 | [] | no_license | number = 1
output = ""
while number <= 100
if number / 10 == 1 || number / 100 == 1 || number == 1
output <<"Bang!"
end
if number % 3 == 0
output << "Fizz!"
end
if number % 5 == 0
output << "Buzz!"
end
if output == ""
output = "#{number}"
end
puts output
output = ""
number = number + 1
end | true |
822693f6de86eed9fe8e899c17820d61fe85bcca | Ruby | thomas-mcdonald/qa | /app/helpers/counts_helper.rb | UTF-8 | 1,424 | 2.765625 | 3 | [
"MIT"
] | permissive | module CountsHelper
def mini_count(count, string, opts = {})
plural = string.pluralize(opts[:with] || count)
%(<div class="mini-count"><div class="num">#{count}</div><div>#{plural}</div></div>).html_safe
end
def views_formatted(count)
units = { thousand: 'k', million: 'm', billion: 'b' }
options ... | true |
8ad10e0720e72f11a10d28e4501d12bf9ab51806 | Ruby | architapatelis/sep-assignments | /02-algorithms/03-sorting/benchmark.rb | UTF-8 | 402 | 3.34375 | 3 | [] | no_license |
require 'benchmark'
require_relative 'bucket_sort'
require_relative 'heap_sort'
require_relative 'quick_sort'
numbers = (1..50).to_a.shuffle!
puts "Quick Sort"
puts Benchmark.measure {
quick_sort(numbers)
}
numbers.shuffle!
puts "Heap Sort"
puts Benchmark.measure {
heap_sort(numbers)
}
numbers.shuffle!
puts... | true |
c645bbe9a99d0a45aa9c6c13c06183247c341126 | Ruby | unagiootoro/RGSS_MZ | /rgss/lib/rpg/Weather.rb | UTF-8 | 3,119 | 3.09375 | 3 | [] | no_license | module RPG
class Weather
include MarshalConvertor
def initialize(viewport = nil)
@type = 0
@max = 0
@ox = 0
@oy = 0
color1 = Color.new(255, 255, 255, 255)
color2 = Color.new(255, 255, 255, 128)
@rain_bitmap = Bitmap.new(7, 56)
for i in 0..6
... | true |
b8da5f3cf5ca730df040ee53a37e6f116b1fe9e4 | Ruby | LuisAscencio/ruby-objects-has-many-through-lab-nyc-web-071519 | /lib/doctor.rb | UTF-8 | 621 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name
@@all=[]
def initialize(name)
@name = name
@@all<<self
end
#class methods
def self.all
@@all
end
#::::::::::::::::::::::::
def new_appointment(date, patient)
Appointment.new(date, patient, self)... | true |
a4753a458562fc30cfa237b2aa473cc61ba6bdc4 | Ruby | Jeff-Adler/ruby-oo-practice-relationships-domains-nyc01-seng-ft-062220 | /app/models/airbnb/listing.rb | UTF-8 | 1,607 | 4 | 4 | [] | no_license | # #### Listing
# - #guests
# - returns an array of all guests who have stayed at a listing
# - #trips
# - returns an array of all trips at a listing
# - #trip_count
# - returns the number of trips that have been taken to that listing
# - .all
# - returns an array of all listings
# - .find_all_by_city(city)
# ... | true |
f2d8388e1f369d9ccd5c4ad9a683de62ad6ff9f1 | Ruby | ddd-ruby/api_view | /lib/api_view/engine.rb | UTF-8 | 3,426 | 2.75 | 3 | [
"MIT"
] | permissive | require "date"
module ApiView
class Engine
# Classes which require no further conversion
BASIC_TYPES = [
String, Integer, Bignum, Float,
TrueClass, FalseClass,
Time, Date, DateTime
]
BASIC_TYPES_LOOKUP = BASIC_TYPES.to_set
DEFAULT_FORMAT = 'json'.freeze
class << self
... | true |
1706ea1b136c058af8a179f9677284cbef7cc1ad | Ruby | mixelpixel/LearnRubyInOneVideo | /22strings_here_doc.rb | UTF-8 | 5,374 | 3.96875 | 4 | [] | no_license | # https://youtu.be/Dji9ALCgfpM
# http://www.newthinktank.com/2015/02/ruby-programming-tutorial/
# Recommended Ruby Book: The Well-Grounded Rubyist 2nd Edition by David A. Black
# Sample chapter: https://manning-content.s3.amazonaws.com/download/3/93fa755-6d88-4296-9d1c-3e40cf96507c/TWGR2E_CH11.pdf
=begin
Ruby is a dyna... | true |
0755965fce970b7de1abd2436480705596bc202b | Ruby | blahutka/testapp | /app/workers/eat.rb | UTF-8 | 131 | 2.8125 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
class Eat
@queue = :food
def self.perform(food)
puts "Ate #{food}!" + " #{Time.now}"
end
end
| true |
1e7f1e734b250d5e4f1cfa282a77467c644a1c3e | Ruby | dvitt90/ttt-3-display_board-example-q-000 | /lib/display_board.rb | UTF-8 | 322 | 3.171875 | 3 | [] | no_license | # Define a method display_board that prints a 3x3 Tic Tac Toe Board
def display_board
var1 = [" ", " ", " ", " ", " ", " ", " ", " ", " "];
print " #{var1[0]} | #{var1[1]} | #{var1[2]} \n-----------\n #{var1[3]} | #{var1[4]} | #{var1[5]} \n-----------\n #{var1[6]} | #{var1[7]} | #{var1[8]} \n";
end
display_board(... | true |
ea065e3797ea3c51130e5d68dbbbadab93677439 | Ruby | aparra/playing-ruby | /estrutura_controle/exceptions.rb | UTF-8 | 164 | 3.578125 | 4 | [] | no_license | puts "Digite um numero"
numero = gets.to_i
begin
resultado = 100/numero
rescue
puts "Numero digitado invalido"
exit
end
puts "100/#{numero} eh #{resultado}" | true |
b4c0ea4fb1523f8b46df82e8382dde84bb035fe0 | Ruby | ivankocienski/software-design-patterns | /src/memento.rb | UTF-8 | 1,079 | 3.625 | 4 | [] | no_license | # Memento
class Board
# the memento class
class Snapshot
attr_reader :saved_grid
def initialize(source)
@saved_grid = source.grid.dup
end
end
# the primary class
attr_reader :grid
def initialize
@grid = ['-'] * 9
end
def move(x, y, piece)
@grid[(y * 3) + x] = piece
end
... | true |
07ca0e74137ced4c7568e3649ea047293621a86d | Ruby | AlanDust/Cantina-Coding-Challenge | /recursion.rb | UTF-8 | 1,610 | 3.109375 | 3 | [] | no_license | require 'httparty'
require 'byebug'
require 'hashie'
class Recursion
def initialize
end
def run
url = "https://raw.githubusercontent.com/jdolan/quetoo/master/src/cgame/default/ui/settings/SystemViewController.json"
data = HTTParty.get(url)
parsed_data = HTTParty.get(url).parsed_response
json = ... | true |
0863a04dd32811008fc089fbd2adb229c6ac05dc | Ruby | klieber/saas-class | /hw1/spec/part2_spec.rb | UTF-8 | 2,610 | 2.984375 | 3 | [] | no_license | $LOAD_PATH << '../lib'
require 'part2'
describe "#rps_game_winner" do
it "returns Armando for [ [ \"Armando\", \"R\" ], [ \"Dave\", \"R\" ] ]" do
game = [ [ "Armando", "R" ], [ "Dave", "R" ] ]
rps_game_winner(game).should eq([ "Armando", "R" ])
end
it "returns Dave for [ [ \"Armando\", \"R\" ], [ \"Dave\... | true |
86c50ca1256398bf9a73e38459bfaf5bf3140f59 | Ruby | kt3k/ruby-bmp | /lib/bump/domain/version_number_factory.rb | UTF-8 | 498 | 2.984375 | 3 | [
"MIT"
] | permissive | module Bump
# The factory class for the version number
class VersionNumberFactory
# Regexp for version expression
VERSION_REGEXP = /^(\d+).(\d+).(\d+)(-(\S*))?$/
# Creates the version number object from the string
#
# @param [String] version_string
# @return [Bump::VersionNumber]
def se... | true |
b5749a52e9132b69e256ecef704d4238919b2669 | Ruby | justinweiss/error_stalker | /lib/error_stalker/backend/in_memory.rb | UTF-8 | 658 | 2.78125 | 3 | [
"MIT"
] | permissive | # Provides an in-memory backend that stores all exception reports in
# an array. This is mostly useful for tests, and probably shouldn't be
# used in real code.
class ErrorStalker::Backend::InMemory < ErrorStalker::Backend::Base
# A list of exceptions stored in this backend.
attr_reader :exceptions
# Create a n... | true |
e606215c9a38dc71cdcd36f1cfa50b11ca46f3e8 | Ruby | marcandre/backports | /lib/backports/1.8.7/enumerable/count.rb | UTF-8 | 380 | 2.640625 | 3 | [
"MIT"
] | permissive | unless Enumerable.method_defined? :count
require 'backports/tools/arguments'
module Enumerable
def count(item = Backports::Undefined)
seq = 0
if item != Backports::Undefined
each { |o| seq += 1 if item == o }
elsif block_given?
each { |o| seq += 1 if yield(o) }
else
... | true |
04ee828448f6198e228bccfc250d2584b44b436d | Ruby | mrkamel/search_flip | /lib/search_flip/aws_sigv4_plugin.rb | UTF-8 | 1,292 | 2.53125 | 3 | [
"MIT"
] | permissive | require "aws-sdk-core"
require "uri"
module SearchFlip
# The SearchFlip::AwsSigV4Plugin is a plugin for the SearchFlip::HTTPClient
# to be used with AWS Elasticsearch to sign requests, i.e. add signed
# headers, before sending the request to Elasticsearch.
#
# @example
# MyConnection = SearchFlip::Connec... | true |
3997347e79ca968bd3b175e3b53083a7e13eacda | Ruby | openjournals/buffy | /app/lib/paper_file.rb | UTF-8 | 1,882 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'bibtex'
class PaperFile
attr_accessor :paper_path
attr_accessor :bibtex_entries
attr_accessor :bibtex_error
def initialize(path=nil)
@paper_path = path
@bibtex_error = "No paper file path" if @paper_path.nil?
end
def bib
return @bib unless @bib.nil?
parsed_bib = BibTeX.open(bibt... | true |
1ada8b49ba8571e3f5ef3dba28677ef933179df9 | Ruby | jmalik981/oo-kickstarter-online-web-ft-120919 | /lib/backer.rb | UTF-8 | 224 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Backer
attr_reader :name, :backed_projects
def initalize(name)
@name=name
@backed_projects =[]
end
def backed_project(project)
backed_project << project
project.backes << self
end
end | true |
95df33ea037af0039896e8a55b3a66daf670b860 | Ruby | sandalaphon/Karaoke | /specs/song_spec.rb | UTF-8 | 335 | 2.703125 | 3 | [] | no_license | require('minitest/autorun')
require_relative('../song.rb')
require('minitest/rg')
class Test_Song < MiniTest::Test
def setup
@song1 = Song.new("Moonriver","Audrey Hepburn", 1977)
@song2 = Song.new("My Way", "Frank Sinatra", 1974)
end
def test_get_song_name
expected="Moonriver"
actual=@song1.title
assert_equ... | true |
095b256852bfe4fe0e8a676fab81f23beb06aae1 | Ruby | Tumbles/magic-search-engine | /deck_indexer/lib/deck_indexer.rb | UTF-8 | 4,729 | 2.625 | 3 | [
"MIT"
] | permissive | require "json"
require "pathname"
require "date"
class DeckIndexer
def initialize(card_index_json, decks_json, save_path)
main_index = JSON.parse(Pathname(card_index_json).read)
@sets = main_index["sets"]
@cards = main_index["cards"]
@decks = JSON.parse(Pathname(decks_json).read)
@save_path = Pat... | true |
4147144e1477d105f8ac5c30294ff0f37087fb65 | Ruby | Arcath/YAIB | /lib/yaib/message.rb | UTF-8 | 743 | 2.78125 | 3 | [] | no_license | module YAIB
class Message
attr_reader :message, :user, :channel
def initialize(rawmsg, bot)
@message, rawchan, rawuser = parse(rawmsg)
if rawchan == bot.config.nick then
@channel = bot.return_user rawuser, rawuser
@user = @channel
... | true |
8427fc94f37ab6640fe2f40f3ef0cfcfbc5f2210 | Ruby | MushroomObserver/mushroom-observer | /app/classes/pattern_search.rb | UTF-8 | 1,085 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
#
# = PatternSearch
#
# == Usage
#
# search = PatternSearch::Observation.new(string)
# unless search.errors.any?
# render_results(search.query.results)
# else
# render_errors(search.errors)
# end
#
# == Description
#
# Accepts strings which are made up of a list ... | true |
405de77248ea11c66a5db39d5d333af9f8a16a02 | Ruby | giano/FaceR | /lib/linker.rb | UTF-8 | 1,561 | 2.71875 | 3 | [] | no_license | require "net/http"
require "net/http/post/multipart"
require 'mime/types'
require "uri"
require "json"
module Facer
# This class hold the main linkage to face.com
# acting as a gateway to subclasses
class Linker
# The main uri to face.com api.
FaceComURI="http://api.face.com/"
attr_reader :accou... | true |
d98ac9a17327ad62408eeeedc01fc415482ace4f | Ruby | motaHack/project100knock | /projectEuler/022.rb | UTF-8 | 381 | 2.84375 | 3 | [] | no_license | start_time = Time.now
str = nil
names = []
score = 0
i = 1
texts = File.open("names.txt","r") do |file|
file.each_line do |line|
str = line
end
end
str = str.delete("\"").delete("\n")
names = str.split(",")
names = names.sort
p names
names.each do |name|
name.each_char do |chr|
score += (chr.ord - 64)... | true |
defac240f62440bc8f9debc9279e1da2b2013dc4 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/src/1653.rb | UTF-8 | 159 | 2.734375 | 3 | [] | no_license | def compute(strand1, strand2)
diff = 0
arr = strand1.split("").zip(strand2.split(""))
arr.each { |x| diff += 1 unless x[0] == x[1] }
diff
end | true |
e659f32cee1a02c7153f6b7b5f818eae9cac6067 | Ruby | vicramon/vimgenius | /db/seeds/cursor-movements.rb | UTF-8 | 1,096 | 2.625 | 3 | [] | no_license | @lesson = Fabricate(:lesson,
name: 'Vim Motion',
summary: %q[
This lesson covers the basic Vim motions.
],
directions: %q[
This lesson will test your knowledge of Vim motions.
],
done_message: %q[
You did it! You are one more step on yo... | true |
b40f9c661e3c82d7f78af06535588fa26dc13f4f | Ruby | garrinmf/eulerproject | /ruby/problem4.rb | UTF-8 | 219 | 3.1875 | 3 | [] | no_license | ##
#
# Euler Problem 4
#
##
palin = 0
999.downto(1) do |x|
999.downto(1) do |y|
tmp = x*y;
if (tmp.to_s == tmp.to_s.reverse)
if tmp > palin
palin = tmp
end
end
end
end
puts palin
| true |
3109d13da6b048670eadf53ae4e537e7d290fd9e | Ruby | axhixh/Exercism | /ruby/rna-transcription/rna_transcription.rb | UTF-8 | 374 | 2.734375 | 3 | [
"MIT"
] | permissive | class Complement
def self.of_dna(dna)
rna = ""
dna.each_char do |c|
case c
when 'G' then rna += 'C'
when 'C' then rna += 'G'
when 'T' then rna += 'A'
when 'A' then rna += 'U'
else return ''
end
end
rn... | true |
5b3289b0395925334716b894c9c2131c129bf947 | Ruby | mopuriiswaryalakshmi/Ruby_Programs | /scrambles_str1_rkqodlw_str2_world_return_true.rb | UTF-8 | 614 | 4.0625 | 4 | [] | no_license | =begin
str1 = 'rkqodlw'
str2 = 'world'
s1=str1.split('')
s2=str2.split('')
puts "#{s1}"
puts "#{s2}"
s1.each do |single1|
s2.each do |single2|
if single1 == single2
puts "True"
else
puts "False"
end
end
end
=end
#require 'pry'
def scramble(str1, str2)
flag = []
str2.each do |letter|
(str2.coun... | true |
c05ec59d5f37f95bb40ecb2a713318403fa64a89 | Ruby | playtell/playtell-server | /app/models/tictactoespace.rb | UTF-8 | 836 | 2.796875 | 3 | [] | no_license | class Tictactoespace < ActiveRecord::Base
belongs_to :tictactoeboard
attr_accessible :friend_id, :available, :coordinates
def set_space(friend_id)
self.friend_id = friend_id
if !self.available
return false
end
self.available = false
self.save
return true
end
def is_first_row #rails truncates leadi... | true |
7a2279058d9274d9554f75208c458994ee76dbd7 | Ruby | jfinkhaeuser/unobtainium | /lib/unobtainium/driver.rb | UTF-8 | 9,372 | 2.828125 | 3 | [
"MITNFA"
] | permissive | # coding: utf-8
#
# unobtainium
# https://github.com/jfinkhaeuser/unobtainium
#
# Copyright (c) 2016-2017 Jens Finkhaeuser and other unobtainium contributors.
# All rights reserved.
#
module Unobtainium
##
# Creating a Driver instance creates either an Appium or Selenium driver
# depending on the arguments, and ... | true |
dcad6fb7b0a9541e86d6fd934e3e30567e9bef07 | Ruby | LWRGitHub/code_the_dream | /divisible.rb | UTF-8 | 216 | 3.640625 | 4 | [] | no_license | def divisible()
num = 1
arr = []
while num < 100
if num % 2 == 0 || num % 3 == 0 || num % 5 == 0
arr.push(num)
end
num += 1
end
return arr
end
puts divisible() | true |
da3a174dcf79bceea601357b2e7bfb12f006d70d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/0c6a2e5f94a14bb189dd0aa971ab75ed.rb | UTF-8 | 233 | 3.3125 | 3 | [] | no_license | # Gigasecond Calculator
# Demannu 9/29/2014
class Gigasecond
def self.from(birthday)
# For semantics I'll do the math on converting a gigasecond to days
gsDays = ((10**9/60)/60)/24
gs = birthday + gsDays
end
end
| true |
b1a51613d365a3a0b8e019d94e49dad220c6eeb9 | Ruby | paolabaccaro/cocktail_mania | /desconsiderar/tip_calculator_ok.rb | UTF-8 | 780 | 3.78125 | 4 | [] | no_license | def first
puts "How much is the bill?"
bill = gets.chomp.to_f
if false
first
else true
def second
puts "How much much would you like to tip?"
puts "Options: 10%, 15% or 20%?"
tip_percent = gets.chomp.to_f
if false
second
else true
def third
puts "How many people are a... | true |
83a2409724693cb06ffd390629f285c2debd8588 | Ruby | YuusakuHayashi/ruby_practice | /lesson14.rb | UTF-8 | 227 | 3.6875 | 4 | [] | no_license | # case
#
puts "signal? just now"
signal = gets
#p signal
printf("current signal is %s\n", signal.chomp)
case signal
when "red\n"
puts "stop"
when "green\n"
puts "go"
when "yellow\n"
puts "caution"
else
puts "wrong"
end
| true |
881312ebb4cfa6d3b1bcb6d448ea8dfbaf33e033 | Ruby | shubha-rajan/array_intersection | /lib/array_intersection.rb | UTF-8 | 898 | 3.953125 | 4 | [] | no_license | # Returns a new array to that contains elements in the intersection of the two input arrays
# Time complexity: O(n + m) where n is the length of array1 and m is the length of array 2 because you would have to iterate through the entire first array to build the hash table, and the entire second array to check if values ... | true |
b0cb5c3c1278d8b9d8444e04f8585d92fb370d5b | Ruby | borcun/free | /ruby/string/string.rb | UTF-8 | 171 | 3.484375 | 3 | [] | no_license | #!/usr/bin/ruby -w
# #{expression} calculates result and return it into string
puts "The result #{10*5*7}";
# downcase
str = String.new("HELLO WORLD")
puts str.downcase
| true |
cb523d2f07c8f28cad315525ba9e13a68ccaa6f3 | Ruby | Al-Qallaf/Storma | /hash.rb | UTF-8 | 504 | 2.96875 | 3 | [] | no_license |
H = Hash["a" => 100, "b" =>200]
h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
typeTable = Hash["VARCHAR" => ":string", "TEXT" => ":text", "INT" => ":integer", "FLOAT"=> ":float",
"DECIMAL" => ":decimal","DATETIME" => ":datetime", "TIMESTAMP" => ":timestamp",
"TIME" => ":time", "DATE" => ":date", "BINA... | true |
b08db8d106b6ba4452a7490f8c7d9a9210c0c58b | Ruby | taroooyan/Atcoder-solved | /ABC/012/b.rb | UTF-8 | 89 | 2.5625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'time'
n = gets.to_i
puts Time.at(n).utc.strftime("%X")
| true |
8918c6654ae3c06ddd2ab4ec0c11fc726eea2a8f | Ruby | mkiselyow/translate_it_to_I18n_readable_format | /lib/file_transformer.rb | UTF-8 | 1,081 | 3.109375 | 3 | [] | no_license | require 'yaml/store'
class FileTransformer
def self.transform(file_path)
file = File.open(file_path, 'r')
lines = file.read.to_s.split("\n")
answer = []
lines.map do |line|
value = line.split(': ')[1]
key = line.split(': ')[0].gsub(/'/, '')
keys_array = key.split('.')
result =... | true |
f5216b1dc04da3a1e0d33e951190892180b06f7d | Ruby | cameronfarina/app-academy-projects | /software-engineering-foundations/Uploadable Exercises/cameron_farina_blocks_project/lib/part_2.rb | UTF-8 | 387 | 3.03125 | 3 | [] | no_license | require "byebug"
def all_words_capitalized?(words)
words.all? { |word| word.capitalize == word }
end
def no_valid_url?(urls)
endings = ['.com', '.net', '.io', '.org']
urls.none? { |url| endings.any? { |ending| url.end_with?(ending) } }
end
def any_passing_students?(students)
students.any? do |hash|
... | true |
4f5af60c173764d8555324efc039320163f027d7 | Ruby | christhede/LaunchSchool | /130_RubyFoundations/grade_school.rb | UTF-8 | 577 | 3.9375 | 4 | [] | no_license | # store students names, along with what grade they are in.
# add students to the school along with their grade.
class School
attr_reader :school
def initialize
@school = {}
end
def add(name, grade)
@school[grade].nil? ? @school[grade] = [name] : @school[grade] << name
end
def grade(grade)
... | true |
93b2a4af269953b03991f773ee981814bf6f7499 | Ruby | liamseanbrady/tealeaf-course-one | /Lesson1/Practice/variable_scope.rb | UTF-8 | 428 | 3.609375 | 4 | [] | no_license | require "pry"
local_var = "Hello, world!"
array = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]
def change_local_var(outer_var)
outer_var.clear
end
def inner_scope
inner_var = "I am an inner var"
end
array.each do |arr|
arr.each do |num|
p arr
p num
end
p arr
# p num
end
# Can acces... | true |
19b993cd54004f311dd7b9841ad2da3319a415c8 | Ruby | bettinson/markov_midi | /midi.rb | UTF-8 | 2,232 | 3.0625 | 3 | [] | no_license | require 'midilib'
require 'midilib/io/seqreader'
require 'midilib/sequence'
require 'midilib/consts'
require 'pp'
include MIDI
# Create a new, empty sequence.
seq = Sequence.new()
# Read the contents of a MIDI file into the sequence.
File.open('More Interesting Melody.mid', 'rb') { | file | seq.read(file) }
events ... | true |
47f0ce9dac18e6dc239a5e8156eaa93cb4b9e7cb | Ruby | CarlosAndres22/IronHack-1 | /BootCamp/Week1/Day2/movie_exercise/movieapp.rb | UTF-8 | 607 | 2.90625 | 3 | [] | no_license | require_relative("lib/movie.rb")
require_relative("lib/moviechart.rb")
godfather = Movie.new("Godfather", 10)
diehard = Movie.new("DieHard", 8)
ghostbusters = Movie.new("Ghostbusters", 9)
homealone = Movie.new("Homealone", 6)
startrek = Movie.new("StarTrek", 5)
nightofthedead = Movie.new("Night of the living dead", 3)... | true |
bef7012b160eefe405bacb93bd84195b5e901ddb | Ruby | etellezp/real_madrid-cli-app | /lib/real_madrid/cli.rb | UTF-8 | 754 | 3.1875 | 3 | [] | no_license | class RealMadrid::CLI
def initialize
puts "Welcome to Real Madrid Football Squad"
a = Scrape.new
@squad = a.scrape
end
def call
input = nil
while input != "exit"
puts "What would you like to do. Type 'list' to show the players or 'exit' to quit"
input = gets.strip
case inp... | true |
228bf21ed8c934f9e77e9e0b424fae104d9725c7 | Ruby | wengkhing/flashcards | /app/controllers/rounds.rb | UTF-8 | 1,023 | 2.515625 | 3 | [] | no_license | get '/new/round/:id' do
deck = Deck.find(params[:id])
p deck
user = User.find(session[:user_id])
round = Round.create(user: user, deck: deck)
redirect to ("/new/round/#{round.id}/guess/0")
end
get '/new/round/:id/guess/:g_id' do
unless params[:g_id].to_i == 0
g = Guess.find(params[:g_id])
@correctn... | true |
ef07d991fe8ff5d8b0985d3965dbd72c26f4a5f4 | Ruby | RPCIII/CodeWars | /Codewars/Ruby/8kyu/Number_of_People_on_the_Bus.rb | UTF-8 | 122 | 3.53125 | 4 | [] | no_license | def number(bus_stops)
bus_stops = bus_stops.transpose
return bus_stops[0].inject(:+) - bus_stops[1].inject(:+)
end | true |
4b039b775fd6e4ab11cc97bf32501d49b6821ce7 | Ruby | mjosephmiller/chris_pine_challenges | /Array_Challenge_07.rb | UTF-8 | 426 | 4.09375 | 4 | [] | no_license | #Let's write a program which asks us to type in as many words
#as we want (one word per line, continuing until we just press Enter
# on an empty line), and which then repeats the words back to us in
# alphabetical order. OK?
puts 'type in as many words as you want, one per line. Double tap
enter when you\'re done'
arr... | true |
7efd1fee40ccbba9bc8ea183b77d5c5b35ffced0 | Ruby | cider-load-test/pic-a-day | /spec/helpers/application_helper_spec.rb | UTF-8 | 2,265 | 2.84375 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../spec_helper'
describe ApplicationHelper, "display_instructions" do
before do
@default = "Take one picture of yourself each day, every day - like #{link_to "this", "http://youtube.com/watch?v=6B26asyGKDo"}."
@come_back = "Come back tomorrow, and take another picture of yo... | true |
60ca0587355f650d459e9b8e1a4fd7db0fceacaf | Ruby | manchester-tech-events/techevents-nw | /gems/ruby/2.2.0/gems/faraday-0.9.1/test/parameters_test.rb | UTF-8 | 1,904 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path("../helper", __FILE__)
class TestParameters < Faraday::TestCase
# emulates ActiveSupport::SafeBuffer#gsub
FakeSafeBuffer = Struct.new(:string) do
def to_s() self end
def gsub(regex)
string.gsub(regex) {
match, = $&, '' =~ /a/
yield(match)
}
end
end... | true |
dd424b2b406dc856aeed7aa2c6c935d015fbd26b | Ruby | Tharnid/DJonesRuby | /methods.rb | UTF-8 | 429 | 4.40625 | 4 | [] | no_license | # Intro Methods
# A way of setting aside some code for future use
# define methods first
def hello
puts "Hello Dude!!!"
puts "Hellod Douchebag!!!"
end
# invoking the method hehe
hello
def count
10.times do |number|
puts number
end
end
# invoking count method
count
def greeting ( first_name )
puts "H... | true |
09a4a11749f99b5d6452ece9e222f1a45d6b63c3 | Ruby | philwebalbert/music_library | /app/models/cart.rb | UTF-8 | 720 | 3.390625 | 3 | [] | no_license | class Cart
attr_reader :items
attr_reader :total_price
def initialize
empty_all_items
end
def empty_all_items
@items = []
@total_price = 0.0
end
def add_album( album )
existing_item = @items.find {|item| item.album.id == album.id}
if existing_item
existing_item.quantit... | true |
5c5dafd3a723466b2dd1cfb227561ddf940566b1 | Ruby | deeckowy/II-UWr | /ProgramowanieObiektowe/lista8/zadanie2/ImBw.rb | UTF-8 | 985 | 3.640625 | 4 | [] | no_license | class ImBW
attr_accessor :map
def initialize(h,w)
@H=h
@W=w
@map=Array.new
end
def randomize()
k=0
t1=Random.new
while(k<@H)
t=Array.new
i=0
while (i<@W)
t<<t1.rand(0..1)
i+=1
... | true |
dad871019b10d27ffd9ba42b467a6b275ab13fe1 | Ruby | jdee/react_native_util | /lib/react_native_util/cli.rb | UTF-8 | 2,909 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'commander'
require_relative 'converter'
module ReactNativeUtil
class CLI
include Commander::Methods
include Util
def run
program :name, SUMMARY
program :version, VERSION
program :description, <<DESC
[Work in progress] Converts a project created with <%= color 'react-native ini... | true |
3cafe093afc191fac1824a1b0ee275b9e5825441 | Ruby | thisdata/hyperloglog-redis | /lib/time_series_counter.rb | UTF-8 | 3,778 | 3.140625 | 3 | [
"MIT"
] | permissive | module HyperLogLog
class TimeSeriesCounter
include Algorithm
# This is an implementation of HyperLogLog that allows for querying counts
# within time ranges of the form (t, current_time] with second-level
# granularity. The standard implementation of HyperLogLog stores the max
# number of leading... | true |
3cf6397d096d70c29018f82950fa36272c889d21 | Ruby | irontoby/git2rally | /plugin/ralkup.rb | UTF-8 | 6,671 | 2.890625 | 3 | [] | no_license | # Copyright 2001-2013 Rally Software Development Corp. All Rights Reserved.
##################################################################################################
#
# Plugin module for VCS connector to perform user name mappings.
# Contains a class with logic to perform Rally user lookups given some ident... | true |
0b11bdc8f02f68f5a51630f0c61263e78c3f56e9 | Ruby | Nicholas-Maxwell/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 449 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(language)
i = 0
collection = ["RUBY", "JAVASCRIPT", "PYTHON", "OBJECTIVE-C"]
while i < language.length #Iterating over collection using 'WHILE'
yield(language[i]) #---> Yielding the correct element (language)
i += 1
end
collection #---> returning new collection
end
#def my_collect(languag... | true |
0b743897c802e8f67a919eac33b9cb11ec29eecd | Ruby | shadabahmed/leetcode-problems | /0923-3sum-with-multiplicity.rb | UTF-8 | 1,714 | 3.625 | 4 | [] | no_license | # @param {Integer[]} a
# @param {Integer} target
# @return {Integer}
def three_sum_multi(a, target)
tuples = 0
a.each_with_index do |num, idx|
tuples += two_sum_count(a, idx + 1, target - num)
end
tuples
end
def two_sum(a, idx, target)
count = 0
last = a.length - 1
while idx < last
sum = a[id... | true |
3f0129752d405d90efdac10e200fba8117abdc15 | Ruby | calicoder/tweetit | /app/models/twitter.rb | UTF-8 | 1,759 | 2.96875 | 3 | [] | no_license | require "twitter"
require "awesome_print"
class TweetIt
CONSUMER_KEY = "v0Qlzb01LQBaxEF3WDCbPQ"
CONSUMER_SECRET = "Bhwg1KGyPYpii24Bwv9bUzZeYJGeEO8mHmeniR7w"
def initialize
@twitter = Twitter::Client.new(
:consumer_key => CONSUMER_KEY,
:consumer_secret => CONSUMER_SECRET,
:oauth_token... | true |
1fb735af0a6fb729b8fac024fb0f67d80db72a5c | Ruby | vimtaku/scheme_ruby | /main.rb | UTF-8 | 1,057 | 3.1875 | 3 | [] | no_license |
require './repl.rb'
require './interpreter.rb'
# exp = [[:lambda, [:x, :y], [:+, :x, :y]], 3, 2]
# p _eval(exp, $global_env)
# exp = [:let, [[:x, 3]],
# [:let, [[:fun, [:lambda, [:y], [:+, :x, :y]]]],
# [:+, [:fun, 1], [:fun, 2]]]]
# p _eval(exp, $global_env)
# exp = [:letrec,
# [[:fact,
# [:lambda, [:n],
... | true |
2ea0c857073853a1b27a32bf602e4e3d3c0f744a | Ruby | Fukayanegi/CodeIQ | /satakemura/the_strongest_deck.rb | UTF-8 | 1,289 | 3.21875 | 3 | [
"MIT"
] | permissive | # Arrayを拡張
class Array
def count
k = Hash.new(0)
self.each{|x| k[x] += 1 }
return k
end
end
cards = STDIN.gets.chomp.to_i
costs = STDIN.gets.chomp.to_i
status = {}
while line = STDIN.gets do
cost, score = line.chomp.split(" ").map{|v| v.to_i}
status[cost] = [] if !status.include? cost
status[cost... | true |
1bc8eee1e36832f6bb9fed53474546c4a2f03220 | Ruby | PeterTucker/Udemy-Ruby-Programming | /calcMethods.rb | UTF-8 | 997 | 4.15625 | 4 | [] | no_license | def add(n1, n2)
return n1 + n2
end
def subtract(n1, n2)
return n1 - n2
end
def multi(n1, n2)
return n1 * n2
end
def divide(n1, n2)
return n1 / n2
end
def calc(num1, num2, op)
case op
when "+"
return add(num1,num2)
when "-"
return subtract(num1,num2)
when "*"
return multi(n... | true |
39e22238ad67d8eab3c6771ea91348e4a3194543 | Ruby | isabeljulmar/letters | /letters.rb | UTF-8 | 373 | 3.203125 | 3 | [] | no_license | require 'pry'
require 'colorize'
def letters
puts "Letters menu"
puts "1) Your input"
puts "2) Exit"
input = gets.strip
case input
when input == string
input.scan(/([a-z])(?=.*\1)/i).uniq.size
puts input.scan
if input == 'exit'
exit
else
... | true |
3a638ca8897b15957f531b2d3988eabe299bfa06 | Ruby | wayne5540/robot-test | /spec/robot_spec.rb | UTF-8 | 3,232 | 2.765625 | 3 | [
"WTFPL"
] | permissive | require_relative "../app/robot"
describe "Robot" do
let(:robot) { Robot.new }
describe "#face=" do
describe "valid orientation, non case-sensitive" do
specify do
expect { robot.face=("NORTH") }.to change(robot, :face).from(nil).to(:north)
end
specify do
expect { robot.face=("... | true |
35b7b788f36fa59a001a7cec321ac9b122dcee8a | Ruby | stuartbates/carwow | /lib/commands/colour_pixel_command.rb | UTF-8 | 240 | 2.78125 | 3 | [] | no_license | require 'commands/base_command'
class ColourPixelCommand < BaseCommand
def execute(bitmap)
bitmap[y, x] = colour
bitmap
end
private
def x
args[0]
end
def y
args[1]
end
def colour
args[2]
end
end
| true |
1db5d57256d49fb5405ec62bbc09175902f77c70 | Ruby | GLexx909/examtutor | /app/services/characteristic_change_service.rb | UTF-8 | 4,079 | 2.578125 | 3 | [] | no_license | class Services::CharacteristicChangeService
def initialize(user, request, new_points, path, **test)
@user = user
@request = request
@new_points = new_points
@path = path
@test = test[:test]
end
def change
case @request
when 'topics'
score_for_topic
when 'essay_passages'
... | true |
bda08854ac8c1ab7ca5f9b9a06c085947f8ec77b | Ruby | rshiva/MyDocuments | /01-notes-programming /04-ruby+rails/ruby1.9/samples/packaging_8.rb | UTF-8 | 717 | 2.578125 | 3 | [] | no_license | #---
# Excerpted from "Programming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www... | true |
42c07bbeeefaa267f4b4c63df8b9e0bdde5515a5 | Ruby | jroo/bdad | /test/unit/screen_data_test.rb | UTF-8 | 2,121 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class ScreenDataTest < ActiveSupport::TestCase
test "Handle 2 NaN pairs" do
assert_equal(
[[]],
ScreenData.convert_svg_to_x_y_pairs("MNaN NaNLNaN NaNz")
)
end
test "Handle 1 NaN pair" do
assert_equal(
[[]],
ScreenData.convert_svg_to_x_y_pairs("MNaN NaNz"... | true |
a2288eb7f39c46d1fccd2c3e20e525517a01e9bd | Ruby | machologo/ruby_watir_projects | /TrailFramework/features/support/pages/home_page.rb | UTF-8 | 606 | 2.546875 | 3 | [] | no_license | class HomePage
@@base_url = "http://enoteca.demo.episerver.com/en-US/"
def initialize(browser)
@browser = browser
#@log = log
end
def visit_home_page
@browser.goto(@@base_url)
end
def search_for_wine(wine_name)
@browser.text_field(:id => "HeaderArea_MainMenu_QuickSearch_SearchText")... | true |
9a4a2ffba16359a52c34a77c422d7ae3f750e474 | Ruby | ladyhodhod/PATS | /test/models/pet_test.rb | UTF-8 | 3,094 | 3 | 3 | [] | no_license | require 'test_helper'
class PetTest < ActiveSupport::TestCase
# Relationship matchers...
should belong_to(:owner)
should belong_to(:animal)
should have_many(:visits)
# Validation matchers...
should validate_presence_of(:name)
# ---------------------------------
# Testing other methods with a cont... | true |
2279ddb9ae21e3cacbb39708add3d9a4553c8039 | Ruby | mbelgrader/aa-projects | /memory_match/Board.rb | UTF-8 | 1,011 | 3.59375 | 4 | [] | no_license | require_relative "Card"
class Board
attr_reader :board_size, :grid
def initialize
@board_size = 2
@grid = Array.new(board_size) { [] }
end
def [](pos)
x, y = pos
grid[x][y]
end
def []=(pos, value)
x, y = pos
grid[x][y].face_value = value
end
def populate
temp_array = []
... | true |
44fdb949e24ffe33a7ffb987fe42ba2102539ddf | Ruby | Mattlk13/maglev | /src/test/Trac86.rb | UTF-8 | 2,245 | 2.5625 | 3 | [] | no_license | # tests for RubyOpElementAsgnNode
class C
def initialize
@iva = { }
@ivb = [6]
@getcount = 0
end
def geta
@getcount = @getcount + 1
@iva
end
def testa
@ivc = 5
cc = 6
@ivc ||= 7
unless @ivc == 5 ; raise 'err' ; end
dd = nil
dd &&= 5
unless dd == nil ; raise 'er... | true |
c51696b6e0e5d664858cc161fc70504626a07bea | Ruby | ckammerl/phase_0_unit_2 | /week_5/10_BONUS_rpn/my_solution.rb | UTF-8 | 2,392 | 4.15625 | 4 | [] | no_license | # U2.W5: Implement a Reverse Polish Notation Calculator
# I worked on this challenge [with: -].
# 2. Pseudocode
# Input: string of num and operators
# Output: integer
# Steps:
# 3. Initial Solution
=begin
class RPNCalculator
def initialize
end
=end
# method working for expression with three elements ['70', '... | true |
99a97bd4f80464633418efd1b6bbde404694af50 | Ruby | DEGoodmanWilson/ruby-devmate | /lib/dev_mate.rb | UTF-8 | 6,267 | 2.703125 | 3 | [
"MIT",
"Ruby"
] | permissive | require "dev_mate/version"
require "json"
require "httparty"
module DevMate
class BadRequestError < StandardError
end
class UnauthorizedError < StandardError
end
class ConflictError < StandardError
end
class NotFoundError < StandardError
end
class UnknownError < StandardError
end
class DevM... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.