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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
efde994eaea6b983ddbf5de2a1bb586c10ae21af | Ruby | aziks/Week1 | /caesarcypher.rb | UTF-8 | 650 | 3.828125 | 4 | [] | no_license | def solve_cipher(input, cipher)
input_array = input.split(//)
output_array = []
cipher = cipher.to_i
input_array.each do |letra|
if letra.ord < 97
numeroletra = letra.ord
numeroletra = numeroletra + 25
print numeroletra.chr
elsif letra.ord > 121
numeroletra = letra.ord
numeroletra ... | true |
85ec0cc8d7f00d7c6a621b6c05f550f7cb5cbac6 | Ruby | TheWeepingGorilla/dictionary | /lib/dictionary.rb | UTF-8 | 173 | 2.671875 | 3 | [] | no_license | class Term
def initialize (word, definition)
@word = word
@definition = definition
end
def word
@word
end
def definition
@definition
end
end
| true |
c7e085933b2ffbe972ee90106c90cfbcca60468c | Ruby | SuperKmar/Shootemup5-on-ruby-gosu | /MediumEnemy.rb | UTF-8 | 1,990 | 2.640625 | 3 | [] | no_license | # BasicEnemy.rb
#
# Copyright 2015 Kmar <kmar@kmar-Kubuntu>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
... | true |
36bf818ce07f5f438c635fabe7a79ba0beac2647 | Ruby | rwbarton/dcss_henzell | /src/henzell/commands.rb | UTF-8 | 1,604 | 2.765625 | 3 | [] | no_license | require 'henzell/learndb_query'
module Henzell
class Commands
def initialize(commands_file)
@commands_file = commands_file
@commands = { }
self.load
end
def include?(command_name)
@commands[command_name] || command_name == '??'
end
def learndb_query(arguments)
[0, ... | true |
bb6e8fb587e1ee4c0399979e452c2f9b663a6697 | Ruby | rikitoro/design_patterns_in_ruby | /sec3_TemplateMethod/plainTextReport.rb | UTF-8 | 163 | 2.6875 | 3 | [] | no_license | require 'report'
class PlainTextReport < Report
def output_head
puts(" **** #{@title} ****")
end
def output_line(line)
puts(line)
end
end
| true |
ca98e97b94a9afcf9cdfb12c8bb0200a1e6dfa0e | Ruby | annaleme/exercicios_aceleradora_testes | /exercicio_3/validador.rb | UTF-8 | 976 | 3.484375 | 3 | [] | no_license | class Validador
def initialize numero
@numero = numero
end
def self.valida numero
return Validador.new numero
end
def bandeira
cont = 0
number = @numero.to_s.reverse
for index in 0..number.length
if index % 2 == 0
cont += number[index].to_i
else
dobro = (numbe... | true |
95084c875d8c7bfa777cdeb35abfa87d249e55b6 | Ruby | D4L/abstractGraph | /lib/abstract_graph/implementations/adjacency_matrix/add_edge.rb | UTF-8 | 804 | 2.96875 | 3 | [
"MIT"
] | permissive | # required in "abstract_graph/implementations/adjacency_matrix"
module AbstractGraph
module Implementations
class AdjacencyMatrix
# d: Adds an edge.
# a: Check that s isn't taken, v1 and v2 exist
# t: constant
# p: s is the name of the edge, v1 and v2 are names of the two vertices
... | true |
d994573527886968a16c7114b746c8d86efaf9d4 | Ruby | abhishekg785/Getting-started-with-Ruby | /object1.rb | UTF-8 | 438 | 4.03125 | 4 | [] | no_license | #eveything is object in ruby
# functions, class everything
# simple initialized in a variable cls
cls = class Ram
def initialize()
puts "Inside the Ram class"
end
end
obj = Ram.new()
sample = def Sample
puts "Inside the sample function"
end
# this is similar to as
# class MyClass
# at... | true |
d924f1e1c3508467a45e302b8b78eceeaf617278 | Ruby | ajaysreenivasan/ruby-drills | /exercise021/ex021.rb | UTF-8 | 172 | 3.8125 | 4 | [] | no_license | # Exercise 21 - Functions Can Return Something
def add(a, b)
return a + b
end
a = STDIN.gets.chomp.to_i
b = STDIN.gets.chomp.to_i
puts "SUM: #{a}+#{b}=#{add(a, b)}"
| true |
40950b5b2b43b076091beef18481535795bebc55 | Ruby | ministryofjustice/laa-apply-for-legal-aid | /app/controllers/concerns/address_handling.rb | UTF-8 | 1,004 | 2.71875 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | module AddressHandling
AddressCollectionItem = Struct.new(:id, :address)
private
def collect_addresses
count = AddressCollectionItem.new(nil, t("providers.address_selections.show.addresses_found_text", count: @addresses.size))
[count] + @addresses.map { |addr| AddressCollectionItem.new(addr.lookup_id, add... | true |
b1eb054bb768dc10fe500e62860428d1597f261b | Ruby | zhimin/adminwise-ui-tests | /rwebspec/pages/password_change_page.rb | UTF-8 | 383 | 2.5625 | 3 | [] | no_license |
class PasswordChangePage < AbstractPage
def initialize(browser)
super(browser, "Change Password") # <=
end
def enter_current(password)
enter_text("current_password", password)
end
def enter_new(new_pass)
enter_text("user[password]", new_pass)
end
def enter_confirm(confirm_pass)
ente... | true |
7b1e594a82d7850d9945c3bc357a058422660ee7 | Ruby | nidialal/nid-mid | /hw1/part6.rb | UTF-8 | 592 | 3.234375 | 3 | [] | no_license | class Numeric
@@currencies = {'yen' => 0.013, 'euro' => 1.292, 'rupee' => 0.019,'dollar'=>1}
def method_missing(method_id)
singular_currency = method_id.to_s.gsub( /s$/, '')
if @@currencies.has_key?(singular_currency)
self * @@currencies[singular_currency]
else
super
end
end
def in(v... | true |
12cb0f49b7854d5e8d260ad2b55354357d25c113 | Ruby | stowersjoshua/KuruQuest | /bin/build_dictionary | UTF-8 | 1,358 | 3.125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative '../dictionary'
require_relative '../display'
require 'optparse'
require 'csv'
OptionParser.new do |parser|
parser.on('-o', '--destination [DESTINATION DICTIONARY]') do |path|
@destination_path = path
end
parser.on '-s', '--source [SOURCE DICTIONARY]' do |path|
@sou... | true |
4331242f29029a118e309626cdb0e42ba150e78b | Ruby | DallasBille/programming_languages-dumbo-web-career-012819 | /programming_languages.rb | UTF-8 | 1,404 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #{
#:ruby => {
# :type => "interpreted",
# :style => [:oo]
# },
#:javascript => {
# :type => "interpreted",
# :style => [:oo, :functional]
# },
# :python => {
# :type => "interpreted",
# :style => [:oo]
# },
# :java => {
# :type => "compiled",
# :clojure => {
# :type => "compiled",
# ... | true |
d13ec5d3863e313296a47038adb7c927bf9c3072 | Ruby | mackee1008/2014 | /20141112/richyoung2.rb | UTF-8 | 280 | 3.40625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
# richyoung2.rb.rb
# 2個の引数(年齢、所持金)を与えて判定を行います
age = ARGV[0].to_i
money = ARGV[1].to_i
if age <= 35 or money > 10000 then
puts "若い金持ちかやな"
else
puts "びんぼーなおっさんやで"
end
| true |
a677d055a61461ba82f7e3bd8e10d146eb72a248 | Ruby | nevenRakonic/toy_robot | /lib/command_dispatcher.rb | UTF-8 | 425 | 3.140625 | 3 | [] | no_license | class CommandDispatcher
def initialize(commands, robot)
@commands = commands
@robot = robot
end
def run
@commands.each do |command|
method_name = command.first
args = command.last
if can_send_command?(method_name)
@robot.send method_name, *args
end
end
end
pr... | true |
fd0af9fbf605e24e1c91e0dd39f604e194ccb40a | Ruby | darshkpatel/relational_redis | /redis-stat/gems/ansi256-0.2.5/bin/ansi256 | UTF-8 | 731 | 3.203125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'ansi256'
bold = ARGV.delete '-b'
underline = ARGV.delete '-u'
if ARGV.length < 1
puts 'usage: ansi256 [-b] [-u] <[fg][/bg]> [message]'
exit 1
end
fgbg, *msg = ARGV
fg, bg = fgbg.split('/').map { |e|
if !e.to_s.empty?
case e
when /^#?[0-9a-f]{6}$/... | true |
0cf167bca185db98aedd99e462b7372a4356aa23 | Ruby | laudb/timeline | /app/models/article.rb | UTF-8 | 566 | 2.625 | 3 | [] | no_license | class Article < ActiveRecord::Base
def fetch
require 'open-uri'
require 'simple-rss'
# save rss data from website into 'rss'
url = 'http://feeds.theguardian.com/theguardian/football/rss'
rss = SimpleRSS.parse open(url)
#iterate through feed. Save title, link, description into variable
... | true |
7064834943f36aedae8a2501ba7b7f063eb50540 | Ruby | YujohnNattrass/ruby_small_problems | /easy5/after_midnight2.rb | UTF-8 | 553 | 3.3125 | 3 | [] | no_license | require 'time'
HRS_TO_MIN = 60
def after_midnight(time)
Time.parse(time).min + (Time.parse(time).hour * 60)
end
# def after_midnight(time)
# hours, minutes = time.split(":").map(&:to_i)
# p (hours * HRS_TO_MIN + minutes) % 1440
# end
def before_midnight(time)
total_minutes = after_midnight(time)
total_minu... | true |
3482403579b08e17a33e34391cf18640e8f2f198 | Ruby | GarstgerUnhold/text-utils | /lib/text_utils.rb | UTF-8 | 1,638 | 2.53125 | 3 | [] | no_license | module Redcar #TODO: Fix this!!!
# This class implements the search-and-replace command
class TextUtils
# Create the search and replace menu item
def self.menus
# Here's how the plugin menus are drawn. Try adding more
# items or sub_menus.
Menu::Builder.build do
sub_menu "Edit" do
... | true |
891f91e083604408cb459e1897509aaba673e0d7 | Ruby | mailchimp/statistrano | /lib/statistrano/remote/file.rb | UTF-8 | 2,179 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | module Statistrano
class Remote
class File
attr_reader :path, :remote, :permissions
def initialize path, remote, permissions=644
@path = path
@remote = remote
@permissions = permissions
end
def content
resp = remote.run "cat #{path}"
if resp.su... | true |
23708ac2d7ab72b62be22e2be0a27a9d7693be94 | Ruby | saronpasu/rgss3 | /enemy_growup_system/growup_record.rb | UTF-8 | 4,061 | 2.9375 | 3 | [] | no_license | #-*- encoding: utf-8 -*-
# for RGSS3 powored by Ruby1.9.2
# coded by saronpasu.
module Enemy_GrowUp_System
class GrowUp_Record
# 定数:覚えるスキルの上限
LEARNED_SKILL_MAX = 3
# 定数:覚える特徴の上限
LEARNED_FEATURE_MAX = 5
attr_accessor :data, :enemy_id
# スクリプト上部へ移動
# 定数:覚えるスキルの上限
# LEARNED_S... | true |
6859753fcfc153ab40da7319ff218f29cea06039 | Ruby | krhitoshi/saklient.ruby | /lib/saklient/cloud/resources/server_instance.rb | UTF-8 | 6,553 | 2.796875 | 3 | [
"MIT"
] | permissive | # -*- encoding: UTF-8 -*-
# This code is automatically transpiled by Saklient Translator
require_relative '../../util'
require_relative '../client'
require_relative 'resource'
require_relative 'iso_image'
require_relative '../enums/eserver_instance_status'
module Saklient
module Cloud
module Resources
#... | true |
c541ab848716c46349aa52c121adbfbbf620776b | Ruby | AlexisCH48/desafios_flujos | /mayorde4.rb | UTF-8 | 675 | 3.578125 | 4 | [] | no_license | #definir variables
valor1 = ARGV[0].to_i
valor2 = ARGV[1].to_i
valor3 = ARGV[2].to_i
valor4 = ARGV[3]
#definir comparativa de valores
if valor4.nil? #Comparativa si solo exiten 3 valores
if valor1 >= valor2 && valor1 >= valor3
puts "#{valor1}"
elsif valor2 >= valor3
puts "#{valor2}"
else
... | true |
4026207fa33eed963cdbc1160c9c376530311ccc | Ruby | jmartow/object_oriented_programming | /people.rb | UTF-8 | 514 | 4.0625 | 4 | [] | no_license | class Person
attr_accessor :name
def greeting
puts "Hi, my name is #{name}"
end
end
class Student < Person
def learn
puts "I get it!"
end
end
class Instructor < Person
def teach
puts "Everything in Ruby is an Object."
end
end
person1 = Instructor.new
person1.name = "Chris"
person1.greeting
person2 = ... | true |
ff955ee6a99c80dd1739f271f9a9c38000bb35e7 | Ruby | Uthaeus/codewars_ruby | /map_that.rb | UTF-8 | 350 | 4.21875 | 4 | [] | no_license | # Create a method flat_map that accepts a list and a block, runs the block for each item in the list. It should return a new array with the block return values, and that array should be flattened (1-dimensional).
def flat_map list, &block
# your solution here
list.flat_map &block
end
list = [3,5,8,13]
p flat_... | true |
fee1791201d424ba648f4bea29a47872763ebce1 | Ruby | MihailSergeenkov/ror_basic | /lesson_8/passenger_carriage.rb | UTF-8 | 829 | 3.359375 | 3 | [] | no_license | require_relative 'carriage.rb'
class PassengerCarriage < Carriage
attr_reader :number_of_busy_seats
attr_reader :number_of_seats
def initialize(number_of_seats)
@number_of_seats = number_of_seats
@number_of_busy_seats = 0
validate!
end
def busy_seat
self.number_of_busy_seats += 1 if number_o... | true |
1774f07143602ba435dbefd85bad471a930b5ada | Ruby | somethinrother/bitmaker_lessons | /object_oriented_programming2/text.rb | UTF-8 | 627 | 3.625 | 4 | [] | no_license | # class Person
# @@people = []
# def initialize
# @name = nil
#
# end
#
# def self.create
# person = Person.new
# person.name = gets.chomp
# @@people << person
# end
#
# def self.people
# @@people
# end
#
# def name=(name)
# @name = name
# end
#
# def name
# @name
# end... | true |
0544494ab116ebebc931beafd5ad6ed3896d346a | Ruby | vvalorous/rebot | /lib/rebot/cli.rb | UTF-8 | 993 | 2.6875 | 3 | [
"MIT"
] | permissive | require "thor"
module Rebot
class CLI < Thor
include Thor::Actions
class_option :verbose, type: :boolean, default: true, aliases: "-v"
attr_reader :bot_name
source_root File.expand_path("../../../template", __FILE__)
desc "new [BOT_NAME]", "Creates a BOT_NAME dir with your new bot structure."
... | true |
25634516f765233dcdcf322c9d360a3042cec124 | Ruby | VinutaChetan/tasksbox | /app/models/newtask.rb | UTF-8 | 610 | 2.640625 | 3 | [] | no_license | class Newtask < ActiveRecord::Base
belongs_to :project
validates_presence_of :title #,:project_id,:due_date,:is_completed
# validates_numericality_of :project_id
# validate :check_valid_date # if !self.project.nil?
# validate :check_boolean
# private
# def check_valid_date
# if((!self.project.nil?)&&(self.... | true |
3e5a51cdf68b8c7841988f0169616356c6bef816 | Ruby | Takokaro/beachef | /test/models/cuisine_test.rb | UTF-8 | 919 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: cuisines
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
# updated_at :datetime not null
#
require 'test_helper'
class CuisineTest < ActiveSupport::TestCase
# validation ... | true |
c7f02c550a4a15a2d980e5a9099d2d0bd2644109 | Ruby | bipashant/Leapfrog-Assignment- | /Day 1/CelciusToFarenhite.rb | UTF-8 | 374 | 3.640625 | 4 | [] | no_license | repeat = "y"
while (repeat == "y")
puts "Please enter a Temperature in Celcius"
temp=gets.chomp
if (temp.to_f.to_s==temp || temp.to_i.to_s==temp)
temp=temp.to_f
temp=temp * 9/5 + 32
puts ('%.2f' % temp).to_s+"F"
puts "Do you want check another Temperature?(y/n)"
repeat=gets.chomp
else
pu... | true |
c6221f994423a7311980cfbc4e7dd14e0715768c | Ruby | PeterGemmell/cinema_homework | /models/customer.rb | UTF-8 | 2,187 | 3.703125 | 4 | [] | no_license | require_relative('../db/sql_runner')
class Customer
attr_accessor :id, :name, :funds
def initialize(db_hash) #options is a hash data type. When we query sql it always gives back an array of hashes.
@id = db_hash['id'].to_i if db_hash['id'] #will be a string as a database always return strings. So convert to in... | true |
f0c15ad8b60ec008589b677696c703979f33c690 | Ruby | Will-Bath/student-directory-1 | /directory.rb | UTF-8 | 1,531 | 3.625 | 4 | [] | no_license | student_count = 11
# first, we print the list of students
students = [
{name: "Dr. Hannibal Lecter", cohort: :november, hobbies: :golf},
{name: "Darth Vader", cohort: :november, hobbies: :golf},
{name: "Nurse Ratched", cohort: :november, hobbies: :golf},
{name: "Michael Corleone", cohort: :november, hobbies: :golf},
... | true |
742e4351156c1a442144b9c78058079508c97bd2 | Ruby | catherineemond/challenges | /capstone-2020/algorithms/recursion.rb | UTF-8 | 256 | 3.59375 | 4 | [] | no_license | def countdown(number)
number.downto(0) { |n| puts n }
puts 'Launch!'
end
countdown(10)
#--------------
def recursive_countdown(number)
return puts 'Launch!' if number < 0
puts number
recursive_countdown(number - 1)
end
recursive_countdown(10) | true |
10ccb1412ed20047606738979e1de60d76dd089f | Ruby | autumnw/sensu-plugins-network-checks | /bin/check-netif.rb | UTF-8 | 2,340 | 2.515625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
#
# check-netif
#
# DESCRIPTION:
# Network interface throughput monitoring
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
#
# USAGE:
# #YELLOW
#
# NOTES:
# This plugin depends on rpm package sysstat!
# LICENSE:
# Copyright 2015 Autodesk, Inc. and contributors. <autumn.wa... | true |
34c738d8ee6bd9da8ba66bdf06670ef95b01724a | Ruby | davehunt/jenkins-selenium-tests | /test/selenium/core/freestyle_test.rb | UTF-8 | 757 | 2.53125 | 3 | [] | no_license | require File.dirname(__FILE__) + "/../lib/base"
require File.dirname(__FILE__) + "/../pageobjects/newjob"
require File.dirname(__FILE__) + "/../pageobjects/job"
class FreestyleJobTests < JenkinsSeleniumTest
def setup
super
@job_name = "Seleneium_Test_Job"
NewJob.create_freestyle(@driver, @base_url, @job... | true |
b2257465f5975859d8ccc07df072d45e7186c9c2 | Ruby | Adams1991/week1-day_2-start_point | /ruby_functions_practice.rb | UTF-8 | 1,164 | 3.96875 | 4 | [] | no_license | def return_10()
return 10
end
def add(first_number, second_number)
return first_number + second_number
end
def subtract(first_number, second_number)
return first_number - second_number
end
def multiply(first_number, second_number)
return first_number * second_number
end
def divide(first_number, second_number)... | true |
b5a39697eb097a649c9300d7f9ff7462c3be2834 | Ruby | WIU/d2l_sdk | /lib/d2l_sdk/course.rb | UTF-8 | 14,826 | 2.640625 | 3 | [
"MIT"
] | permissive | require_relative 'requests'
require 'json-schema'
require 'mime/types'
########################
# ACTIONS:##############
########################
# Deletes a course based, referencing it via its org_unit_id
# This reference is created through a formatted path appended with the id.
# Then, a delete http method is exec... | true |
d9f9f855c451aea755912452d1c5d4c944b1c42d | Ruby | dplummer/dbmod | /excel_row.rb | UTF-8 | 2,385 | 3 | 3 | [] | no_license | class ExcelRow
attr_reader :row, :accessdb, :accessdb_data, :status, :serial, :asset_tag,
:user_first_name, :user_last_name, :user_login, :request_number,
:accessdb_record
def initialize(row, accessdb_data, accessdb)
@row = row
@accessdb_data = accessdb_data
@accessdb = accessdb
@status = ... | true |
290c7ae6407394c0d9656fe986f61744f9366f5d | Ruby | vaiorabbit/ZopfliCompress | /test/inflate.rb | UTF-8 | 1,598 | 2.96875 | 3 | [
"Zlib"
] | permissive | require 'zlib'
=begin
struct BinaryHeader
{
uint32 FourCC;
uint32 Version;
uint32 FileSize;
uint32 BlockSize;
};
Binary Body:
If header.BlockSize > 0 then
The body is made up from a sequence of compressed blocks:
|Compressed Block Size(Length==sizeof(uint32))| |Compressed Block (Length==Compress... | true |
5a373ed2dbcd47735e7ea14963364affeb8043fc | Ruby | whiteleaf7/narou | /spec/downloader_spec.rb | UTF-8 | 1,485 | 2.71875 | 3 | [
"BSD-3-Clause",
"MIT",
"Unlicense"
] | permissive | # -*- Encoding: utf-8 -*-
#
# Copyright 2013 whiteleaf. All rights reserved.
#
require_relative "../lib/downloader"
describe Downloader do
describe ".create_subdirecotry_name" do
context "小説家になろうのタイトルが渡された場合" do
it do
expect(Downloader.create_subdirecotry_name("n9669bk 無職転生 - 異世界行ったら本気だす -")).to ... | true |
ef0f61b267005446dc8aff13cff6753145c2c0f6 | Ruby | moriokumura/mor.io | /lib/tasks/import.rake | UTF-8 | 838 | 2.75 | 3 | [] | no_license | # require 'csv'
#
# namespace :import do
#
# PaperTrail.whodunnit = "rake:import #{`whoami`.strip}"
#
# desc 'Import AttributeItems'
# task :attribute_items, [:file] => :environment do |task_name, args|
# PaperTrail.whodunnit = "rake:#{task_name} #{`whoami`.strip}"
#
# file = args[:file] || File.join(Rail... | true |
a07a5b97db123067ebe4f0ba55060c3174f233f8 | Ruby | JohnPlummer/roman_numeral | /roman_numeral_spec.rb | UTF-8 | 1,082 | 3.171875 | 3 | [] | no_license | $LOAD_PATH.unshift File.dirname(__FILE__)
require 'rspec'
require 'roman_numeral'
describe RomanNumeral do
describe 'new' do
it 'raises an exception if the numerals are invalid' do
expect{RomanNumeral.new('IIV')}.to raise_error('Invalid Numerals')
end
end
describe 'to_integer' do
it 'return... | true |
2c9200a779ef9ba60825e132589a9947b11ea195 | Ruby | CepCap/intern | /work/school/schooldb.rb | UTF-8 | 2,668 | 3.125 | 3 | [] | no_license | require_relative 'schoolhelper'
class SchoolDB
include SchoolHelper
attr_reader :subjects, :students
attr_accessor :students_file
def initialize
@subjects = ['русский', 'математика', 'английский', 'программирование', 'естествознание']
@students_file = 'students'
@students = {}
generate
end
... | true |
4714b6b4cdc3fd1d033ee7a1a3687ff225a2c0c5 | Ruby | codecation/trailmix | /app/models/reply_token.rb | UTF-8 | 338 | 2.890625 | 3 | [
"MIT"
] | permissive | class ReplyToken
def initialize(email)
@email = email
end
def self.generate(email)
new(email).generate
end
def generate
"#{username}.#{random_suffix}".downcase
end
private
attr_reader :email
def random_suffix
SecureRandom.urlsafe_base64(8)
end
def username
email.split("@"... | true |
eb6a6963d5bb56c46f6397a8ca15490c6d61b6d8 | Ruby | 95-Samb/advent-of-code | /2020-day-10/output.rb | UTF-8 | 451 | 2.5625 | 3 | [] | no_license | require_relative "adapter_configurator"
require_relative "input_converter"
input = File.read("input.txt")
adapters = InputConverter.new.execute(input)
subject = AdapterConfigurator.new(adapters)
jolt_differences = subject.jolt_differences
number_of_arrangements = subject.charging_arrangements
jolt_di... | true |
112f72efbacd08eee3a9ca977c612a77eaacbd15 | Ruby | alu0100902341/P11_LPP | /lib/gema/alimento.rb | UTF-8 | 352 | 3.078125 | 3 | [
"MIT"
] | permissive | class Alimento
attr_accessor :nombre, :proteinas, :glucidos, :lipidos, :kcal_
def initialize(nombre, prot, glu, lip)
@nombre = nombre
@proteinas = prot
@glucidos = glu
@lipidos = lip
@kcal_ = ( (4 * @proteinas) + (4 * @glucidos) + (9 * @lipidos) )
end
def to_s
"#{@nombre} P(#{@proteinas}) G(#{@glucid... | true |
8c4573d6b123786b7862a64720b6a53422283fe5 | Ruby | ChaeOkay/CoreRuby | /7week/7WE3.rb | UTF-8 | 251 | 3.75 | 4 | [] | no_license | require 'Date'
def month_days(month, year=2013)
date = Date.new(year, month, 1)
count = 0
until date.month == (month+1)
date += 1
count += 1
end
"#{count} #{Date::MONTHNAMES[month]}"
end
puts month_days(5)
puts month_days(2, 2000) | true |
af9f68f383506bf5c8308009fd9a82a147095e37 | Ruby | xana68/glyph-framhelper | /app/helpers/flash_helper.rb | UTF-8 | 2,920 | 2.671875 | 3 | [] | no_license | module FlashHelper
# Converts flash types to :success or :error to conform to what
# twitter bootstrap can handle
#
def homogenize_flash_type type
case type.to_sym
when :notice then :success
when :alert then :warning
when :error then :danger
else type
end
end
def icon_class_for type... | true |
c88c083426eb4b4fc8ad8667b85719fb3e8536de | Ruby | shashankdass/humble_giving | /test_twilio.rb | UTF-8 | 446 | 2.625 | 3 | [] | no_license | require 'twilio-ruby'
account_sid = "AC4b35fda44c0492996a609f2e8c8c22c4" # Your Account SID from www.twilio.com/console
auth_token = "95aa5484149e68cddbfbf468a1627a08" # Your Auth Token from www.twilio.com/console
@client = Twilio::REST::Client.new account_sid, auth_token
message = @client.messages.create(
body... | true |
e5aeff1515cfc93e57a39845bc6ffaf25b5f8640 | Ruby | OlgaSe/clock | /lib/clock.rb | UTF-8 | 1,079 | 3.375 | 3 | [
"MIT"
] | permissive | # clock.rb
def clock(hours, minutes, seconds)
if hours < 0 || hours > 23
raise ArgumentError, "Invalid hours #{hours}"
end
if hours < 10
hours = "0#{hours}"
elsif
minutes < 10
minutes = "0#{minutes}"
elsif
seconds < 10
minutes = "0#{minutes}"
end
return "#{hours}:#{minutes}:#{seconds}... | true |
9513b70bb92017c0696f8685d4d84c31e9e069c6 | Ruby | maxplomer/interview_coding_challenges | /salesforce_dot_com/upload_customer_data_to_api.rb | UTF-8 | 2,264 | 3.171875 | 3 | [] | no_license | ### Script to upload csv customer data to Desk.com API
### Export Desk.com subdomain with: $ export DESK_DOT_COM_SUBDOMAIN="zzz-maxplomer"
### Export Desk.com user email with: $ export DESK_DOT_COM_USER_EMAIL="maxplomer@gmail.com"
### Export Desk.com password with: $ export DESK_DOT_COM_PASSWORD="MyDeskDotComPassword"
... | true |
9c743eb8acf1ca85091839d0b7cb74429a883817 | Ruby | eina/top-basic-ruby | /spec/substrings_spec.rb | UTF-8 | 1,213 | 3.453125 | 3 | [] | no_license | require_relative '../substrings'
describe "substrings" do
it "should be able to find the same word in an array" do
dictionary = ["below", "weather"]
expect(substrings("below", dictionary)).to include("below")
end
it "should be able to find a substring" do
dictionary = ["low", "weather"]
expe... | true |
1a01e035ad306e8842e6f72b8205a3f886a9a2d2 | Ruby | suhy-jang/morning-code | /leetcode/06.binary-tree-level-order-traversal/suhy.rb | UTF-8 | 1,002 | 3.421875 | 3 | [] | no_license | # Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @return {Integer[][]}
def level_order(root)
return [] if root.nil?
i=0
q = [root]
or... | true |
8212519358694d2a00acceb41539bec3387fb071 | Ruby | wildcatblue/ttt-with-ai-project-v-000 | /lib/board.rb | UTF-8 | 1,111 | 4.09375 | 4 | [] | no_license | #token repesents the appropriate token for each player object
class Board
require 'pry'
attr_accessor :cells
def initialize
@cells = Array.new(9, " ")
end
def board
@cells
end
def reset!
cells.clear
@cells = Array.new(9, " ")
end
def display
puts
puts " #{board[0]} | #{boa... | true |
0bd9451810e8ee798d4d416d3fbe7c8c541ff94c | Ruby | davidhollis/psiugt | /app/models/remote_file.rb | UTF-8 | 1,112 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | require 'tempfile'
class RemoteFile < ActiveRecord::Base
enum role: %i(image genealogy)
def s3_bucket
"psiugt-org-#{role}"
end
class << self
def create_from(io:, role:, suffix: '')
role = role.to_s
unless self.roles.keys.include? role
raise ArgumentError, "role must be one of ... | true |
9870f0739cb2c2e04c33ddf933694a11d3dc0505 | Ruby | RandyG3/Udemy | /Ruby/Section 08 Arrays I Creation Addition and Mods/086-Introduction to Arrays.rb | UTF-8 | 130 | 2.515625 | 3 | [] | no_license |
p [] # Create an empty array - still a valid object
p [].class
numbers = [] # Create an empty array - still a valid object | true |
eac02a37481b18b8d8a88a66b0eee69422d77176 | Ruby | ak-matsu/ruby | /left.rb | UTF-8 | 416 | 4.125 | 4 | [] | no_license | # 問題.1
# 任意の文字列の最初の2文字を最後尾に持ってきて
# その文字を出力するメソッドを作りましょう。
# 出力例:
# left2("Hello") → lloHe
# left2("java") → vaja
# left2("Hi") → Hi
# ヒント
# 範囲指定をして、指定の要素を取得しましょう。
def left2(str)
puts str[2..-1] + str[0..1]
end
left2("Hello")
left2("java")
left2("Hi")
| true |
4b81cf674373889da59c4a71a82d8f579628f43b | Ruby | dalspok/exercises | /small_problems_i2/easy_7/6.rb | UTF-8 | 443 | 3.4375 | 3 | [] | no_license | =begin
P:
E:
D:
A:
C: =========================
=end
def staggered_case str
lower = true
arr1 = str.chars.map do |char|
lower = (lower ? false : true) if char.match /[a-zA-Z]/
lower ? char.downcase : char.upcase
end
arr1.join
end
p staggered_case('I Love Launch School!') == 'I lOvE lAuNcH sChOo... | true |
94ebba1a0db08bd7f46ad3800497672ddb683d4b | Ruby | taw/magic-search-engine | /indexer/lib/patches/patch_assign_priorities_to_sets.rb | UTF-8 | 781 | 2.515625 | 3 | [
"MIT"
] | permissive | class PatchAssignPrioritiesToSets < Patch
def call
@versions = [nil, *@sets.map{|x| x.dig("meta", "date") }.uniq.sort]
each_set do |set|
set["priority"] = priority(set)
end
end
private
def priority(set)
# Errata sets are just a way to apply Oracle erratas without creating any cards
... | true |
05f2195e3f3bb747e2f0c2781306eafb42dc2353 | Ruby | drewtempelmeyer/acts_as_king | /lib/acts_as_king.rb | UTF-8 | 2,680 | 3.125 | 3 | [] | no_license | require 'acts_as_king/railtie' if defined?(Rails)
# Written by Drew Tempelmeyer
module ActsAsKing
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
# Defines that the model should have a self referencing hierarchy. This allows you to have threaded comments or any other type
... | true |
a69f972c2db2d641a86ac4b690cd90c529a2a8a4 | Ruby | akpersad/google-maps-api-projects | /app/models/Google_model.rb | UTF-8 | 1,868 | 3.0625 | 3 | [] | no_license | # require 'pry'
# require 'open-uri'
# require 'JSON'
# require 'yaml'
# require 'rest-client'
# require 'openssl'
# class DirectionsModel
# def initialize(url)
# # binding.pry
# directions_hash = JSON.load(open(url, {OpenSSL::SSL::VERIFY_PEER => OpenSSL::SSL::VERIFY_NONE}))
# # binding.pry
# if directio... | true |
1ef097c1829ed9f86d3ff69d8ca09c4f90f249d8 | Ruby | vladiim/fitafy | /db/seed_files/exercises/create_glutes.rb | UTF-8 | 8,483 | 2.921875 | 3 | [] | no_license | #!/bin/env ruby
# encoding: utf-8
def create_glutes
count = 0
e = Exercise.find_or_create_by_name("Hip Abduction (Cable)")
e.muscle = "glutes"
e.muscle = e.muscle.downcase
e.equipment_id = Equipment.find_or_create_by_name("Cable Cross Over Machine").id
e.category = "muscle"
e.category = e.cate... | true |
f02872cb6151f240f81727a673e60ec4dba264a4 | Ruby | archivesspace/archivesspace | /common/aspace_logger.rb | UTF-8 | 1,457 | 2.953125 | 3 | [
"ECL-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'logger'
require 'atomic'
class ASpaceLogger < Logger
def initialize(logdev)
@backlog = Atomic.new([])
@recording = Atomic.new(false)
super(logdev)
end
def add(severity, message = nil, progname = nil, &block)
if @recording.value == true
if !message
if block
mess... | true |
2383c01d52d3192d0357c99ee6822632c7c0111b | Ruby | yuramelesh/see_through | /config/config_reader.rb | UTF-8 | 789 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative 'repository'
require_relative 'profile'
class Config_reader
def initialize
@config = YAML.load_file('config.yml')
@repositories = []
@profiles = []
end
def read_repos
@config['repositories'].each do |repository|
@repositories.push(Repository.new(repository['name']))
e... | true |
4f9fdfd6f108412541357a9847f97ff3331cb7aa | Ruby | zhj149/air_traffic_simulator | /airplane.rb | UTF-8 | 858 | 3.078125 | 3 | [] | no_license | class Airplane
include Positionable
#attr_reader :weight
attr_accessor :aircraft_type, :weight
def self.create(options={})
airplane = self.new(options[:aircraft_type])
airplane.weight = options[:weight] || rand(600)
airplane.velocity = options[:velocity] || rand(900)
airplane.alti... | true |
a51a0cc33d004e6d2100480ea01f51bcdb42fead | Ruby | MarioBland/programming-univbasics-4-array-simple-array-manipulations-nyc-web-100719 | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 2,536 | 3.875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def using_push(array,string)
array.push(string)
end
def using_unshift(array,string)
array.unshift(string)
end
def using_pop(array)
array.pop
end
def pop_with_args(array)
array.pop(2)
end
def using_shift(array)
array.shift
end
def shift_with_args(array)
array.shift(2)
end
def using_concat(a... | true |
bf72ee354cdd0672a8b76760f5fbd831bfedf60a | Ruby | ryanfb/ruby-parallel-benchmarks | /benchmark-pmap.rb | UTF-8 | 464 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'benchmark'
require 'pmap'
require_relative 'constants'
require_relative 'pidigits'
Benchmark.bmbm do |x|
x.report("pi") { (0..ITERATIONS - 1).pmap(THREAD_LIMIT) {|i| pidigits(i + 1000) } }
x.report("sort!") { (1..ITERATIONS).pmap(THREAD_LIMIT) { ARRAY.dup.sort! } }
x.report("sort")... | true |
b832b2735d6f93b18dcd9caa69efc4076a40e7c5 | Ruby | paradisetob/oo-barking-dog-online-web-pt-090919 | /lib/dog.rb | UTF-8 | 76 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
fido= Dog.new
fido.name
def bark
puts "woof!"
end
end
| true |
4622c12c11128b63dc570f2b8e3b1ce91ba0355e | Ruby | zivolution921/events | /app/models/event.rb | UTF-8 | 2,442 | 2.859375 | 3 | [
"MIT"
] | permissive | class Event < ActiveRecord::Base
#rails must pass all validations in order to save into the database
validates :name, :location, presence: true
validates :description, length: { minimum: 25 }
validates :price, numericality: { greater_than_or_equal_to: 0 }
validates :capacity, numericality: { only_integer... | true |
a1aa9418ff94b959375d5b8902f0c090ca8181e8 | Ruby | bm-sms/daimon_skycrawlers | /lib/daimon_skycrawlers/filter/robots_txt_checker.rb | UTF-8 | 858 | 2.78125 | 3 | [
"MIT"
] | permissive | require "webrobots"
require "daimon_skycrawlers/filter/base"
require "daimon_skycrawlers/version"
module DaimonSkycrawlers
module Filter
#
# This filter provides robots.txt checker for given URL.
# We want to obey robots.txt provided by a web site.
#
class RobotsTxtChecker < Base
def initia... | true |
075d63d50a4be554218c696cd288f8a4ad1cdfb8 | Ruby | MakeSureAndShow/Codewars-Launch-Medium-Problems | /test10.rb | UTF-8 | 1,372 | 3.546875 | 4 | [] | no_license | SECONDS_PER_MINUTE = 60
SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60
SECONDS_PER_DAY = SECONDS_PER_HOUR * 24
SECONDS_PER_YEAR = SECONDS_PER_DAY * 365
def format_duration(number)
if number == 0
return "now"
end
years, number = number.divmod(SECONDS_PER_YEAR)
days, number = number.divmod(SECONDS_PER_DAY... | true |
98f1a96719c7410810ec04778dea173bf5d282e4 | Ruby | hypn/ruby_piface_home_automation | /app/controllers/channels_controller.rb | UTF-8 | 1,234 | 2.734375 | 3 | [] | no_license | class ChannelsController < ApplicationController
before_action :channel
begin
require 'piface'
rescue Exception
puts 'Error: piface not defined!'
end
def on
render text: set_channel(@channel, 1)
end
def off
render text: set_channel(@channel, 0)
end
def status
render text: read_... | true |
dcbb41e4ed50c0ee92efe457729e4515d272d858 | Ruby | msruseva/Programming-101-Ruby | /week01/list_hashes.rb | UTF-8 | 2,621 | 3.953125 | 4 | [] | no_license | def number_to_digits(n)
result = []
while n != 0
result << n % 10
n = n / 10
end
result.reverse
end
def numbers_recursive_to_digit(n)
result = []
return [n] if n < 10
numbers_to_digit(n / 10).push(n % 10)
end
def digits_to_number(n)
result, index = '', 0
while ind... | true |
572621ab7c0b2db7cc23a6135b70bf5210d95e07 | Ruby | cstbolts335/W1D5_Projects | /polTree/lib/00_tree_node.rb | UTF-8 | 1,099 | 3.453125 | 3 | [] | no_license |
class PolyTreeNode
attr_reader :parent, :children, :value
def initialize(value)
@value = value
@parent = nil
@children = []
end
def parent=(new_parent)
unless parent.nil?
parent.children.reject! {|el| el == self}
end
@parent = new_parent
unless new_parent.nil? || new_parent... | true |
53662a3ab3c0194c269f4dc09a00120f3a679d2d | Ruby | jrcode7/Introduction_To_Programming | /Final_Exercises/Exercise_6.rb | UTF-8 | 225 | 3.25 | 3 | [] | no_license | numbers = [1, 2, 3, 4, 5 ,6, 7, 8, 9, 10]
new = []
numbers.select do |num|
num % 2 != 0
end
numbers.push(11)
numbers.unshift(0)
print numbers
puts
numbers.pop
numbers << 3
print numbers
puts
print numbers.uniq
puts
| true |
4974ebe40d6163be03e7cac012db369dc79d357f | Ruby | hmarr/backup | /lib/backup/database/mongodb.rb | UTF-8 | 4,968 | 2.734375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Backup
module Database
class MongoDB < Base
##
# Name of the database that needs to get dumped
attr_accessor :name
##
# Credentials for the specified database
attr_accessor :username, :password
##
# Connectivity options
attr_access... | true |
2050f0f5316084a7b72aa4719990679512680b2c | Ruby | reillywj/launchschool_code_challenges | /201606/robot_name/robot_name.rb | UTF-8 | 722 | 3.390625 | 3 | [
"MIT"
] | permissive | class Robot
LETTERS = ('A'..'Z').to_a.freeze
class << self; attr_accessor :names end
@names = []
attr_reader :name
def initialize
generate_name(2, 3)
end
def reset
old_name = name
generate_name(@letters, @numbers)
self.class.names.delete old_name
end
private
def generate_name... | true |
2c69652be967415d0d20080f4a14ae8acd65439e | Ruby | nextgen-database/nextgen-database | /lib/tasks/etl_import_data.rake | UTF-8 | 9,933 | 2.859375 | 3 | [] | no_license | # Extraction, Transformation and Loading
# Taking the data from the existing database and moving it into the new database
# https://stuff-things.net/2016/11/02/importing-legacy-data-into-your-rails-app/
# Require the CSV Gem
require 'csv'
namespace(:ng) do
namespace(:import) do
#
# Testing the waters
#
desc... | true |
24efc8c1b8cdce809e49dba76daf89c758fd6571 | Ruby | Mariana-21/launchschool_v2 | /130_139_more_ruby_foundation/easy_1/07_all_method.rb | UTF-8 | 119 | 2.609375 | 3 | [] | no_license | class MyClass
def all?(collection)
collection.each { |item| return false unless yield(item) }
true
end
end
| true |
55373bd598bb0cca7ceef7e99bd53a2884e7fe46 | Ruby | garru/distributed_logreader | /lib/distributed_logreader/archiver/date_dir.rb | UTF-8 | 813 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'fileutils'
module DLogReader
class DateDir < Archiver
include FileUtils
attr_accessor :base_backup_dir
def initialize(backup_dir)
self.base_backup_dir = backup_dir
end
def archive(file)
unless base_backup_dir.nil?
backup_filename = backup_dir
mv(file, bac... | true |
676dd62ad20807ce0a404789f8412178f82f05a6 | Ruby | BreadMan96/Ruby_School | /RubyPushkin/luna_fix_shop.rb | IBM866 | 2,387 | 3.546875 | 4 | [] | no_license | #encoding: cp866
hh = {
basket_ball: { weight: 250, price: 100 },
golf_ball: { weight: 50, price: 200 },
shaiba: { weight: 150, price: 150 }
}
print " ਮ:\n1. ᪥⡮ \n2. \n3. \n ⮢, ⮢ 쪮, १ : "
acc = gets.strip.to_s
arr = Array.new(acc.split(','))
arr.each_index do |y|
arr[y] = arr[y].to_i
end
if arr[... | true |
ed43b1e9b1a1a6b03bd7eb5c400d236ef47e3a9d | Ruby | lacravate/yasify | /lib/yasify.rb | UTF-8 | 638 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"WTFPL"
] | permissive | # encoding: utf-8
require 'yaml'
require "pathstring"
# No comment here. Go see Pathstring source to understand
# 39 lines of code, including a good bunch of blank lines
# that's too beautiful to look at to mar it with comments
class Yasify < Pathstring
def read
YAML.load(super) rescue {}
end
def unit
... | true |
98cc20f92789ab796e528b9fb9272d0545b1f774 | Ruby | toniousx/launch_school | /101-109/lesson_2_small_programs/pseudocode.rb | UTF-8 | 2,411 | 4.15625 | 4 | [] | no_license | =begin
1. a method that returns the sum of two integers
## casual pseudocode
we initialize a method who has 2 integer arguments
we initialize the variable result and inside we add the first argument
adding the sum operator continued by the second argument
we print the result variable
we close the method
invoke the meth... | true |
f03c59381c091be9b45753eac4f7931b8ec28794 | Ruby | remnantkevin/ruby | /inheritance/car.rb | UTF-8 | 274 | 3.21875 | 3 | [] | no_license | require_relative 'vehicle'
class Car < Vehicle
attr_accessor :num_seats
def initialize(registration, weight, seats)
super(registration, weight)
self.num_seats = seats
end
def what
puts 'Car'
end
def to_s
puts reg, weight, num_seats
end
end
| true |
d746bdcb12166db6da4de73c1db3a43274e484ba | Ruby | mcmire/super_diff | /support/current_bundle.rb | UTF-8 | 1,846 | 2.640625 | 3 | [
"MIT"
] | permissive | require "bundler"
require "shellwords"
require "singleton"
module SuperDiff
class CurrentBundle
include Singleton
ROOT_DIR = Pathname.new("..").expand_path(__dir__)
APPRAISAL_GEMFILES_PATH = ROOT_DIR.join("gemfiles")
def assert_appraisal!
raise AppraisalNotSpecified.new(<<~MESSAGE) unless app... | true |
547cdc9ec2351d0b63dc7554ee854f34e7ad819a | Ruby | surfstudio/Generamba | /lib/generamba/helpers/non_xcode_proj_helper.rb | UTF-8 | 830 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module Generamba
# Replaces `XcodeprojHelper` for non xcodeproj-based projects
# Common example is generating stuff in SPM modules, which have no project file.
class NonXcodeProjHelper
# Recursively checks if directory contains any files
def self.has_files?(path)
return false un... | true |
950dbe64c2d79141c617d517b422eaff422dfecc | Ruby | cultureamp/cepa-health | /lib/cepa-health/generator.rb | UTF-8 | 965 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rails/generators'
require 'securerandom'
module CepaHealth
class InitializerGenerator < Rails::Generators::Base
def create_initializer_file
key = SecureRandom.hex(3)
create_file "config/initializers/cepa_health.rb", <<-CONTENT
# Configure Cepa Health checks.
# See: https://github.com/jonat... | true |
b1484fa7ed413a62896b40fe2d1230826feb357c | Ruby | SaraMc12/New_Reading_list | /App/google_books_list.rb | UTF-8 | 1,177 | 3.421875 | 3 | [] | no_license | require 'rest-client'
require 'json'
class GoogleBooksList
def initialize(string)
@search_string = string
end
def top_5_results
items = book_info_array["items"]
info_array_length = book_info_array.length
min_index = 5
if info_array_length < 5
min_ind... | true |
a7d6d3b2aed79ae75c46ced24a9d18017e3278f0 | Ruby | JNaftali/phase-0-tracks | /ruby/santa.rb | UTF-8 | 2,135 | 3.625 | 4 | [] | no_license | class Santa
attr_reader :age, :ethnicity
attr_accessor :gender
def initialize (gender, ethnicity )
p "Initializing Santa instance..."
@gender = gender
@ethnicity = ethnicity
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer", "Vixen", "Comet", "Cupid", "Donner", "Blitzen"]
@age = 0... | true |
76057a346afe31d529ff3c3d52609150dba8d608 | Ruby | craigmdavidson/Simple-Statistics | /lib/simple_statistics.rb | UTF-8 | 1,436 | 3.40625 | 3 | [
"MIT"
] | permissive |
module Enumerable
def array_of method_name
self.collect {|element| element.method(method_name).call}
end
end
class Array
def mean
self.inject(0) { |sum, x| sum += x } / (self.size.to_f)
end
def median already_sorted=false
return nil if self.empty?
array = self.sort unless already_sorted
... | true |
493f1c4a841248fe8bf8f33da255e512d23088ff | Ruby | andrijaperovic/slack_dj | /app/operations/find_video.rb | UTF-8 | 995 | 2.984375 | 3 | [
"MIT"
] | permissive | # Takes the query in given command and searches
# youtube. Takes the first video returned
# by youtube api and adds it to the playlist
#
class FindVideo
include Interactor
# Expects:
# team
# user
# dj
# playlist
# command e.g. "find Michael Jackson Thriller"
#
def call
video = search_youtube
... | true |
3f3d4c92aa92c6f3ef5aaa9bcde1a67da79bb2e3 | Ruby | athenacasarotto-drizly/ziptz | /lib/zip_code.rb | UTF-8 | 2,171 | 2.625 | 3 | [
"MIT"
] | permissive | require 'active_record'
require 'tty-spinner'
require 'yaml'
require 'ziptz'
class ZipCode < ActiveRecord::Base
self.table_name = 'ZIPCodes'
self.primary_key = 'ZipCode'
establish_connection YAML.safe_load(File.open('database.yml'))
alias_attribute :day_light_saving, :DayLightSaving
alias_attribute :state, ... | true |
b48f049465d7aaa6d65710d81e7035eeb8cf02ae | Ruby | xenda/curso_rails01 | /sesion02/send.rb | UTF-8 | 257 | 3.609375 | 4 | [] | no_license | puts "Ingrese su primer número"
initial = gets.chomp.to_i
puts "Ingrese la operación"
operation = gets.chomp
puts "Ingrese su segundo número"
last = gets.chomp.to_i
resultado = initial.send(operation,last)
print "Y el resultado es: #{resultado}"
| true |
299d14a755630339260ba57e809f182cad56e61d | Ruby | jhnnyk/LS101 | /study/piglatin.rb | UTF-8 | 155 | 2.609375 | 3 | [] | no_license | def pig_latin(message)
words = message.split(" ")
words.map do |word|
end
end
p pig_latin("hello there travis. how is your schoolwork going?")
| true |
953db5c28e0dd486ad05d44ff797d73b63409555 | Ruby | dansimpson/mover | /lib/cloud_sync/log.rb | UTF-8 | 828 | 2.796875 | 3 | [] | no_license | module CloudSync
class Log
@threshhold = 1
@descriptor = {
1 => "DBUG",
2 => "WARN",
3 => "INFO",
4 => "ERROR"
}
def self.debug msg
log(msg,1) if @threshhold <= 1
end
def self.warning msg
log(msg,2) if @threshhold <= 2
end
def self.info msg
... | true |
4a81f47b94ae9f220da23e53d07cadaffbe513eb | Ruby | jsimpson/exercism-solutions | /ruby/resistor-color/resistor_color.rb | UTF-8 | 220 | 3 | 3 | [] | no_license | class ResistorColor
COLORS = ["black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white"]
class << self
def color_code(color)
COLORS.index { |i| i == color }
end
end
end
| true |
46bf02c8b986207ecc089e5ee4534703f4af2972 | Ruby | timgrc/rails-krowd | /app/services/push_bot_answer.rb | UTF-8 | 488 | 2.6875 | 3 | [] | no_license | require 'yammer'
class PushBotAnswer
def initialize(bot, question)
@bot = bot
@question = question
end
def call
yam = Yammer::Client.new(access_token: @bot.user.access_token)
if @question[:sender_id].to_i != @bot.user.rse_id
bot_answer = CalculateBotAnswer.new(@question[:plain]).call
... | true |
28142caddf802a64ad468396490c6fbcc0cb4763 | Ruby | eeibadat99/assignment | /RubyAssignment/prb7.rb | UTF-8 | 620 | 4.09375 | 4 | [] | no_license | # define a class
class Quiz
# constructor method
def initialize(q,a)
@question, @answer = q, a
end
# accessor methods
def question
@question
end
def answer
@answer
end
def self.ask(q,a)
p "#{q}"
ans= gets.to_i
if a== ans
puts "correct... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.