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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b11c47e6c061427db410f01c254b65e9955167f5 | Ruby | pipevera/tallerejercicios | /notas.rb | UTF-8 | 611 | 3.46875 | 3 | [] | no_license | file = File.open('notas.txt', 'r')
content = file.readlines
file.close
class Student
attr_accessor :nombre, :nota1, :nota2, :nota3
def initialize(nombre, nota1 = 0, nota2 = 0, nota3 = 0)
@nombre = nombre
@nota1 = nota1
@nota2 = nota2
@nota3 = nota3
end
end
def promedio_alumno(registros)
regis... | true |
11233585dbd147a826d05a53e17a3c861c2b2e41 | Ruby | phillips848676/rottenpotatoes-rails-intro | /app/models/movie.rb | UTF-8 | 402 | 2.546875 | 3 | [] | no_license | class Movie < ActiveRecord::Base
def self.individualRatings
return Movie.distinct.pluck(:rating)
end
def self.with_ratings diffRatings
Movie.where(rating: diffRatings)
end
def self.sort_diff isTitle
if (isTitle )
Movie.order(:title)
elsif (... | true |
a0ea5934810f8cc8a1af706279822247b88643e4 | Ruby | lxyzzhao/ttf2png | /ttf2png.rb | UTF-8 | 906 | 2.9375 | 3 | [] | no_license | # coding: utf-8
# USAGE: ruby ttf2png.rb
#//-------------------------------------------
# Note:
#//-------------------------------------------
# Unicode(code point):
# U+3042 == "あ" == "\u3042" == \u{3042}
# How to get code point:
# "あ".unpack( "U*" ).first.to_s(16) #=> "3042"
# "あ".encode( "UTF-8" ).ord.to_s(16) #... | true |
37873c33551a9d2f53f83e3e9bbecb44c1a41180 | Ruby | peel3r/till_kata | /lib/till.rb | UTF-8 | 697 | 2.78125 | 3 | [] | no_license | require_relative 'menu'
require_relative 'order'
require_relative 'payment'
require_relative 'receipit'
class Till
include Menu
attr_reader :order, :tax, :receipt
def initialize
new_order
load_price_list
@tax = 8.64
end
def new_order
@order = Order.new
end
def current_order
order... | true |
216c0cac19c8deefc06117b924127ac4221c2a38 | Ruby | fkshom/pork | /lib/pork/repository.rb | UTF-8 | 10,430 | 2.875 | 3 | [] | no_license | require 'ipaddr'
require 'forwardable'
class Pork::RepositoryFileLoader
def initialize(filename)
@filename = filename
@meta = nil
@sep = nil
@data = []
@meta, @sep, @data = _load(@filename)
end
def _load(filename)
tmp = File.readlines(filename)
if sep_index = tmp.find_index{|line| li... | true |
e47f41fb1de21f7979ecd21ed04c3a8e6186f4c8 | Ruby | ssmadhan/coding_exercises | /mult_nums.rb | UTF-8 | 473 | 3.3125 | 3 | [] | no_license | #!/Users/smadhan/.rvm/rubies/ruby-2.3.1/bin/ruby
def multiply(num1, num2)
return 0 if num1.to_i == 0 || num2.to_i == 0
num2_arr = num2.split('')
result = 0
mult_factor = 10
for i in 0..num2_arr.length-1
temp = num2_arr[i].to_i*num1.to_i
if i > 0
temp = temp*mult_fa... | true |
cbc44e1e33164f6aba4a4fd6bea8d73ff7e95ca6 | Ruby | georgepianka/ttt-game-status-v-000 | /lib/game_status.rb | UTF-8 | 1,037 | 3.6875 | 4 | [] | no_license | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], #top_horizontal
[3,4,5], #middle_horizontal
[6,7,8], #bottom_horizontal
[0,3,6], #left_vertical
[1,4,7], #middle_veritcal
[2,5,8], #right... | true |
f169946189762ef2f037819832fef17c677d6ca6 | Ruby | petergoldstein/dalli | /test/helpers/memcached.rb | UTF-8 | 3,617 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require 'socket'
require_relative '../utils/certificate_generator'
require_relative '../utils/memcached_manager'
require_relative '../utils/memcached_mock'
module Memcached
module Helper
# Forks the current process and starts a new mock Memcached server on
# port 22122.
#
... | true |
ec77008df07237b2522a6bc220e101159eb1fef6 | Ruby | misstonbon/SlackAPI | /lib/slack_api_wrapper.rb | UTF-8 | 1,149 | 2.625 | 3 | [] | no_license | require 'httparty'
class SlackApiWrapper
BASE_URL = "https://slack.com/api/"
TOKEN = ENV["SLACK_TOKEN"]
def self.list_channels
url = BASE_URL + "channels.list?token=#{TOKEN}" +
"&exclude_archived=1"
data = HTTParty.get(url)
if data["channels"]
my_channels = data["channels"].map do |chan... | true |
b0cb5b73b30c4f918704f84c8cf28df47a6c5228 | Ruby | gameda/prfOperativos | /Proceso.rb | UTF-8 | 1,328 | 2.78125 | 3 | [] | no_license | class Proceso
def initialize(id, cantBytes, tamMarcos)
@id = id
@cantBytes = Integer(cantBytes)
if @cantBytes <= 0
@cantBytes = 1
end
@cantPaginas = @cantBytes.fdiv(Integer(tamMarcos)).ceil
@tablaPaginas = Array.new()
@marcosRealAsig = 0
@marcosSwapAsig = 0
@faultsCausados = 0
end
#Metodos... | true |
9467d5d021ab75e1a1b5574874235c057299f9b4 | Ruby | 37CARE/S3_J4_Morpion_POO | /app.rb | UTF-8 | 5,080 | 2.578125 | 3 | [] | no_license | require 'bundler'
require 'colorize'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
#LE CODE COMMENCE SON EXECUTION ICI ET APPEL TOUTES LES CLASS
m = Menu.new
b = Board.new
#ON APPEL LES JOUEURS ET ON LEUR ATTRIBU CHACUN UN MARQUEUR
p1 = Player.new
p1.marker = "X".colorize(:green)
p2 = P... | true |
15684f8f0d339749051366c681054caf13eaaddf | Ruby | Xaavvii/oxford-comma-nyc-web-career-040119 | /lib/oxford_comma.rb | UTF-8 | 680 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array = ["fiddleheads","okra","kohlrabi"])
# puts "fiddleheads, okra, and kohlrabi"
# puts " and %{arg}" % { :arg => array[array.size - 1] }
# puts " and %{arg}" % { :arg => array[array.length - 1] }
# puts " and %{arg}" % { :arg => array[array.count - 1] }
# puts " and %{arg}" % { :arg => array.l... | true |
c79eb34f705bb716f2524332336481a954919aac | Ruby | etdev/algorithms | /0_code_wars/multiply.rb | UTF-8 | 110 | 2.671875 | 3 | [
"MIT"
] | permissive | # http://www.codewars.com/kata/50654ddff44f800200000004
# --- iteration 1 ---
def multiply(a, b)
a * b
end
| true |
93a45cb6434745c1774006b867dd5798b0226f41 | Ruby | SHiroaki/Ruby | /prac/while_until.rb | UTF-8 | 476 | 3.71875 | 4 | [] | no_license | # coding: utf-8
sum = 0
i = 1
while sum < 50 # sumが50を超えるときのiはよくわからない
sum += i
i += 1
end
print sum, "\n"
# until
# while文と見た目は同じだが判定が逆になる
# whileは条件が成立している間繰り返すが、untilは条件が成立するまで繰り返す
sum = 0
i = 1
until sum >= 50
sum += 1
i += 1
end
print sum,"\n"
#while文で書き直すと
while !(sum >= 50)
sum += 1
i += 1
end
p... | true |
843c7ab6fd36c7d236c11357c6140191405abcab | Ruby | Protetiko/event_sourced | /examples/_common/events.rb | UTF-8 | 809 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
require 'event_sourced/event'
class InventoryItemCreated < EventSourced::Event
def to_s
"#{self.class.name} - Created"
end
end
class ItemDescriptionSet < EventSourced::Event
field :description
builder do |data|
self.description = data[:description]
end
def to_s
... | true |
75e704091a4e784a5b22370f3987f59524f6cb30 | Ruby | kenderb/RSpec_practice | /sandwich/lib/coffee_class.rb | UTF-8 | 178 | 3.1875 | 3 | [] | no_license | class Coffee
def ingredients
@ingredients ||= []
end
def add(ingredient)
ingredients << ingredient
end
def price
1.00 + ingredients.size * 0.26
end
end
| true |
426d4cb82389b3b75ec22619b204cac732420f37 | Ruby | danielsdeleo/libsvm-ruby-swig | /libsvm-2.88/ruby/svm_test.rb | UTF-8 | 2,832 | 2.875 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'svm'
Svmc::info_on = 1 # turn on the built-in loggin, default to 0 (off)
# a three-class problem
labels = [0, 1, 1, 2]
samples = [[0, 0], [0, 1], [1, 0], [1, 1]]
problem = Problem.new(labels, samples)
size = samples.size
kernels = [LINEAR, POLY, RBF, SIGMOID]
kname = {LINEAR=>'linear',PO... | true |
c6be1fd45318dd9ade33920c05e7b0ae37aee4ac | Ruby | ginnyfahs/whiteboarding-practice | /ruby/strings/remove_duplicates.rb | UTF-8 | 495 | 3.96875 | 4 | [] | no_license | # solve with hash
def remove_dupes(str)
letters_hash = {}
str.each_char do |character|
if !letters_hash[character]
letters_hash[character] = 1
end
end
return letters_hash.keys.join
end
# solve with array
def remove_dupes(str)
letters_arr = []
str.each_char do |character|
... | true |
3fcd534eb7f9e94f91e6dc0eba730eb2e8305c30 | Ruby | bodgix/wiki-top-words | /spec/unit/wiki_page_spec.rb | UTF-8 | 3,120 | 2.796875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../spec_helper'
require_relative '../../lib/wiki_page'
describe WikiTopWords::WikiPage do
let(:page_id) { 42 }
let(:subject) { described_class.new(page_id) }
let(:content) do
File.read("spec/data/wikipedia_#{page_id}.json")
end
describe '#new' do
it 'i... | true |
17854a57aab925346d1659d0ecee52be22e70783 | Ruby | copiousfreetime/yacl | /spec/define/cli/parser_spec.rb | UTF-8 | 2,488 | 2.703125 | 3 | [
"ISC"
] | permissive | require 'yacl/define/cli/parser'
module Yacl::Spec::Define
class OptionsForParserTest < ::Yacl::Define::Cli::Options
opt 'pipeline.dir', :long => 'pipeline-dir', :short => 'd', :description => "The pipeline directory we are using", :cast => :string
opt 'timelimit' , :long => 'time-limit', :short => 't', ... | true |
2a717eb2978de3c76b331ff358f1a4b3a8f82793 | Ruby | juliusdelta/sep-assignments | /02-algorithms/02-algorithms-searching/binary_search_recursive.rb | UTF-8 | 370 | 3.4375 | 3 | [] | no_license | def recursive_binary_search(collection, value, low=0, high=nil)
if high == nil
high = collection.length - 1
end
mid = (low + high) / 2
if collection[mid] == value
return mid
elsif collection[mid] < value
recursive_binary_search(collection, value, (mid + 1), high)
else
recursive_binary_sea... | true |
9b0ab185add2a2a0142b5a03bb5685d5b18a9415 | Ruby | allure-framework/allure-ruby | /allure-ruby-commons/lib/allure_ruby_commons/file_writer.rb | UTF-8 | 2,540 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
module Allure
# Allure result file writer
class FileWriter
include JsonHelper
# @return [String] test result suffix
TEST_RESULT_SUFFIX = "-result.json"
# @return [String] test result container suffix
TEST_RESULT_CONTAINER_SUFFIX = "-container.json"
# @return [... | true |
92dff7a9eabe79e2b3e309546aa42c9e82e373ce | Ruby | DanielAKidd/LaunchSchool | /intro/methods.rb | UTF-8 | 536 | 4.5625 | 5 | [] | no_license | # exercise 1
def greeting name
puts "Hello #{name}"
end
# puts greeting "Daniel"
# exercise 2
# 1. 2
# 2. nil
# 3. "Joe"
# 4. "four"
# 5. nil
# exercise 3
def multiply n1, n2
n1 * n2
end
# puts multiply 3, 4
# exercise 4
# Nothing is returned
# exercise 5
def scream words
words = words + "!!!!"
puts words... | true |
1e6f6955bdb4d0ae37b3fdf2c133b44d2c8020b9 | Ruby | zarigani/todo_stateful_template | /lib/label_msg_form_builder.rb | UTF-8 | 3,092 | 2.578125 | 3 | [] | no_license | # form_forに:builder => LabelMsgFormBuilderオプションを設定することで、以下の機能が発揮される
# ===ラベル付きエラーメッセージ付きのフォームを生成する
#
# <% form_for @slip do |f| %>
# <p>
# <%= f.label :number %>
# <%= f.text_field :number %>
# <%= f.error_messages_on :number %>
# </p>
# <% end %>
#
# :builder=>LabelMsgFormBu... | true |
02c8da353adf89fd2d5b8187262c1ca479d08dc9 | Ruby | schatell/ruby_OOP_TOP | /tic_tac_toe/lib/tic_tac_toe.rb | UTF-8 | 6,146 | 4 | 4 | [] | no_license | class PlayScreen
attr_accessor :board
#Initialize a 2d array containing only nil value#
def initialize
@board = [[" ", " ", " "],[" ", " ", " "],[" ", " ", " "]]
end
#The display method display the @board array on a grid.#
def display
puts "Column " + "0 1 2"
puts "Row 0 " + " " +... | true |
d4c66e511867bcb643c0e339e0eed44a4fb6d7ad | Ruby | gemgento/gemgento | /lib/gemgento/api/soap/catalog/product_attribute_set.rb | UTF-8 | 2,370 | 2.578125 | 3 | [] | no_license | module Gemgento
module API
module SOAP
module Catalog
class ProductAttributeSet
# Pull all Magento ProductAttributeSet data into Gemgento.
#
# @return [Void]
def self.fetch_all
response = list
if response.success?
respon... | true |
0807d1e3e1474c517fda87ae8d5e956feb5cb794 | Ruby | gitvar/intro-to-programming-with-ruby | /loops-and-iterators/exercise_1.rb | UTF-8 | 114 | 3.78125 | 4 | [] | no_license | # exercise_1.rb
x = [1, 2, 3, 4, 5]
x.each do |a|
a + 1
end
# Answer: The each method returns: [1, 2, 3, 4, 5] | true |
c9e02cedc9f9cefa9942955bb06021040ad926dd | Ruby | BrianMehrman/EatMe | /app/helpers/meals_helper.rb | UTF-8 | 669 | 2.546875 | 3 | [] | no_license | module MealsHelper
def count_calories(meal)
total = 0
meal.consumptions.each do |consumption|
consumption.food.nutrition_facts.each do |fact|
# count the amount of Calories
if fact.definition.Tagname == 'ENERC_KCAL'
total += fact.value(consumption)#* consumption.measurement
... | true |
cf2e04d09d2e03ffd43af8b2d452a539ac4e3aef | Ruby | rishey/jsracer2 | /app/controllers/index.rb | UTF-8 | 760 | 2.734375 | 3 | [] | no_license | get '/' do
# Look in app/views/index.erb
erb :index
end
###### posts
post '/' do
if params["p1_init"].downcase == params["p2_init"].downcase
#can't play each other. throw error back to home
@error = "Initials Can't Match"
erb :index
elsif params["p1_init"].empty? || params["p2_init"].empty?
@e... | true |
f73134d40ebc89da551df0e610a17c9d9cc03dd6 | Ruby | DaHuO/P2PChat_neat | /start_server.rb | UTF-8 | 620 | 3.078125 | 3 | [] | no_license | load "lib/server.rb"
Erroinfo = "command line parameter not fit:\n" +
"\t'--boot [Integer Identifier] [port]' for start\n" +
"\t'--bootstrap [port] --id [Integer Identifier] [port]' for join\n"
if ARGV.length == 3
if ARGV[0] == "--boot"
Port = ARGV[2].to_i
Identifier = ARGV[1].to_i
para = [Identifier, Port]... | true |
94fd181d66a0dcf711ead704a890bede2af61819 | Ruby | 1gor/eventory | /lib/eventory/aggregate_repository.rb | UTF-8 | 1,004 | 2.515625 | 3 | [
"MIT"
] | permissive | module Eventory
class AggregateRepository
def initialize(event_store, aggregate_class)
@event_store = event_store
@aggregate_class = aggregate_class
end
def load(aggregate_id)
recorded_events = @event_store.read_stream_events(aggregate_id)
events = recorded_events.map(&:data)
... | true |
0ae793db3d5175a290d7a07cf45be9488f260b08 | Ruby | samblenny/guilib | /src/kbd_blit_codegen.rb | UTF-8 | 953 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #!/usr/bin/ruby
# Copyright (c) 2020 Sam Blenny
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# This generates blit patterns for building a blank onscreen keyboard
# RLE encodings for top row, letter keys, and spacebar row
fkey = [3, 65, 1, 65, 68, 65, 1, 65, 3]
letters = [3] + [32, 1]*4 + [32, 2, 32] + [1, 32]*4 + [... | true |
50ffaabd0bb7b22bb3ee18a0ceed43cda7c6c5e7 | Ruby | dkaushal99352/devbootcamp | /rubyprogs/RPN.rb | UTF-8 | 2,030 | 4.65625 | 5 | [] | no_license |
my favorite solution for Fibonacci Numbers:
def is_fibonacci?(i, current = 1, before = 0)
return true if current == i || i == 0
return false if current > i
is_fibonacci?(i, current + before, current)
end
REASON : Recursion comes in handy in this situation - by passing 'current + before' as a parameter to th... | true |
23f587c77592ff1c5c97f18a23e7fced20b01f91 | Ruby | Shintouney/temple | /app/extensions/csv_exporter/subscriptions.rb | UTF-8 | 1,812 | 2.578125 | 3 | [] | no_license | module CSVExporter
class Subscriptions < Base
private
def headers(csv)
csv.headers do |csv_header|
user_columns = %i(id email firstname lastname card_reference)
subscription_columns = %i(state start_at end_at created_at replaced_date origin_location)
subscription_plan_columns = ... | true |
203521fa4217424875c24dd691a6418c12d03c55 | Ruby | MrMicrowaveOven/Treehugger | /spec/treehugger_spec.rb | UTF-8 | 2,884 | 3.578125 | 4 | [] | no_license | require_relative '../lib/treehugger.rb'
describe "Treehugger" do
it "can output the default value with `.`" do
expect { Treehugger.new(".") }.to output('0').to_stdout
end
it "can output several times with `..`" do
expect { Treehugger.new("..") }.to output('00').to_stdout
end
it "can take input with `... | true |
66a9a16cb14dce53afc43c96004c4b7dead8df54 | Ruby | PhilippePerret/WriterToolbox | /objet/quiz/lib/required/quiz/question/helper.rb | UTF-8 | 7,328 | 2.71875 | 3 | [] | no_license | # encoding: UTF-8
=begin
Module de méthodes pour l'affichage des questions du questionnaire
=end
class Quiz
class Question
def evaluation?
@do_evaluation ||= begin
v = quiz.evaluation?
debug "Quiz::Question#evaluation? est #{v.inspect}"
v
end
end
def exergue_repons... | true |
49a6b85e8be4a07dd2f08d4d4160aa41dbf39602 | Ruby | muhammadzesshanshafqat/sinatra-mvc-lab-cb-000 | /app.rb | UTF-8 | 437 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
erb :user_input
end
post '/' do
test_input = "He was an old man who fished alone in a skiff in the Gulf Stream and he had gone eighty four days now without taking a fish"
user_input = params[:latinizer]
@latinizer = Pig... | true |
fec908bcaa45ab593e5974d73704396dbb52bb61 | Ruby | jackcooper1245/ruby-music-library-cli-online-web-sp-000 | /lib/genre.rb | UTF-8 | 442 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
extend Concerns::Findable
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def self.destroy_all
@@all.clear
end
def songs
@songs
end
def save
@@all << self
end
def self.create(name)
genre = self.new(name)
genre.save
genre
end... | true |
069d03e970aa20244825314252ced36facf58d71 | Ruby | badascii/pcs_exercises | /scrabble.rb | UTF-8 | 847 | 3.90625 | 4 | [] | no_license | class Scrabble
# Defines a hash that holds Scrabble letter values
def self.letter_values
values_hash = {}
all_letters = [[ 1, 'a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't'],
[2, 'd', 'g'], [3, 'b', 'c', 'm', 'p'],
[4, 'f', 'h', 'v', 'w', 'y'], [5, 'k'],
... | true |
024670b40a9b80733d9e52a29d99ee5b1cb59e46 | Ruby | mcwaller422/Intro_to_Ruby | /Hashes/Exercises/ex2.rb | UTF-8 | 365 | 4 | 4 | [] | no_license | #What is the difference between merge and merge! ?
#merge returns a new hash without modifying the original, whereas merge! is destructive.
grades = { math: "B" , science: "B", english: "A"}
grades2 = { art: "A" , music: "A", history: "A"}
grades.merge(grades2)
#doesnt modify the original hash
p grades
grades_tot... | true |
12600ece1e1d27aca40f06669a38c4bf430dfec8 | Ruby | Devtron3737/project_library | /project_euler/04_largest_palindrome.rb | UTF-8 | 449 | 3.84375 | 4 | [] | no_license | #find the largest palindrome made from two 3 digit numbers
def palindrome?(wrd)
if wrd.to_s.reverse == wrd.to_s
return true
end
return false
end
largest = 0
arr1 = (1..999).to_a
arr2 = (1..999).to_a
i = 1
y = 1
while i < arr1.length - 1
while y < arr2.length - 1
if palindrome?(arr1[i] * arr2[y]) == true
... | true |
6edcbd4bfc09eda0b32a6b0038f744c13abef954 | Ruby | roggeo/samples-ruby-for-beginner | /if_else_conditional.rb | UTF-8 | 367 | 3.96875 | 4 | [] | no_license | #!/usr/bin/ruby
age = 17
if age >= 16
puts age.to_s + " is an allowed age to drive."
elsif age < 16 and age != 0
puts "Age is less than 16. Not allowed to drive."
else
puts "I can't guess the age."
end
# Using unlelss keyword
age_to_drink = 21
unless age <= age_to_drink
puts "You can drink alcohol."
... | true |
11d2c9162c64d48bff0d1219c65ae0662f7e021c | Ruby | jonhinson/advent_of_code | /2020/4/part_1.rb | UTF-8 | 192 | 2.734375 | 3 | [] | no_license | passports = File.read('input.txt')
valid = 0
passports.split("\n\n").each do |passport|
valid += 1 if (passport.split(/\s/).map { |s| s.split(':').first } - ['cid']).size == 7
end
puts valid | true |
f3da1c2be28264c05ac3f323facae1065e56b853 | Ruby | kanhaolong/rubyexercise-salesmmachine.io | /lib/csv/Integration_organization.rb | UTF-8 | 4,084 | 2.65625 | 3 | [] | no_license | require 'httparty'
require 'json'
require_relative 'csv_importer'
require 'csv'
require 'open-uri'
require 'rest-client'
class Organization
def addOrganization(cName, options = {},api_token)
uri = URI.parse('https://api.pipedrive.com/v1/organizations?api_token=' + api_token.to_s)
if (!options.nil?)
opt... | true |
4ed2a905599d7d9d5e33e95f6ac53b4573e8304f | Ruby | luiswitz/simple_list | /app.rb | UTF-8 | 330 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
class App
def initialize(lists:)
@lists = lists
end
def run
@lists.each do |list|
puts '-' * 50
receipt = receipt_processor.process(list)
receipt.output_receipt
end
end
private
def receipt_processor
ReceiptProcessorServiceFactory.new.build
... | true |
9eed595228ba50f007b05307255586dc10cd6b28 | Ruby | talita-moraes/Teste-Automatizado_Ruby | /features/support/hooks/hooks.rb | UTF-8 | 770 | 2.5625 | 3 | [] | no_license | Before do |scenario|
@time = Time.new
@data = @time.strftime('%d/%m/%Y')
@nome_cenario = scenario.name
puts @nome_cenario
unless scenario.name == 'Tentativa De Login'
@email = CONFIG['email']
@senha = CONFIG['senha']
end
end
After do |scenario|
scenario_name ... | true |
dfc1bd713430a2006fd4887992f2d78218b92d64 | Ruby | kevindigg/odin_project | /2-Ruby/2-Advanced/enumerable-prj2/enumerable.rb | UTF-8 | 674 | 3.28125 | 3 | [] | no_license | module Enumerable
def my_each
return self unless block_given?
for i in self
yield i
end
self
end
def my_each_with_index
return self unless block_given?
i = 0
while i < self.count
yield self[i], i
i += 1
end
end
def my_select
return self unless block_given?
results = []
my_each {... | true |
5cc2ba789f22f01bb85580978eaab997b9b681cf | Ruby | JeonSANG/Itanji-subject | /vending_machine.rb | UTF-8 | 5,277 | 4 | 4 | [] | no_license | #Itanji subject
class VendingMachine
#自動販売機のInitialization
def initialize(product0, product1, product2)
@products = [product0, product1, product2] #ジュースのarray
@sum = 0 #投入金額の総計
@totalSale = 0 #売り上げ金額
end
#情報の出力
def prtInfo
... | true |
faa30ea9bad04bb351cfad330cc45386ab3c3c28 | Ruby | wangray/ctf_dump | /KasperskyIAP16/stegano/kaspersky_stegano.rb | UTF-8 | 261 | 2.71875 | 3 | [] | no_license | require 'wav-file'
wav = open("steg.wav")
format = WavFile::readFormat(wav)
chunk = WavFile::readDataChunk(wav)
puts format
puts chunk
wavs = chunk.data.unpack('s*')
lsb = wavs.map{|sample| sample[0]}.join
flag = lsb[1..100]
puts [flag].pack('b*')
wav.close
| true |
468ca9635c01c81d41031b40cd7e7a716d24022f | Ruby | AlvondiRLJ/cursoRubyPuro | /mission_array.rb | UTF-8 | 298 | 3.96875 | 4 | [] | no_license | array = []
puts "Enter the first value: "
array[0] = gets.chomp.to_i
puts "Enter the second value: "
array[1] = gets.chomp.to_i
puts "Enter the third value: "
array[2] = gets.chomp.to_i
puts "Original array#{array}"
array.each do |number|
puts "The number #{number} at 2 is #{number**2}"
end | true |
6a047fc134b1eaa0bd5765c8c071d335fbdf6fc4 | Ruby | Sid-ah/hk-bc | /database-drill-many-to-many-schema-challenge/spec/user_spec.rb | UTF-8 | 2,265 | 2.515625 | 3 | [] | no_license | require_relative 'spec_helper'
describe User do
let(:user) { User.new(email: 'username@domain.com', username: 'superuser') }
it 'has an email address' do
expect(user.email).to eq 'username@domain.com'
end
it 'has a username' do
expect(user.username).to eq 'superuser'
end
describe 'reviewing prod... | true |
ed30d0bf35718af23d0b6326bc3ab7cb0bc27ed5 | Ruby | Angeru/Quipu_ruby | /spec/02b_spec.rb | UTF-8 | 409 | 2.75 | 3 | [] | no_license | require './02/main2.rb'
RSpec.describe Main02b, "Ejercicio 2 B" do
it "debe parsear los datos" do
result = Main02b.extract_data '1-9 x: xwjgxtmrzxzmkx'
expected = {:end=>9, :letter=>"x", :pass=>"xwjgxtmrzxzmkx", :start=>1}
expect(result).to eq(expected)
end
it "debe dar el resulta... | true |
bdf630e39638a75d1588bd66e0a7fe8ee47a959f | Ruby | jcasimir/jscontact_live | /app/models/printer.rb | UTF-8 | 850 | 2.6875 | 3 | [] | no_license | class Printer
def self.to_csv(input)
end
end
class Serializer
attr_accessor :klass
def klass
@klass ||= load_class
end
def self.serialize(input)
klass.serialize(input)
end
def load_class
SerializerToCVS
end
end
class SerializerToCSV
def self.serialize(input)
to_csv(input)
e... | true |
a86e1cac5342caad310e24a5505b561b96bea5ec | Ruby | Nero144/fizzbuzz | /oren_finard_obf2107.rb | UTF-8 | 447 | 3.03125 | 3 | [] | no_license | #Oren Finard obf2107
#Basic Ruby Script for COMS W3101
#Emily Stolfo
#Note: I know this is probably not the most efficient way to write this script
#But it is the most explicit, and I want to be sure this works
#Cheers!
i = 1
j = 101
while i < j
output = ""
if i % 15 == 0
print "Oren Finard\n"
el... | true |
92676c9a962b155df3829a7f0b1d6c310e8c0a5a | Ruby | david-holtkamp/kaizen | /app/facades/search_facade.rb | UTF-8 | 216 | 2.703125 | 3 | [] | no_license | class SearchFacade
attr_reader :sorted
def initialize(search_results)
@sorted = sort_results(search_results)
end
def sort_results(search_results)
search_results.sort_by(&:upvotes).reverse
end
end
| true |
94ea5c229bd99605b9fcada83c515e2064acc83a | Ruby | hillmandj/clrs-algorithms | /ch-3/code/fibonacci.rb | UTF-8 | 409 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
# Code for 3.2-7
# Mathematical Implementation
def fib(n)
phi = (1 + Math.sqrt(5)) / 2
conjugate = (1 - Math.sqrt(5)) / 2
(((phi ** n) - (conjugate ** n)) / Math.sqrt(5)).to_i
end
def fibonnaci_sequence(num: 100)
0.upto(num).each_with_object([]) { |n, o| o << fib(n) }
end
if __FILE__ ==... | true |
6bdd4e66beda90debdea765672bc2f5e79ebe49c | Ruby | el-doble/the-Odin-Project-Ruby-test-first-ruby | /02_calculator/spec/lib/calculator.rb | UTF-8 | 278 | 3.703125 | 4 | [] | no_license | def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
def sum(array)
array.empty? ? 0 : array.reduce(:+)
end
def multiply(*numbers)
numbers.reduce(:*)
end
def power(a, b)
a ** b
end
def factorial(number)
number == 0 ? 1 : (1..number).reduce(:*)
end
puts factorial(0) | true |
c63a73947b477d62c1b22a3c0ede037c8b1c0046 | Ruby | pigate/ruby_learnings | /ex44.rb | UTF-8 | 1,305 | 3.921875 | 4 | [] | no_license | #implicit inheritance
class Parent
def implicit()
puts "Parent implicit()"
end
def override()
puts "Parent override()"
end
def altered()
puts "Parent altered()"
end
end
class Child < Parent
def override()
puts "Child override()"
end
def altered()
puts "Ch... | true |
88e40c7ebc5fbfa5ce8d633df11cb17c2837a3a8 | Ruby | pharhadnadi/kyubits | /hackerrank/game/hourrank17/gcd_matrix/gcd5.rb | UTF-8 | 1,125 | 3.28125 | 3 | [] | no_license | #!/bin/ruby
n, m, q = gets.strip.split(' ')
n = n.to_i
m = m.to_i
q = q.to_i
a = gets.strip
a = a.split(' ').map(&:to_i)
b = gets.strip
b = b.split(' ').map(&:to_i)
@set_hsh = {}
@ary = []
r_low = c_low = 1.0/0
r_high = c_high = -1.0/0
require 'set'
for a0 in (0..q-1)
r1, c1, r2, c2 = gets.strip.split(' ')
r1 =... | true |
a438c5501a56329535bda5e26ceb0cd59ed70daa | Ruby | fenixchen/rubystudy | /procevent.rb | UTF-8 | 4,549 | 2.546875 | 3 | [] | no_license | #!/usr/bin/ruby -w
PRINTF_START_MAGIC=0x37210000
PRINTF_NORMAL_EVENT = 0
PRINTF_EVENT_IN_PROGRESS = 1
PRINTF_EVENT_DONE = 2
@printf_len = 0
@printf_str = ""
def parsePrintfEvent(event)
if event & 0xFFFF0000 == PRINTF_START_MAGIC
@printf_len = event & ~PRINTF_START_MAGIC
@printf_str = ""
... | true |
5cdfd60fa4aaedf9edb25d181cbecd75dd529e54 | Ruby | stevepentler/ruby-exercises-1 | /command-query/student.rb | UTF-8 | 270 | 3.015625 | 3 | [
"MIT"
] | permissive | class Student
GRADES = %w(F D C B A)
def initialize
@grade_index = 2
end
def study
@grade_index += 1 unless @grade_index == 4
end
def slack_off
@grade_index -= 1 unless @grade_index == 0
end
def grade
GRADES[@grade_index]
end
end
| true |
9136b1acb83fc82884a6bb00b939a86b79c08bf0 | Ruby | KJeffree/PDA_Katherine_Jeffree | /PDA_Static_and_Dynamic_Task_A/spec/testing_task_2_spec.rb | UTF-8 | 862 | 3.21875 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../card.rb')
require_relative('../testing_task_2.rb')
class TestCard < MiniTest::Test
def setup()
@card1 = Card.new('spade', 2)
@card2 = Card.new('diamond', 1)
@card3 = Card.new('heart', 8)
@card4 = Card.new('club', 5)
@cards =... | true |
02c7e69582e75f404270bd2b9d0e6969cc8a0ca2 | Ruby | Andre220503/Ruby-Andre | /clase2/ejercicio05.rb | UTF-8 | 344 | 3.296875 | 3 | [] | no_license | #Imprimir 3 veces un mensaje
#Primero, definimos un método
#Método(Variables)
def imprimir_mensaje(mensaje)
puts mensaje
end
#La variable contiene nuestro valor de interés
mensaje = "Prueba de impresión multiple"
#Se llama al método tres veces
imprimir_mensaje(mensaje)
imprimir_mensaje(mensaje)
imprim... | true |
c786aecd4cf2dc3beef33e858af75406529a7b72 | Ruby | nagaseshadri/puppet-vagrant-oc11.1 | /modules/forge/easy_type/lib/easy_type/validators.rb | UTF-8 | 1,537 | 2.8125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
#
#
# Define all common validators available for all types
#
module EasyType
STRING_OF_DIGITS = /^\d+$/
#
# Contains a set of generic validators to be used in any custo type
#
module Validators
##
#
# This validator validates if a name is free of whitespace and not empty. To use ... | true |
aef4c6a9c919a6880bb05acdfa4ed550db1c8821 | Ruby | travis-ci/travis.rb | /lib/travis/cli/setup/service.rb | UTF-8 | 2,454 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'travis/cli/setup'
module Travis
module CLI
class Setup
class Service
def self.normalized_name(string)
string.to_s.downcase.gsub(/[^a-z\d]/, '')
end
def self.description(description = nil)
@description ||= ""
@description = description if descr... | true |
eb4cb53a02abf9e19cf907d0cddcdfa0b7f48cba | Ruby | 5shadesofr3d/Ruby-Multithreaded-Sort | /timed_sort.rb | UTF-8 | 3,111 | 3.125 | 3 | [] | no_license | require 'test/unit'
require_relative 'merge'
require_relative 'io_controller'
class TimedMultiSort
include Test::Unit::Assertions
#max_t is time in seconds
def initialize(max_t)
assert max_t.is_a? Numeric
assert max_t > 0
@max_t = max_t
assert @max_t.is_a? Numeric
assert @max_t > 0
end
... | true |
a1320a70f62c5d2ca51b661be985f7f038759ff1 | Ruby | vamsipavanmahesh/data_structures | /delete_at_beginning_linked_list.rb | UTF-8 | 327 | 3.09375 | 3 | [] | no_license | require_relative "./utils/insert_helper"
class Node
attr_accessor :data, :next
end
def delete_at_beginning(head)
return unless head
head.next
end
head = insert_at_beginning(nil, 20)
head = insert_at_beginning(head, 30)
head = insert_at_beginning(head, 40)
head = delete_at_beginning(head)
traverse_linked_lis... | true |
5edfc54b29e18134519dbd1ce0864c38c8bcd166 | Ruby | jsbrinkley/FoodCrumbs | /releases/20140530205747/app/models/get_restaurant_list.rb | UTF-8 | 622 | 2.546875 | 3 | [] | no_license | class GetRestaurantList < ActiveRecord::Base
#this class is composed of all the primary methods of the other methods. We will access these other methods
#with the use of a helper
def self.get_google_maps(params)
return GetRestaurantListHelper.get_google_maps(params)
end
# Returns the route boxes resp... | true |
d77c1fca380f16082f85760e2d93add91cfc50ef | Ruby | absarora/phase_0_unit_2 | /week_4/1_mathy_ruby_intro/easy_add_it_up/my_solution.rb | UTF-8 | 2,078 | 4.15625 | 4 | [] | no_license | # U2.W4: Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge [by myself].
# 1. Pseudocode
# ----------------------------------------
# What is the input?
# The ... | true |
975b77602397999d5e254689c3b523712ad20e5a | Ruby | ftBessmann/phase-0 | /phase-0/week-6/nested_data_solution.rb | UTF-8 | 2,781 | 4.03125 | 4 | [
"MIT"
] | permissive | # RELEASE 2: NESTED STRUCTURE GOLF
# Hole 1
# Target element: "FORE"
array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]]
# attempts: 1
# ============================================================
p array[1][1][2][0]
# ============================================================
# Hole 2
# Target elemen... | true |
10dd1bf8781b137f25a0b6279b0c1e44f41b1cbe | Ruby | DouweM/mail_room | /lib/mail_room/delivery/letter_opener.rb | UTF-8 | 657 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'mail'
require 'letter_opener'
module MailRoom
module Delivery
# LetterOpener Delivery method
# @author Tony Pitale
class LetterOpener
# Build a new delivery, hold the mailbox configuration
# @param [MailRoom::Mailbox]
def initialize(mailbox)
@mailbox = mai... | true |
7316b679c8020ee0cbcb2803e1f258434d947bf6 | Ruby | chaoshades/rmvx-ebjb-party | /src/Windows/Window_Battle_Formations.rb | UTF-8 | 4,540 | 2.796875 | 3 | [
"MIT"
] | permissive | #===============================================================================
# ** Window_Battle_Formations
#------------------------------------------------------------------------------
# This window displays battle formations in the Formation screen
#==============================================================... | true |
5148c210f07226f2315b67bcc51a93e7bdb450c6 | Ruby | PreetBhadana/Training | /Ruby/Ruby_Practice/FIle IO Practice Programs/Open_FIle_in_Sysread_mode.rb | UTF-8 | 157 | 2.921875 | 3 | [] | no_license | #Open_FIle_in_Sysread_mode
afile = File.new("test.txt", "r")
if afile
content = afile.sysread(20)
puts content
else
puts"Unable to open file"
end | true |
0fa695898c8514d0f57005d3611dcb77a75e467e | Ruby | sharonw4769/05-tweet-shortener-lab | /tweet_shortener.rb | UTF-8 | 1,340 | 4.1875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def dictionary
dictionary = {
"too" => "2",
"to" => "2",
"two" =>"2",
"four" => "4",
"for" => "4",
"be" => "b",
"you" => "u",
"at" => "@",
"and" => "&"
}
end
def word_substituter(tweet)
tweet.split.collect do |word| #goes through each word and makes new array for the words
... | true |
a648a370f55eda5b9613dfbfb47f4b9395c624f6 | Ruby | lnarolski/mearm-stm32f429i | /Middlewares/ST/touchgfx/framework/tools/textconvert/lib/outputter.rb | UTF-8 | 4,348 | 2.765625 | 3 | [
"MIT"
] | permissive | ##############################################################################
# This file is part of the TouchGFX 4.15.0 distribution.
#
# <h2><center>© Copyright (c) 2020 STMicroelectronics.
# All rights reserved.</center></h2>
#
# This software component is licensed by ST under Ultimate Liberty license
# SLA004... | true |
7795ff8b2df463109c8d3d4f53d85f46072cf4c6 | Ruby | RyanScottLewis/punylinux | /lib/path/list.rb | UTF-8 | 534 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'list'
require 'path/printer'
module Path
class List < ::List
def print(**keywords)
Printer.call(self, **keywords)
end
def values
map(&:value)
end
def with_descriptions
self.class.new select(&:description?)
end
def value_justification
values.map(&:lengt... | true |
fb770b85af608c3b3d68eadea904904953b30e26 | Ruby | albertbahia/wdi_june_2014 | /w02/d02/ranjan_agarwal/GoT_inheritance/lib/knight.rb | UTF-8 | 713 | 3.28125 | 3 | [] | no_license | # require 'pry'
require_relative 'human.rb'
require_relative 'king.rb'
class Knight < Human
attr_reader(:sword_name,:king_name)
def initialize(name,house,sword_name)
super(name,house,strength)
@strength = 50
@sword_name = sword_name
@hp = 500
@king_name = nil
end
def pledge_loyalty(kings)
... | true |
8f5a84d4b94733da3f16b2828ab2497febe68523 | Ruby | finpin/sezame-sdk-ruby | /lib/sezame-sdk/response.rb | UTF-8 | 2,852 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | require 'rqrcode'
module Sezame
# defines a set of response classes
# to get easily response values
module Response
# generic response, expects the response as returned by the httpclient
class Generic
attr_reader :response
attr_reader :data
def initialize(response)
@response ... | true |
741c250aedbbb8cf5cb0d0d61032eceaa610102f | Ruby | ratdog19336/ttt-with-ai-project-v-000 | /bin/tictactoe | UTF-8 | 771 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
# bin/tictactoe
require_relative '../config/environment'
puts "Welcome to CLI Tic Tac Toe!"
puts "Please select the number of players:"
input = gets.strip
# def select_game_type(input)
if input == "0"
# PLAYERS = input
newgame = Game.new(player_1 = Players::Computer.new("X"), player_2 = P... | true |
58cb815ce7019b00fb14fe73dbb40301c7ee5fe6 | Ruby | imperio0001/aula-gama | /simple_number_test.rb | UTF-8 | 367 | 2.796875 | 3 | [] | no_license | require_relative "../simple_number"
require 'minitest/autorun'
class TestSimpleNumber < MiniTest::Unit::TestCase
def setup
@num = SimpleNumber.new(2)
end
def test_add
assert_equal(4, @num.add(2) )
end
def test_mult
assert_equal(4, @num.multiply(2) )
end
def test_add_not_even_number
as... | true |
28b348708a434a9fe0926df435c8f3942e3c058e | Ruby | ZhijieWang/Boon-api | /db/seeds.rb | UTF-8 | 3,053 | 2.53125 | 3 | [] | no_license | require 'pp'
# # This file should contain all the record creation needed to seed the database with its default values.
# # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
# #
# # Examples:
# #
# # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
... | true |
a0f5f61dba5b29dc1eb26afcc8507b1624d1bfd8 | Ruby | deadelf79/discord-pvp-bot | /data/bot_dyn.rb | UTF-8 | 623 | 2.578125 | 3 | [] | no_license | # data/bot_dyn.rb
# variables
@time_between_greetings = Config::Times.between_bot_greetings
@timecode_dir = "./data/bot_dyn"
@timecode_filename = "greetings_timecode"
# functions
def save_greetings_timecode
timecode = Time.now.to_i
open([@timecode_dir,'/',@timecode_filename].join, "w") { |io| io.write(timecode) }
e... | true |
7709b883607ab12d4a13d64ffd14e1750e13c84f | Ruby | mkorman/RubyStarWars | /basic-commands-and-system.rb | UTF-8 | 317 | 3.765625 | 4 | [] | no_license | puts 'Hello. What is your name?'
name = gets
# double quotes for string interpolation
puts "Hello #{name}"
puts 'We use backticks to run a command and get the result'
puts `time /t`
puts 'We use system to run a command, output the result to console, and get a boolean representing execution OK'
puts system 'time /t' | true |
631160b2f241be183c5206a4c859513674466a82 | Ruby | umarkotak/latihan | /soal6_2.rb | UTF-8 | 680 | 3.96875 | 4 | [] | no_license | class Point
attr_accessor :x
attr_accessor :y
def initialize(x, y)
@x = x
@y = y
end
def quadran
q = 1
if @x >= 0 && @y >= 0
q = 1
elsif @x < 0 && @y >= 0
q = 2
elsif @x < 0 && @y < 0
q = 3
elsif @x >= 0 && @y < 0
q = 4
end
q
end
def to_s
... | true |
f542f23b3a8509eb1d1d3edba8dc5bbc808980c2 | Ruby | Gary1690/ruby-oo-complex-objects-school-domain-nyc01-seng-ft-051120 | /lib/school.rb | UTF-8 | 414 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_accessor :roster
attr_reader :name
def initialize(name)
@roster = {}
@name = name
end
def add_student (student,grade)
if !@roster[grade]
@roster[grade] = []
end
@roster[grade] << student
end
def grade(grade)
... | true |
3520883bf46d77536d0da314d50d73fb8bf18800 | Ruby | YasminM11/hash-practice | /lib/exercises.rb | UTF-8 | 1,402 | 3.859375 | 4 | [] | no_license |
# This method will return an array of arrays.
# Each subarray will have strings which are anagrams of each other
# Time Complexity: o(n)
# Space Complexity: o(n)
def grouped_anagrams(strings)
# raise NotImplementedError, "Method hasn't been implemented yet!"
hash = {}
strings.each do |string|
sorted_string... | true |
b849d2db46badb693a142113b4643a52b9ea9077 | Ruby | sIeepy/project | /app/services/add_column.rb | UTF-8 | 1,494 | 2.671875 | 3 | [] | no_license | class AddColumn
def initialize(database, user, table)
@t_name = table[:table_name]
split(table)
@database = database
@user = user
end
def column_size(data, size)
if size == '' && (data == 'varchar' || data == 'char')
"#{data}(50)"
elsif size != '' && (data == 'varchar' || data == '... | true |
499708dd61b9ac3f69638a27af061493b8ca87f0 | Ruby | mika0616/Ruby | /ruby確認問題/lesson2.rb | UTF-8 | 70 | 2.515625 | 3 | [] | no_license | puts "私の名前は岡 実佳です。年齢は" + 25.to_s + "です。" | true |
9ea91d5d0a56f75fd1900cdbe9001f70cb351867 | Ruby | autosome-ru/motif_benchmarks | /motif_pseudo_roc/cli_args.rb | UTF-8 | 5,421 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'optparse'
def configure_peaks_format!(options, format)
chr_column, start_column, end_column, mode = format.split(',')
options[:peaks_format] = :custom
options[:peaks_format_config] = {chr_column: Integer(chr_column), start_column: Integer(start_column), end_column: Integer(end_column)}
if mode == 'ent... | true |
089346866c0f7df26284167cc36723210cb9668a | Ruby | lintci/laundromat | /app/models/provider/base.rb | UTF-8 | 296 | 2.609375 | 3 | [] | no_license | module Provider
class Base
delegate :to_sym, to: :name
def human_name
self.class.name.demodulize
end
def name
human_name.underscore
end
alias_method :to_s, :name
def abbr
raise NotImplementedError, 'Subclass must define abbr.'
end
end
end
| true |
396e77b37d0857272cc83d900c85582ed4566c72 | Ruby | vinimmelo/ruby-sample | /HeadFirstRuby/clips.rb | UTF-8 | 824 | 3.109375 | 3 | [
"MIT"
] | permissive | module AcceptsComments
def comments
@comments ||= []
end
def add_comment(comment)
comments << comment
end
end
class Clip
def play
puts "Playing #{object_id}..."
end
end
class Video < Clip
include AcceptsComments
attr_accessor :resolution
end
class Song < Clip
include AcceptsCom... | true |
aac7e7a953a7412b293c6d05d2af8fe72bd4ef3c | Ruby | joecorcoran/fur | /lib/fur/runtime/identifier.rb | UTF-8 | 269 | 2.546875 | 3 | [] | no_license | module Fur
module Runtime
class Identifier
attr_reader :value
def initialize(value)
@value = value
end
def inspect
@value
end
def call(scope)
scope.get(@value).call(scope)
end
end
end
end
| true |
573a0f20038518d4de8142ad1914e9e080553588 | Ruby | lawrencegust/rubytest | /ruby_test.rb | UTF-8 | 6,469 | 3.828125 | 4 | [] | no_license | # Instructions for this test:
# 1. Please clone this gist as a git repo locally
# 2. Create your own github repo called 'rubytest' (or a name of your choice) and add this repo as a new remote to the cloned repo
# 3. Edit this file to answer the questions, and push this file with answers back out to your own 'rubytest' ... | true |
9df09266b077864a4f93c240efd60bc13f3c3885 | Ruby | claudiocherubino/voldemort-ruby-client | /test.rb | UTF-8 | 1,477 | 3.125 | 3 | [] | no_license | require 'store_client'
s = StoreClient.new("test", [["localhost", "6666"]])
version = s.put("hello", "1")
raise "Invalid result" unless s.get("hello")[0][0] == "1"
s.put("hello", "2", version)
raise "Invalid result" unless s.get("hello")[0][0] == "2"
s.put("hello", "3")
raise "Invalid result" unless s.get("hel... | true |
7d18b2fed1380be4d439ad5e1cf823569ac1a4e2 | Ruby | sanjaya12090/RubyLearn | /input.rb | UTF-8 | 322 | 3.296875 | 3 | [] | no_license | puts "Please Enter your username"
name = gets.chomp
# chomp -> to String
print "Enter your password"
pass = gets.to_i
# to.i -> to Float
print "Enter first number (float)"
number1 = gets.to_f
# to.i -> to Integer
print "Enter second number (integer)"
number1 = gets.to_i
puts "Name : #{name}, Pass #{pass}... | true |
faff90156e26085cb8583abe7ef99111414add35 | Ruby | ballcheck/redistest | /redis_list_test.rb | UTF-8 | 1,595 | 2.859375 | 3 | [] | no_license | # TODO: work out how to clear redis each time recreate. We did this at YOUhome so take a look.
# TODO: could use Singleton design pattern for test server creation
require File.expand_path( "../test_helper.rb", __FILE__ )
require "timecop"
class RedisStringTest < RedisTestCase
def test_list_push_and_pop_and_len
... | true |
e0bccc7448acf2e01ea0358ede4bd41cc6b81e4f | Ruby | jeffrothwell/12-15-pgm-fun | /exercise.rb | UTF-8 | 1,106 | 3.421875 | 3 | [] | no_license | venues = [
{ address: "123 Main Street", city: "Toronto", wheelchair_accessible: true, capacity: 100 },
{ address: "567 Centre Street", city: "Toronto", wheelchair_accessible: false, capacity: 400 },
{ address: "9B Ontario Street", city: "Montreal", wheelchair_accessible: true, capacity: 1000 },
{ address: "56 Road Ave... | true |
5db19af78ce93daf208a1124361ba66d2bf6a04e | Ruby | Schwoisser/space-ship | /space/planetary/government_attribut.rb | UTF-8 | 584 | 2.515625 | 3 | [] | no_license |
# So mal en langer Kommentar auf deutsch.
# Planeten sollen unterschiedliche Attribute haben, die sich auf Markt, Militär,
# Bevölkerung, Zollbeschränkungen, Kultur, Produktion, Wissenschaft auswirken.
# Meine erste Inspiration dafür sind Hearts of Iron 2 : Arsenal of Democrazy und Civ 4
# Die Auswahl soll ähnlich g... | true |
edd912cdde964283e892f9260769956190d9755d | Ruby | karuna24s/beautyAppRuby | /runner.rb | UTF-8 | 222 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "./ui.rb"
require "./logic.rb"
@ui = UI.new
@logic = Logic.new
def run
beauty_choice = ""
@ui.welcome
beauty_choice = gets.chomp
@logic.question_logic(beauty_choice)
end
run
| true |
061b1480148edf59a3d1db57c6b90737c0edd2c3 | Ruby | cyberarm/cyberarm_engine | /lib/cyberarm_engine/bounding_box.rb | UTF-8 | 4,078 | 3.3125 | 3 | [
"MIT"
] | permissive | module CyberarmEngine
class BoundingBox
attr_accessor :min, :max
def initialize(*args)
case args.size
when 0
@min = Vector.new(0, 0, 0)
@max = Vector.new(0, 0, 0)
when 2
@min = args.first.clone
@max = args.last.clone
when 4
@min = Vector.new(arg... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.