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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
75e503a3245a81ee33e585966be46ec22f5c05b9 | Ruby | MacInnes/battleship | /lib/computer.rb | UTF-8 | 1,846 | 3.75 | 4 | [] | no_license | require './lib/board'
require './lib/ship'
class Computer
attr_reader :board
def initialize(board)
@board = board
@key = {
0 => "A",
1 => "B",
2 => "C",
3 => "D"
}
@move_history = []
end
def place(ship, board)
random = Random.new
choose_vert_vs_horizontal = ra... | true |
adf1feec2d75bc256f2cf31da30af1c6b5bf8984 | Ruby | AngieGreen/one_blog | /test/models/category_test.rb | UTF-8 | 674 | 2.828125 | 3 | [] | no_license | require 'test_helper'
class CategoryTest < ActiveSupport::TestCase
def setup
@category = Category.new(name: "Example Project", week: 1)
end
test "should be valid" do
assert @category.valid?
end
test "name should be present" do
@category.name = " "
assert_not @category.valid?
end
t... | true |
3880e53f8e847fd9ccd278850210278e2699782d | Ruby | liantics/MetisPracticeFiles | /Week1/hangman/generate_numbers.rb | UTF-8 | 531 | 3.609375 | 4 | [] | no_license | class GenerateNumbers
def initialize
@num_hash = {}
@index = 0
@max_index = 0
end
def make_the_list
ask_for_limit
generate_numbers
end
def ask_for_limit
puts "How many numbers should I generate?"
@max_index = gets.chomp
end
def generate_numbers
while @index.to_i <= @max_index.to_i
hash_ind... | true |
4615fc986cd8d12226d5fa04c3f5f311b66ff95f | Ruby | acasasayas/IronHack_exercises | /Sat15/room_simple.rb | UTF-8 | 1,312 | 4.03125 | 4 | [] | no_license | class Room
attr_reader :description, :N ,:S ,:E, :W, :index
def initialize (description,n,s,e,w,x,y)
@description = description
@n = n
@s = s
@e = e
@w = w
@index_x = x
@index_y = y
end
end
class Player
attr_reader :name, :item, :room_in, :winner
def initialize (name)
@name = name
@item = nil
... | true |
da137cd2691f79fe45094663a37177365c9736cf | Ruby | Cashman1396/Hackkerrank | /Hackerrank/even_odd.rb | UTF-8 | 126 | 3.484375 | 3 | [] | no_license | number = 3
def even_or_odd(number)
if number.odd?
print "Odd"
else
print "Even"
end
end
even_or_odd(number) | true |
fb4e18d85fcc9bbd8e901d67e319bd545d73fad8 | Ruby | astjohn/wicked_pdf | /lib/wicked_pdf/pdf.rb | UTF-8 | 1,004 | 2.78125 | 3 | [] | no_license | module WickedPdf
# This class renders the string content for the pdf and then uses
# Wkhtmltopdf to generate the pdf content. Temporary files generated throughout the process
# are also removed.
class Pdf
attr_accessor :content
def initialize(options, main_body)
options[:wkhtmltopdf] ||= nil
... | true |
77e87607e8ed589b99de19483ad6b426718066be | Ruby | arslanaly47/lakbima | /app/models/vacation.rb | UTF-8 | 542 | 2.59375 | 3 | [] | no_license | class Vacation < ApplicationRecord
belongs_to :employee
belongs_to :vacation_type
def starts_from=(val)
date = Date.strptime(val, "%d/%m/%Y") if val.present?
write_attribute :starts_from, date
end
def ends_at=(val)
date = Date.strptime(val, "%d/%m/%Y") if val.present?
write_attribute :ends_a... | true |
d83291a95228ed4447a6a584b28def5b740b86e9 | Ruby | WesleyHenjum/FightingGame | /fight.rb | UTF-8 | 2,025 | 4.25 | 4 | [] | no_license |
=begin
I borrowed the majority of this code and modified portions in order to better
understand creating, initializing and callig objects. Credit goes to user
ArtemisAthena456 from the SoloLearn app. It was a lot of fun and I plan to
modify it a lot more
=end
name = "Wesley" #Will convert to a 'gets.chomp' when abl... | true |
3107c99257f555d6e85c41610ceafeac7555ef12 | Ruby | lateleo/week-05-project | /app/models/prestige_class.rb | UTF-8 | 2,806 | 2.578125 | 3 | [] | no_license | class PrestigeClass < ActiveRecord::Base
# Non-relational Attributes: name (string),
# role (string),
# armor_type (string),
# stamina_index (integer),
# strength_index (integer),
... | true |
ab34c3cf856b43317a292bd76293d05a12565121 | Ruby | StevenMeiklejohn/ubiquitous-guide | /week2/day_2/snakes_and_ladders/specs/game_spec.rb | UTF-8 | 1,255 | 3.140625 | 3 | [] | no_license | require( 'minitest/autorun' )
require( 'minitest/rg' )
require_relative('../player' )
require_relative('../game' )
require_relative('../board' )
class TestGame < MiniTest::Test
def setup
positions = {
2 => 4,
7 => -7
}
board=Board.new(9, positions)
@player1 = Player.new( "Val" )
@player2 = P... | true |
94d1213c5408da3c7713c1569e6ae5ea36193020 | Ruby | arturocedilloh/LS_101 | /lesson_3/ex_3_Medium1.rb | UTF-8 | 3,209 | 3.96875 | 4 | [] | no_license | =begin
#-----------------Question1-----------------------------
10.times { |number| puts (" " * number)+ "The Flintstones Rock!" }
#-----------------Question2-----------------------------
puts "the value of 40 + 2 is " + (40 + 2).to_s #or
puts "the value of 40 + 2 is + #{(40 + 2)}"
#-----------------Question3--------... | true |
dff5df4d3b2525c64223ae881b03b8ba247ce9be | Ruby | fulgorek/aws-credentials-ruby | /script.rb | UTF-8 | 3,822 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "lib/signature"
require "net/https"
require "libxml_to_hash"
require "uri"
require "json"
require "parallel"
module AWS
class Request
attr_reader :access_key, :secret_key
ENDPOINTS = {
:identity => 'https://sts.amazonaws.com/?Action=GetCallerIdentity&Version=201... | true |
1d1e5745b15884a07fe56c162b1680d700522d76 | Ruby | petparent/rescue_groups | /support/event_mock.rb | UTF-8 | 1,735 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative '../models/event'
require_relative './base_mock'
module RescueGroups
class EventMock < BaseMock
class << self
# method: mocked_class
# purpose: Used by BaseMock, defines which object
# within the RescueGroups namespace to
# initialize with test_hash
... | true |
b0a928100243f314ba480c1db6c0718bdeefdf8d | Ruby | EICHAN1208/todo | /lib/renderer.rb | UTF-8 | 708 | 3.140625 | 3 | [] | no_license | class Renderer
def render_help_option
<<~TEXT
Options:\n-h, --help output usage information\n
Commands:\nadd [task title [-d|--due=(YYYY/)MM/DD]
Add a task\n\nall\nOutput all not-completed tasks\n
today\nOutput tasks that due until today\n
archived\nOutput completed tasks\n\ndone [ID... | true |
8a5a9619e1be42f78e7d48e6320e4e4689d7b019 | Ruby | appirio-tech/cs-website | /test/unit/user_test.rb | UTF-8 | 681 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "should not save" do
user = User.new
assert !user.save, "Saved the user without all required fields"
end
test "should save" do
user = User.new
user.username = 'me'
user.password = 'mypass'
user.sfdc_username = 'me@som... | true |
a91ea8b425da24a57f25d686881e0eb0a50a539e | Ruby | takenagaasuna/git-tutorial | /fizzbuzz.rb | UTF-8 | 187 | 3.09375 | 3 | [] | no_license | for i in 1..100 do
if i%3==0&&i%5==0
print("FizzBuzz\n")
elsif i%3==0
print("Fizz\n")
elsif i%5==0
print("Buzz\n")
elsif i%7==0
print("git\n")
else
print(i,"\n")
end
end
| true |
416a9f67da946596d0704e9af98c79408e7762c8 | Ruby | tripledub/whisky_ratings | /db/seeds.rb | UTF-8 | 329 | 2.53125 | 3 | [] | no_license | require 'csv'
ratings = (1..5).to_a
CSV.parse(File.read("#{File.dirname(__FILE__)}/seeds/whiskeys.csv"), headers: true).each do |row|
Whiskey.create(
{
title: row['name'],
description: row['description'],
taste: ratings.sample,
color: ratings.sample,
smokiness: ratings.sample
}
... | true |
fa7f6b3965b706578384dac1b89bb65d4058f3e9 | Ruby | pledgemusic/country_codes | /lib/postcode_validators/ca_postcode_validator.rb | UTF-8 | 220 | 2.515625 | 3 | [] | no_license | # Canada
class CAPostcodeValidator < PostcodeValidator
@regexp = /^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/
private
def clean(postcode)
super(postcode).gsub('-', ' ').strip.upcase
end
end
| true |
eff1451f414925d79de546793df63b9671108f62 | Ruby | mmcgovern0/alphabetize-in-esperanto-dumbo-web-career-042219 | /lib/alphabetize.rb | UTF-8 | 175 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ESPERANTO_ALPHABET = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz"
def alphabetize(arr)
arr.sort_by{ |phrase| phrase.split("").collect{|order| ESPERANTO_ALPHABET.index(order)} }
end | true |
feb48b9b79309d18c94a51a3e240e0d8879bb752 | Ruby | woojinc/bookish-memory | /coding-problems/advent_of_code/day-6.rb | UTF-8 | 2,810 | 3.484375 | 3 | [] | no_license |
input = File.foreach('/Users/woojin/Desktop/bookish-memory/coding-problems/advent_of_code/day-6-input.txt').map { |line| line.strip }
# Part 1 Test Data => 42
# input = [ "COM)B", "B)C", "C)D", "D)E", "E)F", "B)G", "G)H", "D)I", "E)J", "J)K", "K)L" ]
# Part 2 Test Data => 4
# input = [ "COM)B", "B)C", "C)D", "D)E", ... | true |
fe05852ed76fc09e56bdbc4aa7f4bacfe7023c6d | Ruby | SevenInches/tekala | /lib/sms.rb | UTF-8 | 6,234 | 2.625 | 3 | [] | no_license | class Sms
attr_accessor :teacher_name, :member_name, :teacher_mobile, :member_mobile, :book_time, :quantity, :order_no, :train_field_name, :money, :content
attr_accessor :teacher_mobile, :member_mobile, :teacher_word, :member_word
def initialize(params)
if params
params.each do |key, value|
instance_... | true |
a709062ab40321b05f908060005b09efb77d00bd | Ruby | Sinetheta/solidus_subscriptions | /app/models/solidus_subscriptions/line_item_builder.rb | UTF-8 | 1,079 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | # This class is responsible for taking a SubscriptionLineItem and building
# it into a Spree::LineItem which can be added to an order
module SolidusSubscriptions
class LineItemBuilder
attr_reader :subscription_line_item
# Get a new instance of a LineItemBuilder
#
# @param subscription_line_item [Soli... | true |
7b361967422ee4c2557b5496aec6ce70d0ae655f | Ruby | yschu7/sample_app | /ruby/ch08-4.rb | UTF-8 | 1,016 | 3.421875 | 3 | [] | no_license | #!/usr/bin/env ruby
countdown = Object.new # A plain old object
def countdown.each # The each iterator as a singleton method
yield 3
yield 2
yield 1
end
countdown.extend(Enumerable) # Now the object has all Enumerable methods
p countdown.sort # [1, 2, 3]
module Mymod
module MyClass... | true |
bba9c2015705cf6f5a976cd3fad582d6d00bfe83 | Ruby | ayip723/ruby_chess | /lib/human_player.rb | UTF-8 | 2,044 | 3.796875 | 4 | [] | no_license | require_relative 'errors'
class HumanPlayer
LETTER_MAP = {
'a' => 0,
'b' => 1,
'c' => 2,
'd' => 3,
'e' => 4,
'f' => 5,
'g' => 6,
'h' => 7
}
NUMBER_MAP = {
'1' => 0,
'2' => 1,
'3' => 2,
'4' => 3,
'5' => 4,
'6' => 5,
'7' => 6,
'8' => 7
}
attr_re... | true |
0a7e58bfd847d88f9f36e4e06f5172c7d6924cfe | Ruby | buithehoa/rspec-3-book | /book-code/12-creating-custom-matchers/01/custom_matcher/spec/event_spec.rb | UTF-8 | 1,640 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'event'
RSpec::Matchers.define :have_no_tickets_sold do
match { |event| event.tickets_sold.count.zero? }
failure_message do |event|
super() + ", but had #{event.tickets_sold.count}"
end
end
RSpec::Matchers.define :be_sold_out do
match { |event| event.tickets_sold.count == event.capacity }
fail... | true |
1e8c118e123af2a4535cd141bf063070fd81d769 | Ruby | roomorama/concierge | /spec/lib/concierge/suppliers/waytostay/properties/city_tourist_tax_spec.rb | UTF-8 | 8,219 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe Waytostay::Properties::CityTouristTax do
let(:currency) { "EUR" }
context "included already" do
let(:taxes) {
[
{
"included" => true,
"rate" => 17,
"rate_type" => "per_stay",
"from_age" => 18,
"max_... | true |
72b7f05b735520451bde0bc8673a6479b1ed436c | Ruby | guyviner/codecorelife | /day5/day5 TA notes/lab4/cat.rb | UTF-8 | 321 | 3.703125 | 4 | [] | no_license | require "./animal.rb"
require "./bird.rb"
require "./helper_method.rb"
class Cat < Animal
include HelperMethod
def initialize(name)
super(name)
end
def catch(bird)
if randomize >= 51
puts "#{self.name} caught #{bird.name} and ate it"
else
puts "#{bird.name} got away!"
end
end
end... | true |
e768dd6c430e209ecba7988471a9d9956dd918c6 | Ruby | sabrina-s/alphaworkspace | /004 Valid anagram/004_validanagram.rb | UTF-8 | 287 | 3.421875 | 3 | [] | no_license | def is_anagram(s, t)
if s.each_char.sort == t.each_char.sort
true
else
false
end
end
p is_anagram("listen", "silent") # true
p is_anagram("doggo", "doge") # false
p is_anagram("elvis", "lives") # true
p is_anagram("hello", "hillo") #false
p is_anagram("empty", "") #false
| true |
7185fe1ff274d0363e0489a79e80dddc290f2f21 | Ruby | vanny96/recursion | /fibonacci.rb | UTF-8 | 373 | 3.84375 | 4 | [] | no_license | def fibs number
array = [0, 1]
return [0] if number == 1
return array if number == 2
for i in 2...number do
array << array[i-1] + array[i-2]
end
array
end
def fibs_rec number
return [0] if number == 1
return [0,1] if number == 2
array = fibs_rec number-1
array << arr... | true |
fab911ef6ca5993cf8a84901ef173f39f1757b38 | Ruby | oafridi/puzzles | /lowest_two_ints.rb | UTF-8 | 745 | 3.8125 | 4 | [] | no_license | def find_smallest_two(arr)
return arr if arr.length < 2
smallest_two = []
smallest = arr[0]
second_smallest = arr[1]
arr[2..-1].each do |num|
if second_smallest < smallest
second_smallest, smallest = smallest, second_smallest
end
if num < smallest
second_smallest = smallest
s... | true |
7532b6cb76c7b104b8b65435b5e542bcb91aaca3 | Ruby | LucaCarignano/notifications | /tests/models/user_test.rb | UTF-8 | 2,058 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require File.expand_path '../test_helper.rb', __dir__
# Test for user class
class UserTest < MiniTest::Unit::TestCase
def values_existence
# Arrange
@user1 = User.new
# Act
@user1.name = 'fede'
@user1.surname = 'guti'
@user1.username = 'fede1'
@user1.email ... | true |
853f2300a3b69fff56557aaee31f2efb371a0d31 | Ruby | michaelfeathers/scythe | /lib/probe.rb | UTF-8 | 747 | 3.03125 | 3 | [
"MIT"
] | permissive |
$:.unshift File.dirname(__FILE__)
require 'date'
class Probe
attr_reader :name
def initialize name, mod_date
@name = name
@mod_date = mod_date
end
def days_silent? date_now
# approx secs/day is good enough
return (seconds_silent?(date_now) / 86400).to_i
end
def hours_silent? date_no... | true |
3f3e204252ab4d77e1b66f6fb910b8219df632d7 | Ruby | SesameSeeds/betsy | /test/models/order_item_test.rb | UTF-8 | 7,759 | 2.6875 | 3 | [] | no_license | require "test_helper"
describe OrderItem do
let(:pending) { order_items(:pending) }
let(:paid) { order_items(:paid) }
describe "validations" do
it "must have a quantity to be valid" do
pending.valid?.must_equal true
pending.quantity = nil
pending.valid?.must_equal false
end
it "r... | true |
7cf41cacdddf912d393811573af8c923ea03ea4a | Ruby | ktamoguis/ttt-with-ai-project-v-000 | /bin/tictactoe | UTF-8 | 226 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
puts "Welcome to Tic Tac Toe!"
#newgame = Game.new
newgame = Game.new(Players::Computer.new("X"),Players::Computer.new("O"))
newgame.board.display
newgame.play
| true |
30675d028998f65169ff9c6109f18269fc1af804 | Ruby | chestercun/projeuler | /15.rb | UTF-8 | 354 | 3.53125 | 4 | [] | no_license |
# add factorial method
class Integer
def factorial_itr
f = 1; for i in 1..self; f*=i; end; f
end
alias :factorial :factorial_itr
end
def nCr(n,r)
return n.factorial / (n-r).factorial / r.factorial
end
# this is a pascal's triangle inspired problem
def paths(n)
return nCr(2*(n-1),n)
end
#... | true |
f723084ab6caa1fe6ed0b1374db8636bd07a867a | Ruby | highercomve/algos | /diagonal-difference/program.rb | UTF-8 | 622 | 3.5 | 4 | [] | no_license | #!/bin/ruby
require 'json'
require 'stringio'
def calc_right(length, index)
((length - 1) * (index + 1)) % length
end
def calc_left(length, index)
(index * (length + 1)) % length
end
# Complete the diagonalDifference function below.
def diagonalDifference(arr)
(0...arr.size).inject(0) do |acc, index|
... | true |
142bde171b95217a3a7896799126e94a970b1429 | Ruby | f-w-robots/MZG | /db-code/circle-bug.rb | UTF-8 | 749 | 2.640625 | 3 | [] | no_license | require_relative 'connection.rb'
require_relative 'helpers/bug.rb'
require_relative 'drivers/bugs/line_follower.rb'
class Worker
def initialize connection
@connection = connection
@connection.mail_permission(["lh"])
@driver = Drivers::Bugs::LineFollower::Main.new self
puts 'forward'
@driver.com... | true |
4a9449fff8d0def2638488189d026d42bec35f5f | Ruby | sdkclements/ruby-cli-lab | /battleship/app.rb | UTF-8 | 634 | 2.734375 | 3 | [] | no_license | require_relative 'models/battleships'
require_relative 'models/game_board'
require_relative 'models/torpedo'
# CREATE BOARD
create_board = initialize_board(10, "(~)")
# Create Boats
add_piece_horz
boat_one = Battleship.new($horz_starting_cords)
# boat_one.cords <<
add_piece_vert
boat_two = Battleship.new($vert_st... | true |
ec76ebea69f1331ae196394be51d45e5eaa4faea | Ruby | arscholtes/blackjack-1 | /blackjack.rb | UTF-8 | 5,113 | 3.515625 | 4 | [] | no_license | require_relative 'deck'
require_relative 'shoe'
class Game
attr_accessor :player_hand,
:dealer_hand,
:deck_o_cards,
:player_value,
:dealer_value,
:phand,
:final_dealer_hand,
:win_tracker,
:... | true |
14a671ee0762965424166821201e37aff48da6dc | Ruby | stogashi146/rails-tutorial-sample_app | /tutorial/Enshu/29.rb | UTF-8 | 203 | 3.390625 | 3 | [] | no_license | # 引数で指定した協会世界時のTimeオブジェクトを返す
t = Time.gm(1970,1,1)
# strftime フォーマット文字列を指定する %Y(西暦) %m(月) %d(日)
puts t.strftime("%Y/%m/%d") | true |
88ac8e3e775a33c1ce4a80ed6d279f737e68ba6e | Ruby | mammothb/ruby-basics | /chess/lib/pieces/pawn.rb | UTF-8 | 1,376 | 2.890625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'movement.rb'
require_relative 'piece.rb'
class Pawn < Piece
include Movement::SingleStep
attr_writer :two_square_opening
def initialize(color, pos = nil)
super({ w: "\u2659", b: "\u265F" }, color, pos)
@baseline = @color == :w ? 1 : 6
@last_rank = @c... | true |
e6fb9e949b2d2ac46cbb3e51d7b1f1a2fe605eac | Ruby | reddavis/NLP-Backpack | /lib/nlp_backpack/chunkers/regex_chunker.rb | UTF-8 | 2,568 | 3.234375 | 3 | [
"MIT"
] | permissive | # ChunkGrammer
# Chunk Grammers are regex-esq patterns that indicate how sentences should be chunked
# The patterns are made up of Tag Patterns.
# (DT)?(JJ.*)* == Optional determiner, followed by zero or more of any type of adjective.
require 'nlp_backpack/chunkers/tag_pattern'
module NLPBackpack
module Chunker
... | true |
b14757900b369c440dca36c0e04c276f092ab274 | Ruby | RomanTurner/upcase_tdd | /spec/person_spec.rb | UTF-8 | 2,511 | 3.703125 | 4 | [] | no_license | require "person"
# Use TDD principles to build out name functionality for a Person.
# Here are the requirements:
# -[X] Add a method to return the full name as a string. A full name includes
# first, middle, and last name. If the middle name is missing, there shouldn't
# have extra spaces.
# -[x] Add a method to r... | true |
ec73dd3e25533512c06221b47f3d49984d51c862 | Ruby | martinpoljak/unified-queues | /lib/unified-queues/multi.rb | UTF-8 | 5,368 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
require "unified-queues/multi/driver"
require "hash-utils/module"
##
# Base 9Unified Queues+ module.
#
module UnifiedQueues
##
# More queues single interface.
#
class Multi
##
# Contains assig... | true |
34f3958c5458aedd900861f1bcadc21599b33d32 | Ruby | leeju/should-i-send-this | /app/models/alchemy_data.rb | UTF-8 | 1,224 | 3.40625 | 3 | [] | no_license | class AlchemyData
attr_reader :keywords, :concepts, :sentiment
def initialize(content)
@alchemyapi = AlchemyAPI.new()
@content = content
@keywords = []
@concepts = []
@sentiment = 0
self.retrieve_from_api
end
def retrieve_from_api
get_keywords
get_concepts
get_sentiment
e... | true |
624eee3649e923255cdc06c34d502b2ed49bcc00 | Ruby | s-p-k/learn-ruby-the-hard-way-solutions | /src/ex03.rb | UTF-8 | 321 | 3.484375 | 3 | [] | no_license | puts "i will now count my chickens"
puts "hens", 25+30/6
puts "roosters", 100-25*3%4
puts 3+2+1-5+4%2-1/4+6
puts "is it true that 3+2<5-7?"
puts 3+2<5-7
puts "what is 3+2?",3+2
puts "what is 5-7?",5-7
puts "Oh that's why it's false"
puts "mo"
puts "greater?",5>-2
puts"greater-or-equal?",5>=-2
puts"less-or-equal?",5<=-2... | true |
d0ec3ed15ed3abc39e2d3a4995bebfaccc5087b6 | Ruby | Bearzooka/PackageChanger | /lib/PackageChanger/messages.rb | UTF-8 | 2,543 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module PackageChanger
USAGE = "
≈≈≈ PackageChanger ≈≈≈
Usage: packagechanger [--silent] [--policy PolicyID] --old OldPackageName --new NewPackageName || --list ListedPackage
"
PATCH_USAGE = "
≈≈≈ PackageChanger ≈≈≈
Patch definition usage: packagechanger [--silent] --patch Patch... | true |
2f06e261b69d9d131579ef8685a37ad85d20802e | Ruby | yoshoku/rumale | /rumale-manifold/lib/rumale/manifold/tsne.rb | UTF-8 | 9,006 | 3.09375 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require 'rumale/base/estimator'
require 'rumale/base/transformer'
require 'rumale/utils'
require 'rumale/validation'
require 'rumale/pairwise_metric'
require 'rumale/decomposition/pca'
module Rumale
module Manifold
# TSNE is a class that implements t-Distributed Stochastic Neighbor... | true |
bc821cfcaece6916e0b668bc590dfb20af299826 | Ruby | BakaBBQ/LCraft | /LData/ARPG Core/Relationships.rb | UTF-8 | 654 | 3.03125 | 3 | [] | no_license | =begin
Relationships
===========================
so relationship is from one to another
###What does relationship do
when seeing someone, if you have a very bad relationship, you will be hostile to the guy there
and it works also the way around
###Two types of relationship
personal relationship... | true |
4feb23a9ec38e996be2c3e913c55e2688bf7b47d | Ruby | ChloeBaba/whistle_island | /db/seeds.rb | UTF-8 | 7,546 | 2.875 | 3 | [] | no_license | require 'date'
puts 'Cleaning database...'
Booking.destroy_all
Island.destroy_all
User.destroy_all
puts 'Creating users...'
user_1 = User.create!(name: "Commodus", email: "user_1@example.com", password: "123456")
user_2 = User.create!(name: "Attila the Hun", email: "user_2@example.com", password: "123456")
user_3 = U... | true |
a89db6fe6009358a46aa527daeba427cbe69fa20 | Ruby | gilesbowkett/wheatley | /spec/simple_case_spec.rb | UTF-8 | 6,959 | 2.828125 | 3 | [] | no_license | %w{rubygems ap}.each {|lib| require lib}
require File.dirname(__FILE__) + "/../lib/basic.rb"
describe "simplest-case automated refactoring" do
it "refactors code" do
@code = <<-CODE
function() {
for (var i = 0 ; i++ ; i < 100) {
console.log("foo");
}
for (var i = 0 ; i++ ; i < 100) {
console.log("... | true |
f93346498c71e0b6a1b0e4a5c4dc107def6a489a | Ruby | enoc3994/CLASE_RUBY | /hola.rb | UTF-8 | 345 | 3.875 | 4 | [] | no_license | # Este es un comentario de una sola linea
=begin
Esto es un comentario de varias lineas
=end
puts "Hola mundo"
# class FacturaRapida => factura_rapida.rb
a = 1; b = 2; c = 3;
# es equivalente
a = 1
b = 2
c = 3
varias_lineas = "este es un string \
de varias lineas "
una_linea = "este es un string una linea"
puts ... | true |
bee7017074f30a763f9fd5b68cab4a97d37e3ed9 | Ruby | theironyard-rails-atl/riazvirani | /07-30/4/hangman.rb | UTF-8 | 836 | 2.640625 | 3 | [] | no_license | require 'sinatra'
require 'pry'
require './hangman_class.rb'
enable :sessions
get '/' do
if request["user_letter"]
session[:game].guess_letter(request["user_letter"])
else
session[:game] = HangmanGame.new()
end
if session[:game].won?
middle_area = %{<h3 style="color: green">You won!</h3>}
elsif... | true |
89cd5e636c1362359014ad5a68f951349725cfe1 | Ruby | sufyanadam/interactor | /lib/interactor/error.rb | UTF-8 | 1,020 | 3.015625 | 3 | [
"MIT"
] | permissive | module Interactor
# Internal: Error raised during Interactor::Context failure. The error stores
# a copy of the failed context for debugging purposes.
class Failure < StandardError
# Internal: Gets the Interactor::Context of the Interactor::Failure
# instance.
attr_reader :context
# Internal: Ini... | true |
de3df37069209f424c83373d24ff14a97adc285c | Ruby | cklim83/launch_school | /03_rb120_oop/lesson_04_oo_practices/05_hard1.rb | UTF-8 | 11,880 | 4.125 | 4 | [] | no_license | =begin
Question 1
Alyssa has been assigned a task of modifying a class that was initially
created to keep track of secret information. The new requirement calls
for adding logging, when clients of the class attempt to access the
secret data. Here is the class in its current form:
class SecretFile
attr_reader :data
... | true |
636c5bc259d4e71f63b8528a4ee09b01566aed1e | Ruby | FStrony/caelum-ruby-on-rails | /Exercicio3_10.rb | UTF-8 | 152 | 3.109375 | 3 | [] | no_license | #encoding: utf-8
#Exercicio 3.10
#Tipos
3.times
puts "0 3 é um objeto!"
puts 3.class
puts 333333333333333.class
#imprime conta
puts 3*(2+5)/8
| true |
c1ead2ec62a70afe06ea3e5b394262b56ce73a98 | Ruby | hawkk9/sangoku | /app/models/skills/idou_skill.rb | UTF-8 | 758 | 2.765625 | 3 | [] | no_license | module Skills
class IdouSkill < Skills::BaseSkill
class << self
def all_effects
[
{
level: 3,
effect: Battle::Effect.new(method(:tousou_before_battle_effect), :before)
}
]
end
def tousou_before_battle_effect(user, opponent_user, battle... | true |
3cdb55b727b15c2cb4fb5719b6030d60eb4469ee | Ruby | google-code-export/tokland | /dicts/maria_moliner/process.rb | UTF-8 | 236 | 2.515625 | 3 | [] | no_license | #!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
def clean_html(html_path)
doc = Nokogiri::HTML.parse(open(html_path))
html = doc.css(".graywin2tr table").css("table")[2..-4].to_s
STDOUT.write(html)
end
clean_html(ARGV[0])
| true |
c0ff82311bff996d6699ca13782e9c7bce1d505f | Ruby | kriskanya/workout-tracker | /spec/integration/adding_daily_routines_spec.rb | UTF-8 | 847 | 2.734375 | 3 | [
"MIT"
] | permissive | RSpec.describe "Adding daily routines", :integration do
context "valid input" do
let!(:output){ run_wt_with_input("add", "Monday") }
it "should add a daily routine" do
expect(DailyRoutine.count).to eql 1
end
it "should save the record accurately" do
expect(DailyRoutine.last.name).to eql "... | true |
cb8ae297f2e98ceee7763d09fb53e1fe3873b72f | Ruby | romigos/2021_RUBY_RUSH | /23_step_array.rb | UTF-8 | 197 | 3.3125 | 3 | [] | no_license | men = ["Gena", "George", "Misha"]
puts men
women = ["Katrin", "Liza", "Masha"]
puts women
puts 'Все вместе: ' + men.to_s + women.to_s
puts 'Все вместе: ' + men.concat(women).to_s
| true |
ea4cc5ad816fda506184bcd8bbbd70965b1f2c00 | Ruby | macha3162/try_vision_api | /vision_label.rb | UTF-8 | 1,184 | 2.75 | 3 | [] | no_license | require 'bundler'
Bundler.require
require 'base64'
require 'json'
require 'net/https'
require 'pp'
IMAGE_FILE = './sea.jpeg'
#IMAGE_FILE = './face.jpeg'
API_KEY = 'AIzaSyCvJnXUnBQXAL1D5mwSdWoVflxSSOUtL3o'
VISION_API = "https://vision.googleapis.com/v1/images:annotate?key=#{API_KEY}"
TRANSLATION_API = "https://transl... | true |
3dd3f74f3758e9a52dae5b8669b67e865fc6ac7d | Ruby | Zevgon/Study_Project_99cats | /app/models/cat_rental_request.rb | UTF-8 | 1,745 | 2.640625 | 3 | [] | no_license | class CatRentalRequest < ActiveRecord::Base
validates :cat_id, :start_date, :end_date, presence: true
validates :status, inclusion:{in: ["Approved","Pending","Denied"]}
validate :overlapping_approved_requests
validate :valid_dates
belongs_to :cat
def approve!
unless self.status == "Denied"
self.t... | true |
83e80fe2164d25b7b39ae9caae0795e9034a8dfc | Ruby | finn-francis/ruby-edit | /lib/ruby_edit/commands/configure.rb | UTF-8 | 997 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'ruby_edit'
module RubyEdit
module Commands
# Configuration command class
#
# Gets called from the CLI configuration method
class Configure
CONFIGURATIONS = %i[editor grep_options].freeze
def initialize(options)
@options = options
end
... | true |
70334c15dbbca7a2711160a60e6f5b4245ea34fe | Ruby | kel12/bestgems.org | /test/models/test_ranking.rb | UTF-8 | 3,083 | 2.609375 | 3 | [] | no_license | require 'minitest/unit'
require 'database'
require_relative '../run_migration'
class TestRanking < MiniTest::Unit::TestCase
def setup
Value.where.delete
Ranking.where.delete
Gems.where.delete
end
def test_total
Gems.insert(:id => 1,
:name => 'foo',
:version => '1.... | true |
048e74cccb7fde31f32506cb05074a77803b111a | Ruby | bvjones/battle_new | /spec/game_spec.rb | UTF-8 | 1,012 | 3.03125 | 3 | [] | no_license | require 'game'
describe Game do
let(:player1) {double :player}
let(:player2) {double :player}
subject(:game) { described_class.new(player1, player2) }
describe '#player1' do
it 'retrieves the first player' do
expect(game.player1).to eq player1
end
end
describe '#player2' do
it 'retrieves the ... | true |
9d3e01f99dfa5c6eb1335495244d20b608c3ddf1 | Ruby | ortegabx05/ttt-6-position-taken-rb-online-web-sp-000 | /lib/position_taken.rb | UTF-8 | 204 | 3 | 3 | [] | no_license | board = ["","","",""," ","","","",""]
def position_taken?(board,index)
taken = nil
if (board[index] == " " || board[index] == "" || board[index] == nil)
taken = false
else
taken = true
end
end | true |
db70ee21683b2d70e7c1f895bfd1cb38ae6b763b | Ruby | tiberiufrat/stock_picker | /stock_picker.rb | UTF-8 | 417 | 3.4375 | 3 | [] | no_license | require 'pry'
def stock_picker(array)
max_profit = 0
days = []
array.each_with_index do |day, index|
return 0 unless day.is_a? Numeric
array.drop(index).each_with_index do |second_day, second_index|
profit = second_day - day
if profit > max_profit
max_profit = profit
days = [i... | true |
ebeb560ea2b4ec7e735d0dcd20db961099bc3a16 | Ruby | Sujimichi/Jebretary | /app/helpers/transferable.rb | UTF-8 | 6,209 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | module Transferable
#move_to can either move or copy a craft.
# move_to campaign #> will move the craft, assuming that one of the same name doesn't already exist in the target campaign
# move_to campaign, :replace => true #>overwites the existing craft (if there is one) in the target campaign
# move_to camp... | true |
a7f8b2418f4d22fef956ee14003510ba310fdf74 | Ruby | OSC/ondemand | /apps/dashboard/app/models/balance.rb | UTF-8 | 3,318 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'open-uri'
# This describes file or project balances for a given user.
class Balance
class InvalidBalanceFile < StandardError; end
attr_reader :user, :project, :value, :project_type, :unit, :updated_at
class << self
# Get balance objects only for requested user in JSON file(s)
#
# KeyError... | true |
df0cbcade30a8f412f6c5022b58a71f09ffc4414 | Ruby | Amanda-Katherine/reverse-each-word-onl01-seng-ft-070620 | /reverse_each_word.rb | UTF-8 | 615 | 4.21875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #reverse_each_word
string = "Hello there, and how are you?"
# run through using each method
# def reverse_each_word(string)
# string_to_array = string.split
# reverse_array = []
# string_to_array.each do |word|
# reverse_array << word.reverse
# end #each
# reverse_array.join(' ')
# end
#run through exch... | true |
942d6775d255c7a95bdb5391e7c3c23147dea296 | Ruby | meta-morpho-sys/new_oystercard | /lib/billing.rb | UTF-8 | 638 | 3.171875 | 3 | [] | no_license | # Handles information about fares and penalties and calculates fares.
class Billing
PENALTY_FARE = 6.0
DEFAULT_FARE = 3.0
COST_PER_ZONE = 1.1
def initialize
@fare = DEFAULT_FARE
end
def calculate_fare(journey)
return PENALTY_FARE unless journey.complete?
src_zone = journey.entry_station.zone.t... | true |
2fad0f1ca3b8fb6d91d875cc60c7f13877b2cc2d | Ruby | kanpou0108/launchschool | /Exercises/101-109_small_problems/medium_2/q05_ans_others.rb | UTF-8 | 486 | 3.5 | 4 | [] | no_license | def triangle(side1, side2, side3)
sides = [side1, side2, side3].sort
case
when sides[0] + sides[1] <= sides[2] || sides.include?(0)
:invalid
when (sides[1] == sides[0]) ^ (sides[1] == sides[2])
:isosceles
when sides[0] == sides[1] && sides[1] == sides[2]
:equilateral
else :scalene
end
end
p ... | true |
b00694732cdf5d6992ec47a7ca466f7aa8006288 | Ruby | JakeTompkins/StickerMachineAPI | /app/services/cacher.rb | UTF-8 | 1,840 | 2.875 | 3 | [] | no_license | class Cacher
def initialize()
# Initialize Redis class
@r = Redis.new(url: 'redis://localhost:6379/1')
end
def set(parameters)
# Create cache record
@r.set(parameters[:key], parameters[:value])
# Set expiration to 24 hours unless object is list of censored terms
... | true |
b9bc0b6b7d46db9196d6799a9a62be250e7dfc8c | Ruby | PlantandFoodResearch/genometools | /scripts/gen-randseq.rb | UTF-8 | 3,342 | 3.109375 | 3 | [
"LicenseRef-scancode-mit-old-style",
"Zlib",
"BSD-3-Clause",
"MIT",
"bzip2-1.0.6",
"ISC",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
class Randomsequence
def initialize(alphabet,myseed=nil)
@alphabet = alphabet
@asize = alphabet.length
if myseed.nil?
seed = Random.new_seed
else
seed=myseed
end
@rgen = Random.new(seed)
end
def sequence(len)
s = Ar... | true |
623302d23b1433b36f60bfdccf0d3d70d3fa4fed | Ruby | south37/grpc_access_logging_interceptor | /spec/support/value_filter.rb | UTF-8 | 298 | 2.546875 | 3 | [
"MIT"
] | permissive | module Support
class ValueFilter
FILTERED_KEYS = [:value]
# @param [Hash] params
# @return [Hash]
def filter(params)
r = params.dup
FILTERED_KEYS.each do |key|
if r.has_key?(key)
r[key] = "[FILTERED]"
end
end
r
end
end
end
| true |
be7a4aa1de6d87db3bd7c5d894381f7c510c50a1 | Ruby | jackdempsey/pancake | /lib/pancake/mixins/publish.rb | UTF-8 | 4,303 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.join(File.dirname(__FILE__), "publish", "action_options")
module Pancake
module Mixins
module Publish
def self.extended(base)
base.class_eval do
class_inheritable_accessor :actions, :formats
self.actions = {}
self.formats = [:html]
end
... | true |
f94d4b9a59fef4a9ee95fecca4f361dd9bc1b23e | Ruby | mskeen/rubyfun-tower | /lib/bird.rb | UTF-8 | 638 | 3.125 | 3 | [] | no_license | require 'gosu'
class Bird
STEP_SPEED = 16
def initialize(window, x, y, scale_x, scale_y, tiles)
@window, @x, @y = window, x, y
@scale_x, @scale_y, @tiles = scale_x, scale_y, tiles
@step = 0
@step_change = STEP_SPEED
end
def draw
@tiles[@step].draw_rot(@x, @y, 0, 0, 0.5, 0.5, @scale_x, @s... | true |
22668bd287c095de7cb3b6a486141a033290fd06 | Ruby | bgentry/flynn | /website/lib/cli_doc_compiler.rb | UTF-8 | 1,361 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | require 'tilt/erb'
require 'active_support/core_ext/string/strip'
require 'active_support/core_ext/string/output_safety'
module Processor
extend ERB::Util
def self.parse(text)
sections = text.split(/\n\n(?=[[:alnum:]]+\:)/) # Split on "[/n/n]Section:"
description = sections.shift.split("\n\n")
usage =... | true |
eed0d187dfd4700c9a7b3f1015ef6a075b27366b | Ruby | efreesen/priori_data | /lib/controllers/base.rb | UTF-8 | 648 | 2.5625 | 3 | [] | no_license | module PrioriData
module Controllers
class Base
def initialize(params)
@message = nil
@params = params
@resources = []
@resource = {}
end
def self.index(params)
self.new(params).index
end
def self.show(params)
self.new(params).show
... | true |
7e6f033d3a7b02f61a44af802636bae9a0024692 | Ruby | rstehwien/mnm3esim-ruby | /lib/mnm3esim/modifiable.rb | UTF-8 | 1,275 | 2.859375 | 3 | [] | no_license | module MnM3eSim
class ModifiableStructData
def self.attr_accessor_modifiable(*syms)
syms.each do |sym|
property = sym.to_s
class_eval %Q"
def #{property}=(value)
@#{property} = value
end
def #{property}
apply_modifiers(\"#{property}\", @#{property})
end
"
end
end... | true |
a5906488df3b8bf262075974331ffedf9ebcda37 | Ruby | florepo/ruby-enumerables-cartoon-collections-lab-london-web-100719 | /cartoon_collections.rb | UTF-8 | 972 | 3.515625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array_dwarfs)
array_dwarfs.each_with_index {|dwarf, index| puts "#{index+1}. #{dwarf}" }
end
def summon_captain_planet(array_planeteer)
planeteer_calls=[]
planeteer_calls=array_planeteer.map {|planeteer| "#{planeteer.capitalize}!"}
end
def long_planeteer_calls(array_calls)
output=[]
... | true |
be9026e0638d835d9c3761598edf2ae2ff220dbd | Ruby | codehaus/foci-git | /lib/foci/date_parser.rb | UTF-8 | 1,198 | 2.921875 | 3 | [] | no_license | class Foci::DateParser
MONTH_VALUE = { 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' =>10, 'NOV' =>11, 'DEC' =>12 }
def self.parse(datetime)
# 20/Oct/2006:00:00:00 -0500
#DateTime.strptime(datetime, "%d/%b/%Y:%H:%M:%S %z")
d... | true |
e176d791717308760b42e46f51ebc28e08f435dd | Ruby | MyNameIsSpencer/oop_inheritance | /test_multilinguist.rb | UTF-8 | 498 | 2.625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './multilinguist.rb'
class TestMultilinguist < MiniTest::Test
def setup
@guy = Multilinguist.new
end
def test_initial_language
assert_equal 'en', @guy.current_lang
end
def test_initial_language
refute_equal 'fr', @guy.current_lang
e... | true |
d19850e70dae551b6a1246a9a3c02ab28e6284ef | Ruby | saru1439s7/ruby-practice | /96.rb | UTF-8 | 340 | 3.625 | 4 | [] | no_license | def fizz_buzz(n)
if n % 15 ==0
"Fizz_buzz"
elsif n % 3 == 0
"Fizz"
elsif n % 5 == 0
"Buzz"
else
n.to_s
end
rescue =>e
puts "[LOG] エラーが発生しました: #{e.class} #{e.message}"
# 捕捉した例外を再度発生させ、プログラム自体は異常終了させる
raise
end
p fizz_buzz(nil)
| true |
89b751239d52dc43adbae1a3aae932a7df034507 | Ruby | HEROGWP/ruby_pratice | /phantomjs_test.rb | UTF-8 | 1,573 | 2.515625 | 3 | [] | no_license | # 環境設定
# brew install phantomjs
# gem i 'capybara'
# gem i 'selenium-webdriver'
# gem i 'watir-webdriver'
# gem i 'poltergeist'
require 'capybara'
require 'capybara/dsl'
require 'capybara/poltergeist'
require 'nokogiri'
require 'logger'
Capybara.run_server = false
# Capybara.current_driver = :selenium
Capybara.curre... | true |
c580c6c87b3c22d61404133d21e5f7288aa6055f | Ruby | sigus/solutions | /aoc/2019/01_1.rb | UTF-8 | 64 | 2.84375 | 3 | [] | no_license | p STDIN.read.split.map(&:to_i).inject(0) { |s, x| s + x/3 - 2 }
| true |
b78c5b0c1c7a8ba422517e2e82c4eb3606d64994 | Ruby | nikkigraybeal/rb101 | /exercises/easy6/halvsies.rb | UTF-8 | 742 | 4.40625 | 4 | [] | no_license | # Write a method that takes an Array as an argument, and returns two Arrays (as a pair of nested Arrays) that contain the first half and second half of the original Array, respectively. If the original array contains an odd number of elements, the middle element should be placed in the first half Array.
def halvsies(a... | true |
3623db3efef175cc1022d6e272b723f18a51b378 | Ruby | lsaville/cracking-code | /tree.rb | UTF-8 | 1,867 | 4 | 4 | [] | no_license | class TreeNode
attr_accessor :data, :left, :right
def initialize(data, left=nil, right=nil)
@data = data
@left = left
@right = right
end
end
class LinkedList
attr_accessor :head
def initialize(node)
@head = node
end
def prepend(node)
@head = node if @head == nil
node.next_node ... | true |
bbd6e17d7dafb81a0a7af61e869dcbfa0aa1e3fb | Ruby | Claire7514/exo_ruby | /exo_10.rb | UTF-8 | 47 | 2.5625 | 3 | [] | no_license | birth = gets.chomp.to_i
puts "#{2017 - birth}"
| true |
0bf33ec2d94e1d36e13ac947866ea0006baec44a | Ruby | mariusbutuc/nu-markup-calculator | /test/thesaurus_test.rb | UTF-8 | 399 | 2.609375 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/thesaurus'
class ThesaurusTest < Minitest::Test
def test_synonym_returns_nil_when_none_exists
thesaurus = Thesaurus.new(:no_synonym_here)
assert_nil thesaurus.synonym
end
def test_synonym_returns_expected_value_when_one_exists
thesaurus = Thesa... | true |
546b14843ade0676760f6ccd86bc0449fec5d661 | Ruby | erfan111/iust_ecommerce2 | /app/models/cart.rb | UTF-8 | 712 | 2.59375 | 3 | [] | no_license | ##
#* Cart database model
#* generated by scaffold
class Cart < ActiveRecord::Base
# attr_accessible :title, :body
## the following relations are described in project.rdoc
has_many :line_items , :dependent => :destroy
def add_product(product_id)
##
# the product is reformed into a line_item with quanti... | true |
a22cc0d0c58fdeac752f525da0365f636746cb70 | Ruby | seantarzy/ruby-enumerables-introduction-to-map-and-reduce-lab-nyc-web-111819 | /lib/my_code.rb | UTF-8 | 899 | 3.578125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # My Code here....
def map_to_negativize(source_array)
source_array.map do |num|
num * -1
end
end
def map_to_no_change(source_array)
source_array.map do |num|
num * 1
end
end
def map_to_double(source_array)
source_array.map do |num|
num * 2
end
end
def map_to_square(source_a... | true |
c09448a0ae1c2f236174f95ad0b48d37d94b0db1 | Ruby | nyx-a/stim | /src/b.structure.rb | UTF-8 | 3,457 | 3.1875 | 3 | [
"MIT"
] | permissive |
module B
def self.callablize object
case
when object.respond_to?(:call)
object
when object.respond_to?(:to_proc)
object.to_proc
when object.respond_to?(:to_sym)
object.to_sym.to_proc
else
raise "Can't make it callable #{object}(#{object.class})"
end
end
# force ca... | true |
7b47c033e2e479cae77cd1c24ff45621578f7788 | Ruby | leacoco/ops-Gems | /example_gem/test_greetings.rb | UTF-8 | 132 | 3.203125 | 3 | [] | no_license | require 'hola'
puts "This is a small ruby program that will great you my boy"
Hola.greetings
puts "Are you happy now"
puts "End"
| true |
7a4f538387e7f288b40daf7112b40884e5cc1b0d | Ruby | ChanceMims/ruby-enumerables-cartoon-collections-lab-austin-web-120919 | /cartoon_collections.rb | UTF-8 | 767 | 3.171875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarf_list)# code an argument here
# Your code here
dwarf_list.each_with_index{|my_dwarves, index| p "#{index + 1}.* #{my_dwarves}"}
end
def summon_captain_planet(planeteer_calls)# code an argument here
# Your code here
return planeteer_calls.map{|element_calls| p "#{element_calls.capital... | true |
a3acc748eb2dd554c115175b7e447a7688f41895 | Ruby | jjasghar/lita-motivate | /lib/lita/handlers/motivate.rb | UTF-8 | 826 | 2.765625 | 3 | [
"MIT"
] | permissive | module Lita
module Handlers
class Motivate < Handler
route(/^!(m|than(k|ks)) (.+)$/, :motivate, help: {
"!m USER" => "motivates the user.",
"!m thank(s) USER" => "motivates the user."
})
def motivate(request)
name = request.matches[0][2]
reque... | true |
ac7c8ffd223217f94eea3a969dbbf00e3f0cfc81 | Ruby | ashokkumar/toy-robot | /lib/location.rb | UTF-8 | 904 | 3.28125 | 3 | [] | no_license | require './lib/coordinate'
require './lib/direction'
require './lib/table_top'
class Location
def initialize(coordinate, direction, table_top)
@coordinate = coordinate
@direction = direction
@table_top = table_top
end
def move
new_location = new_location({coordinate: @direction.move(@coordinate)... | true |
34709637597bfe35dea3d94f68b368ca2c97a9f1 | Ruby | ekemi/ruby-advanced-class-methods-lab-onl01-seng-ft-032320 | /lib/song.rb | UTF-8 | 1,730 | 3.203125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist_name
@@all = []
def self.all
@@all
end
def save
self.class.all << self
end
def self.create
song = self.new
song.save
return song
end
def self.all
@@all
end
def self.new_by_name(string)
song = self.new
... | true |
96d009ce253087101e983e20bbed0268d3d50b9b | Ruby | DavidBarriga-Gomez/flash_cards | /runner.rb | UTF-8 | 1,782 | 3.828125 | 4 | [] | no_license | require './lib/card'
require './lib/turn'
require './lib/deck'
require './lib/round'
card_1 = Card.new("What is the capital of Alaska?", "Juneau", :Geography)
card_2 = Card.new("The Viking spacecraft sent back to Earth photographs and reports about the surface of which planet?", "Mars", :STEM)
card_3 = Card.new("Descr... | true |
d37342b4f5d0918245b2699b1e05630f2f96838c | Ruby | clalil/Ruby | /flow_control.rb | UTF-8 | 847 | 4.78125 | 5 | [] | no_license | #Write a method that takes a string as argument. The method should return a new, all-caps version of the string only if the string is longer than 10 characters.
def strings(response)
if response.length > 10
puts response.swapcase
else
puts response
end
end
strings("thisisalongsentence")
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.