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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e5c1b6935e9fa46c2952a00c4178324a51d5eea8 | Ruby | caroledou/shoprite | /db/seeds.rb | UTF-8 | 12,758 | 2.890625 | 3 | [] | no_license | require 'open-uri'
require 'json'
puts "Cleaning DB"
Review.destroy_all
Delivery.destroy_all
OrderDetail.destroy_all
Order.destroy_all
User.destroy_all
Composant.destroy_all
Ingredient.destroy_all
Recipe.destroy_all
# ------------------------ USER ------------------------
puts "Creating account carole-albert"
accou... | true |
f3c8dea869a6f63b5bbc6b43ae5d46816db82cae | Ruby | robacarp/nemucod_decrypt | /uncrypt_nemucod/decrypt.rb | UTF-8 | 928 | 2.578125 | 3 | [] | no_license | require 'fileutils'
require_relative 'shared'
module UncryptNemucod
class Decrypt
include Shared
def initialize(crypted_file:, key_file:)
decrypted_file = crypted_file.gsub(/.crypted$/,'')
FileUtils.cp crypted_file, decrypted_file
@decrypted_file = File.open decrypted_file, 'r+b'
@c... | true |
eb51b7a3736cc4e389fd7b6cfa30558292889caf | Ruby | cbronzo/model-class-methods-lab-v-000 | /app/models/captain.rb | UTF-8 | 552 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Captain < ActiveRecord::Base
has_many :boats
def self.catamaran_operators
includes(boats: :classifications).where(classifications: {name: "Catamaran"})
end
def self.sailors
includes(boats: :classifications).where(classifications: { name: 'Sailboat' }).uniq
end
def self.motorboats
includes(boats: :cla... | true |
1155e372abbbabeb1bbcdfd921d115410cff8fe0 | Ruby | zuk/glowstick | /lib/glowstick/glowstick.rb | UTF-8 | 2,135 | 2.8125 | 3 | [
"MIT"
] | permissive | class Glowstick
###########################################################################
# Class
class << self
attr_accessor :graphs
end
self.graphs = []
def self.register(graph)
self.graphs << graph
end
def self.clear
self.graphs.clear
end
##########################... | true |
26943f2d1436308695975ee13a21c4b4b488ad7f | Ruby | eivindhagen/dirscan | /lib/file_pile_dir.rb | UTF-8 | 1,559 | 3.1875 | 3 | [] | no_license | # manages the directory structure for a File Pile
class FilePileDir
private
def dir_structure
[
{path: 'filedata', doc: 'file data, named by content sha256'},
{path: 'metadata', doc: 'meta data, catalog information for each file in the pile'},
{path: 'logs', doc: 'log files, generated b... | true |
5fa81c0cd40c995f9dc5ebf1035bcbd27f99da36 | Ruby | micahstubbs/connections-to-csv | /app/models/user.rb | UTF-8 | 1,838 | 2.609375 | 3 | [] | no_license | class User < ActiveRecord::Base
attr_accessible :email, :provider, :name, :uid
def self.from_omniauth(auth)
where(auth.slice("provider", "uid")).first || create_from_omniauth(auth)
end
def self.create_from_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.name = auth["info... | true |
c4f8e47290d9b3a217431d52b1aa7256d097ede9 | Ruby | arizansari80/C-Programs | /SPOJ/Simple Airtmatic/mult.rb | UTF-8 | 878 | 3.171875 | 3 | [] | no_license | puts "Enter the string";
r=gets;
$arr=r.split("*");
a=$arr[0].to_i;
b=$arr[1].to_i;
c=$arr[1].split("");
r=a*b;
r=r.to_s;
$dash="";
$dashtemp="";
l0=$arr[0].length;
l1=$arr[1].length-1;
$lr=r.length;
if l0>=l1
i=0;
while i<l0 do
$dash+="-";
i+=1;
end
if l0==l1
$dash+="-";
end
else
i=0;
while i<l1 do
$da... | true |
3aad0cad1c9cbc0235ba6dd94ff042196c6ca360 | Ruby | akoltun/form_obj | /lib/form_obj/form/array.rb | UTF-8 | 1,684 | 2.65625 | 3 | [
"MIT"
] | permissive | module FormObj
class Form < FormObj::Struct
class Array < FormObj::Struct::Array
def persisted?
empty? || all?(&:persisted?)
end
def mark_as_persisted
each(&:mark_as_persisted)
end
def mark_for_destruction
each(&:mark_for_destruction)
end
def ma... | true |
27093a7f09a25d7a40a3b54404eb73aa2b140acc | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz38_sols/solutions/Christian Neukirchen/serializableproc.rb | UTF-8 | 670 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'delegate'
class SerializableProc < DelegateClass(Proc)
attr_reader :__code
def initialize(code)
@__code = code.lstrip
super eval("lambda { #@__code }")
end
def marshal_dump; @__code; end
def marshal_load(code); initialize code; end
def to_yaml
Object.instance_method(:to_yaml).bind(s... | true |
2a097847a5aa9cc855c4f462d18918917df902ca | Ruby | drhoten/summerofruby2014 | /week_01/hello/add_it_up.rb | UTF-8 | 541 | 4.25 | 4 | [] | no_license | class AddItUp
# Instance method
def add1
1+1
2+2
3+3
end
# Class method
def self.add2
a=1
b=2
c=a+b
d=4
c
end
def add3
a=1
b=2
return a
c=a+b
end
def self.is_even?(a_number)
a_number.even?
end
print "The result of the first verse is #{AddItUp... | true |
55597c547552a76ac57153189bc2ae305e3a455c | Ruby | brendanthomas1/ruby-blockchain | /blockchain.rb | UTF-8 | 520 | 3.03125 | 3 | [] | no_license | class Blockchain
def initialize
@chain = [Block.new(index: 0)]
end
def chain
@chain.dup
end
def add_block
@chain << Block.new(index: @chain.length, previous_hash: @chain.last.hash)
end
class Block
require 'digest'
attr_reader :hash
def initialize(index:, previous_hash: nil)
... | true |
2923f921d92b2f2d7761d70f237f3c446c13bba0 | Ruby | brianvh/dry-types | /lib/dry/types/definition/hash.rb | UTF-8 | 1,871 | 2.546875 | 3 | [
"MIT"
] | permissive | module Dry
module Types
class Definition
class Hash < Definition
def self.safe_constructor(types, hash)
types.each_with_object({}) do |(key, type), result|
if hash.key?(key)
result[key] = type[hash[key]]
elsif type.is_a?(Default)
result[k... | true |
80f3d5cd09b946a734a92b0036db6f0c78405e14 | Ruby | codyaray/judgeme | /app/helpers/asset_tag_helpers.rb | UTF-8 | 2,417 | 2.578125 | 3 | [] | no_license | # Adapted from SinatraMore: https://github.com/nesquena/sinatra_more/
module AssetTagHelpers
# Creates a link element with given name, url and options
# link_to 'click me', '/dashboard', :class => 'linky'
def link_to(name, url = 'javascript:void(0);', options = {})
options = { :href => url }.merge(options)
... | true |
80cbdd6534d6afe14b9903d1f99983ece8446a47 | Ruby | Davigl/kattis-solutions | /licensetolaunch/solution.rb | UTF-8 | 76 | 3.140625 | 3 | [] | no_license | x = gets.chomp.to_i
y = gets.chomp.split.map(&:to_i)
puts y.index(y.min) | true |
1cf316b34455657e31d87497e89fefe79ac0edf1 | Ruby | wtfspm/advent_of_code | /2019/09/compute.rb | UTF-8 | 366 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative './lib/computer'
if $0 == __FILE__
memory = ARGF.readlines.map(&:strip).first
memory = memory.split(',').map(&:to_i)
computer = Computer.new(memory, [1], [])
computer.compute!
puts "Part 1: #{computer.outputs}"
computer = Computer.new(memory, [2], [])
computer.comp... | true |
2d2c6977ec8d52117cbe24fed31306e713762ae6 | Ruby | Luke-Shepp/Advent-Of-Code-2019 | /Day 4/Part 2.rb | UTF-8 | 274 | 3.4375 | 3 | [] | no_license | count = 0
147981.upto(691423).each do |num|
digits = num.digits
consecutive = digits.each_cons(2).all? { |a, b| a >= b }
double = digits.chunk(&:itself).any? { |_, chunk| chunk.size == 2 }
count += 1 if consecutive && double
end
puts "Answer: #{count}"
| true |
db04bc4aad5dc68796501fa80b0fd13470289533 | Ruby | fumikony/kondate | /lib/kondate/host_plugin/file.rb | UTF-8 | 1,139 | 2.75 | 3 | [
"MIT"
] | permissive | require 'yaml'
module Kondate
module HostPlugin
# YAML format
#
# host1: [role1, role2]
# host2: [role1, role2]
class File < Base
# @param [HashWithIndifferentAccess] config
def initialize(config)
super
raise ConfigError.new('file: path is not configured') unless confi... | true |
9905669503b28b4a7be9b0551872da20dd7abcb2 | Ruby | ColinMcCulloch/battle | /lib/player.rb | UTF-8 | 170 | 3.34375 | 3 | [] | no_license | class Player
STARTING_HP = 50
attr_reader :name, :hp
def initialize(name)
@name = name
@hp = STARTING_HP
end
def reduce_hp
@hp -= 10
end
end
| true |
e54c96f6806c2a0087c13d76191dd1530f32a87e | Ruby | cha63506/fuzed-old | /gems/erlectricity/test/decode_spec.rb | UTF-8 | 4,146 | 3.03125 | 3 | [
"BSD-3-Clause"
] | permissive | require File.dirname(__FILE__) + '/test_helper.rb'
context "When unpacking from a binary stream" do
specify "an erlang atom should decode to a ruby symbol" do
get("haha").should == :haha
end
specify "an erlang number encoded as a small_int (< 255) should decode to a fixnum" do
get("0").should == 0
... | true |
299ac794f4412225cbff42ed27c7fb76a00d51af | Ruby | aar10n/ImageRepository | /server/app/helpers/json.rb | UTF-8 | 3,493 | 3.09375 | 3 | [] | no_license | module Json
module Scope
ROOT = "root"
OBJECT = "object"
ARRAY = "array"
end
class JsonBuilder
def initialize(scope: nil, &block)
@builders = []
@scope = Scope::ROOT
@value = nil
init_scope(scope) unless scope.nil?
instance_eval(&block)
end
def build
... | true |
090d5a8ef5579660c25f71a697688a475343aa8f | Ruby | jentle/pumaServer | /app/models/dcapi.rb | UTF-8 | 1,374 | 2.609375 | 3 | [] | no_license | require 'net/http'
require 'uri'
module DCAPI
SCI_URI = "http://login.etherios.com/ws/sci"
def self.send_data(api_url, data)
url = URI.parse(api_url)
headers = {
'Accept' => 'application/xml'
}
# Create a HTTPRequest Object based on HTTP Method.
req = Net::HTTP::Post.new(url.path, he... | true |
a45717b9079db2fabfed8fa7ede86ed7837f3d36 | Ruby | bendee48/blogger | /app/models/article.rb | UTF-8 | 389 | 2.578125 | 3 | [] | no_license | class Article < ApplicationRecord
has_many :comments
has_many :taggings
has_many :tags, through: :taggings
def tag_list
tags.join(', ')
end
def tag_list=(tag_string)
tag_names = tag_string.split(",").collect { |tag| tag.strip.downcase }.uniq
new_or_found_tags = tag_names.map { |tag| Tag.find_o... | true |
0a84abcf78bb78aabb2a106382f694f36b0b7326 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/robot-name/d760d513d88644bf85b2534e209e779b.rb | UTF-8 | 297 | 3.0625 | 3 | [] | no_license | class Robot
def name
@name ||= random_letter + random_letter + random_three_digit_number
end
def reset
@name = nil
end
private
def random_letter
('A'..'Z').to_a.sample
end
def random_three_digit_number
(0..9).to_a.sample(3).join
end
end
| true |
0030b9b76c852e7931cfb7119f5921bff1a11764 | Ruby | xjvcm/bank_account | /JonathanManzano/bank_account.rb | UTF-8 | 2,077 | 3.453125 | 3 | [] | no_license | class BankAccount
attr_writer :accNum, :name
attr_accessor :chkBal, :savBal, :total
@@count = 0
private
def initialize (name)
@name = name
@chkBal = 0
@savBal = 0
@accNum = bankNumGen
@@count +=1
end
def interest
@interest_rate = rand(0.1..10.9).to_f
end
def bankNumGen
... | true |
b37c60e7aaf454238df4d062928d254ebab7a9d5 | Ruby | whatalnk/cpsubmissions | /atcoder/ruby/arc008/arc008_2/1079935.rb | UTF-8 | 618 | 3.265625 | 3 | [] | no_license | # Contest ID: arc008
# Problem ID: arc008_2 ( https://atcoder.jp/contests/arc008/tasks/arc008_2 )
# Title: B. 謎のたこ焼きおじさん
# Language: Ruby (1.9.3)
# Submitted: 2017-01-27 09:13:59 +0000 UTC ( https://atcoder.jp/contests/arc008/submissions/1079935 )
n, m = gets.chomp.split.map(&:to_i)
names = Hash.new(0)
gets.chomp.sp... | true |
e6974d13b1abbed128b47916e28eaffc49892496 | Ruby | BCerki/math_game | /math_game_planning.rb | UTF-8 | 353 | 3.53125 | 4 | [] | no_license | # player--prompts
# number--parts of the question asked
# lives--each player gets three
# turn--who's getting asked the question
# winner--who's still alive
# goodbye--game over
class Player
def initialize
@lives = 3
@current_player = false
end
end
class Question
def initialize
@number1
@number2
end... | true |
ef78a7c8e79c77235cfc36c0120e3d5ab0be1296 | Ruby | cruzjorge/tutorialruby | /sobreescritura.rb | UTF-8 | 85 | 2.625 | 3 | [] | no_license | require_relative 'clsPerro.rb'
dog = Perro.new('Fido', 'Chiahuahua')
puts dog.ruido
| true |
66c7a90524955d0c610e3c3c9982ad8e59b6b8bd | Ruby | ahuhn14/burner | /lib/burner/util/string_template.rb | UTF-8 | 1,332 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
#
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
module Burner
module Util
# Can take in a string and an object and use the object for formatting ... | true |
24742fac57b46f9a71c45efc366fab2ce368bbc6 | Ruby | londondata/Ruby-Fundamentals | /Sorting Algorithms/insertion_sort.rb | UTF-8 | 297 | 3.34375 | 3 | [
"MIT"
] | permissive | class Array
def insertion_sort
(1...size).each do |n|
value_to_insert = delete_at(n)
insertion_index = n
insertion_index -= 1 while insertion_index > 0 && self[insertion_index - 1] > value_to_insert
insert(insertion_index, value_to_insert)
end
self
end
end
| true |
233947e3defc01e70c125d8796a8d9d060c5ccc4 | Ruby | akr/htree | /test/test-traverse.rb | UTF-8 | 1,744 | 2.59375 | 3 | [
"Ruby"
] | permissive | require 'test/unit'
require 'htree/traverse'
require 'htree/parse'
require 'htree/equality'
class TestTraverse < Test::Unit::TestCase
def test_filter
l = HTree.parse('<a><b>x</b><b/><a/>').make_loc
l2 = l.filter {|n| n.path != 'doc()/a/b[1]' }
assert_equal(HTree.parse('<a><b/><a/>'), l2)
end
def tes... | true |
569ad3d525718a8ea72d37e7f6a775e782dfadc0 | Ruby | maalston/myrubyprograms | /3_week/1e_ten_for_fifty.rb | UTF-8 | 260 | 3.28125 | 3 | [] | no_license | # 1e_ten_for_fifty.rb
#
# Exercise1. Why is the output of this program:
#
def method
a = 50
puts a
end
#
a = 10
method
puts a
#
# The scope of variable "a" inside the method is private and different from the
# variable "a" outside the method definition.
| true |
3ad7268b4368b907d6efa1956a46bc72f40eeb42 | Ruby | deependersingla/ruby_script | /thread.rb | UTF-8 | 1,051 | 3.421875 | 3 | [] | no_license | require 'open-uri' #for open
require 'benchmark'
def conRead(urls) #urls is an array of string
#containing website urls
thread_list = [] #keep track of our threads
urls.each do |f|
thread_list << Thread.new { #add a new thread to
#download each site
open(f) do |x|
x.read
en... | true |
c284846cb97051f1e2e7a58c2a7ca8a2592574e9 | Ruby | mloberg/ReMQ.rb | /lib/ReMQ/Worker.rb | UTF-8 | 2,012 | 2.953125 | 3 | [
"MIT"
] | permissive | module ReMQ
class Worker
# Create a new ReMQ worker.
#
# @param [String] name Optional name of the queue
def initialize(name = nil)
@queues = []
add_queue(name) if name
end
# Return the list of quques that this worker will run.
#
# @return [Array] Array of queues
def ... | true |
01cd311494f1316dcee2eba0d37a827f3883538c | Ruby | martindemello/QBBS | /db/db_bulletins.rb | UTF-8 | 1,853 | 2.96875 | 3 | [] | no_license |
def b_total
res = @db.exec("SELECT COUNT(*) FROM bulletins")
result = single_result(res).to_i
return result
end
def create_bulletin_table
puts "-DB: Creating Bulletins Table"
@db.exec("CREATE TABLE bulletins (name varchar(40), \
locked boolean DEFAULT false, number int, \
modify_date ti... | true |
eefac4f6c2b347ba8db01b724c7b79f31e6058a9 | Ruby | ongaeshi/milkode | /lib/milkode/cdweb/lib/package_list.rb | UTF-8 | 3,032 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | # -*- coding: utf-8 -*-
#
# @file
# @brief パッケージ一覧
# @author ongaeshi
# @date 2012/05/25
require 'milkode/cdweb/lib/database'
module Milkode
class PackageList
VIEW_NUM = 7
ADD_NUM = 5
UPDATE_NUM = 5
FAV_NUM = 7
FAVORITE_LIST_NUM = 7
NEWS_ITEM_NUM = 20
EXCLUDE_UPDATE_SEC ... | true |
005c71cf6956dd09c592bdce1902e648c0649ecd | Ruby | sonata/mongoid | /lib/mongoid/associations/has_one.rb | UTF-8 | 2,742 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Mongoid #:nodoc:
module Associations #:nodoc:
class HasOne #:nodoc:
include Proxy
# Build a new object for the association.
def build(attrs = {}, type = nil)
@target = attrs.assimilate(@parent, @options, type); self
end
# Creates the new association... | true |
6fc903903424d73b533230078262e0f1f06cd867 | Ruby | benmicol/trading-web | /trading-web/lib/scrapping/base_scrapping_parser.rb | UTF-8 | 1,847 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | require File.dirname(__FILE__) + '/../log_util'
module BaseScrappingParser
EMPTY = ''
EMPTY_SPACE = ' '
NA = 'n.a.'
def self.logger= log
@@logger =log
end
attr_reader :soup, :failed
def initialize body
if body.kind_of? BeautifulSoup
@soup = body
else
@soup = BeautifulSoup.ne... | true |
5d27b35b518e3019cf3ddb99bb1f449cb61862fc | Ruby | nettan20/vanity | /lib/vanity/store/mock.rb | UTF-8 | 1,406 | 2.671875 | 3 | [
"MIT",
"CC-BY-4.0"
] | permissive | module Vanity
module Store
# @since 1.3.0
class Mock
@@hash = {}
def initialize(options = {})
end
def get(key)
@@hash[key]
end
alias :[] :get
def set(key, value)
@@hash[key] = value.to_s
end
alias :[]= :set
def del(*keys)
... | true |
b49555a108d030a68a2cd8150177e13cb38ba9f7 | Ruby | tidydee/lhl_web_intructor | /phone_num_exercise/phone.rb | UTF-8 | 2,194 | 3.703125 | 4 | [] | no_license | @data = {
'A' => '2', 'B' => '2', 'C' => '2',
'D' => '3', 'E' => '3', 'F' => '3',
'G' => '4', 'H' => '4', 'I' => '4',
'J' => '5', 'K' => '5', 'L' => '5',
'M' => '6', 'N' => '6', 'O' => '6',
'P' => '7', 'Q' => '7', 'R' => '7', 'S' => '7',
'T' => '8', 'U' => '8', 'V' => '8',
'W' => '9', 'X' => '9', 'Y' =>... | true |
4fe32558b52e8d823bd65dbf3cbaf191bb47f572 | Ruby | gjdame/learning_ruby | /webserver/server3.rb | UTF-8 | 1,124 | 3.140625 | 3 | [] | no_license | require 'socket'
routes = {
"/" => "Hi, thanks for sitting through this guys. I know its the highlight of your week. \n
Other available routes are about and pun",
"/about" => "My middle name is James. I have one sister. I like cheese.",
"/pun" => "6:30 is the best time on a clock. Hands down!"... | true |
9fe163dc0975a2bdd7fd992d47866700179cbf67 | Ruby | yahor/qoolife-api | /lib/qoolife-api/paginated_collection.rb | UTF-8 | 802 | 2.59375 | 3 | [
"MIT"
] | permissive | module QoolifeApi
class PaginatedCollection < ActiveResource::Collection
attr_accessor :first_page, :prev_page, :next_page, :last_page
def initialize(elements = [])
@elements = elements
response = QoolifeApi::Base.connection.http_response
response = pagination_header_response_to_has... | true |
357fadd7156a96b89e26c370a4846ba77c634f83 | Ruby | TheGuth/launch_school | /launch_school_review/ruby_oop_book/inheritance_exercises.rb | UTF-8 | 4,898 | 4.3125 | 4 | [] | no_license | # Exercise 1.
# Create a superclass called Vehicle for your MyCar class to inherit from and move the
# behavior that isn't specific to the MyCar class to the superclass. Create a constant
# in your MyCar class that stores information about the vehicle that makes it different
# from other types of Vehicles.
# Then... | true |
9674a48841987d2a544c6734e2bd28dce8b41ff2 | Ruby | CodingSoeren/client-ruby | /spec/support/game_state_helpers.rb | UTF-8 | 1,483 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../lib/software_challenge_client/util/constants'
require_relative '../../lib/software_challenge_client/color'
module GameStateHelpers
include Constants
class BoardFormatError < StandardError
end
def field_from_descriptor(coordinates, descriptor)
piece =... | true |
5693a11f5bc470f0574df083eda1a047efe85ee5 | Ruby | Rae-Kwon/bubble-sort | /bubblesort.rb | UTF-8 | 355 | 3.609375 | 4 | [
"MIT"
] | permissive | def bubble_sort (array)
length = array.length
(0..length - 2).each do |index|
(0..length - index - 2).each do |curr|
if array[curr] > array[curr + 1]
array[curr + 1], array[curr] = array[curr], array[curr + 1]
end
end
end
p array
end
array = [4, ... | true |
cca7904551a1f7261e80d83ec50b0c12895d0720 | Ruby | dkotvan/challenge | /backend/models/product.rb | UTF-8 | 850 | 3.015625 | 3 | [] | no_license | class Product
# use type to distinguish each kind of product: physical, book, digital, membership, etc.
attr_reader :name, :type
def initialize(name:, type:)
@name, @type = name, type
end
def shippable?
false
end
end
class PhysicalProduct < Product
def initialize(name:)
super(name: name, ty... | true |
56b6bfc17dd499cac36741841e70e2d83a02aacd | Ruby | ktcannell/ttt-game-status-v-000 | /lib/game_status.rb | UTF-8 | 1,215 | 3.953125 | 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 row
[3,4,5], # Middle row
[6,7,8],# Bottom row
[0,4,8],# Diagonal left to right
[2,4,6],# Diagonal right to left
[0,3,6],# First co... | true |
844ef704d8d20d0392b2c2381c294d0518ce002c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/nucleotide-count/4ae36b43f73544bfb334c96c26e75207.rb | UTF-8 | 402 | 3.421875 | 3 | [] | no_license | class Nucleotide
DNA = ['A', 'C', 'G', 'T']
class << self
alias_method :from_dna, :new
end
def initialize(input)
raise ArgumentError if input.match(/[^#{DNA.join('')}]/)
@dna = input
end
def count(input)
@dna.count(input)
end
def histogram
DNA.each_with_object Hash.new do |nucleo... | true |
a11057a43f7d4caba6b01cd46146a7cf512c0792 | Ruby | svanderbleek/stocksy | /test/models/stock_test.rb | UTF-8 | 525 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class StockTest < ActiveSupport::TestCase
test "trend up/down" do
up_arrow = '^'
down_arrow = 'v'
up_trend = stocks(:one).trend(up: up_arrow, down: down_arrow)
down_trend = stocks(:two).trend(up: up_arrow, down: down_arrow)
no_trend = Stock.new.trend(up: up_arrow, down: dow... | true |
27edfb677ed35a5d4a978f5756d60cfadf7ae8df | Ruby | velvelshteynberg/Practicingruby | /firstmethod.rb | UTF-8 | 1,569 | 4.65625 | 5 | [] | no_license | #first method: the def is the defintion of the method
# def hey
# puts "Hello"
# end
# hey
# puts "It is a great day"
# hey
# puts "Have fun"
# hey
# def ask_name
# puts "What is your name?"
# my_name = gets.chomp
# end
# ask_name
# if my_name == nil
# ask_name
# else
# puts "hello"
# end
... | true |
08b5d2c32500a87de66847981125eadbab26aee9 | Ruby | byu/serf | /lib/serf/middleware/parcel_freezer.rb | UTF-8 | 536 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'ice_nine'
require 'optser'
module Serf
module Middleware
##
# Middleware to add uuids to freeze the parcel.
#
class ParcelFreezer
attr_reader :app
attr_reader :freezer
##
# @param app the app
#
def initialize(app, *args)
opts = Optser.extract_options! args
@app = ... | true |
a5065ebe211606d454ef26b6ed4d2eabd8195207 | Ruby | VulnerabilityHistoryProject/vulnerability-history | /lib/taggers/bounty_tagger.rb | UTF-8 | 1,170 | 3.171875 | 3 | [
"MIT"
] | permissive | require_relative '../writing'
class BountyTagger
def initialize
end
def create_tags
@bounty_tag = Tag.find_or_create_by!(
name: 'Bounty Awarded',
shortname: 'bounty',
color: '#25C322',
icon: 'money',
description: Writing.tag_article('bounty'),
family: 'bounty'
)
en... | true |
5c4cba4adb797b8dc10e131fa14f79befea38867 | Ruby | RickCarlino/NMEA-Geo-Tagger | /main.rb | UTF-8 | 1,258 | 3.1875 | 3 | [] | no_license | require "nmea_plus"
require "rubyserial"
# === CONFIGURATION ===
# You can change these if you need to, but make sure you
# understand what you're changing.
GPS_PORT = ENV["GPS_PORT"] || "/dev/ttyACM0"
FILE_LOCATION = "geo.csv"
CSV_HEADERS = "" # <= Customize this
# === DATA INITIALIZATION ===
decoder = NMEAPlus::De... | true |
99c1bdfc02f0d9f46bbcaa4bf39659398bb7011f | Ruby | jdeepee/holbertonschool-sysadmin_devops | /use_a_regular_expression_against_a_problem_now_you_have_2_problems/0-letters_and_numbers.rb | UTF-8 | 78 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby
arg = ARGV[0].dup
out = arg.gsub!(/[^0-9a-zA-Z]/, '')
puts out | true |
70e2c992e638a05aa85f8e9b6b59585ba295a1c6 | Ruby | upinetree/depcop | /lib/depcop/rule/efferent_couplings.rb | UTF-8 | 710 | 2.59375 | 3 | [
"MIT"
] | permissive | module Depcop
module Rule
class EfferentCouplings
CONFIG_DEFAULTS = { "Max" => 5 }
def initialize(nodes, edges, config)
efferent_deps = Hash[nodes.map { |n| [n.join("::"), []] }]
edges.each do |edge|
to = edge["to"].join("::")
from = edge["from"].join("::")
... | true |
fe62becd42a09e3bffda28d40338539ae8bc7041 | Ruby | bhavikakhare/link-to-jobs | /test/models/company_test.rb | UTF-8 | 2,667 | 2.5625 | 3 | [] | no_license | # == Schema Information
#
# Table name: companies
#
# id :bigint not null, primary key
# address :string
# avg_rating :decimal(, )
# count_ratings :integer
# description :text
# email :string
# name :string
# phone_number :bigint
# size ... | true |
eb5dbf03c2952c43e9aa42210bba7cc976323541 | Ruby | JeremyVe/danebook | /spec/models/user_spec.rb | UTF-8 | 1,882 | 2.625 | 3 | [] | no_license | require 'rails_helper'
describe User do
let(:user){ create(:user) }
context "validation" do
it "should be valid with common attributes" do
expect(user).to be_valid
end
it "should not be valid if email is missing" do
invalid_email = [nil, "", " "]
invalid_email.each do |email|
... | true |
e7a6d43e5efe925cfb5ec0b3299029208ddcd4bd | Ruby | justed-tests/rails-api | /app/models/order.rb | UTF-8 | 460 | 2.734375 | 3 | [] | no_license | # order for tables =)
class Order < ApplicationRecord
belongs_to :table
has_many :order_items
has_many :items, through: :order_items
def build_new_item(params)
existing_item = OrderItem.find_by(order: self, item_id: params[:item_id])
if existing_item
existing_item.increment(:quantity)
else
... | true |
67077e2f5569d1457356a20f300eacb218d260a2 | Ruby | jomno/How-Do-Rails-Work | /http/response/test/file_steam.rb | UTF-8 | 118 | 2.90625 | 3 | [] | no_license | File.open("test", "rb") do |file|
while chunk = file.read(12)
puts chunk
puts "hi"
sleep(0.5)
end
end
| true |
5b0f13f4fe97db00d50bf3f0060979e95464f659 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/leap/c4dd0831ec02443c8d6de9e88538a6ad.rb | UTF-8 | 297 | 3.40625 | 3 | [] | no_license | class Year
def initialize(year)
@year = year
end
def leap?
exceptional_century? || (vanilla_leap_year? && not_century)
end
def vanilla_leap_year?
@year % 4 == 0
end
def exceptional_century?
@year % 400 == 0
end
def not_century
@year % 100 != 0
end
end
| true |
3deb49f5ca543c973ae6a6a3e92486a218bb7309 | Ruby | akami11/Dmm-PF | /app/controllers/sorts_controller.rb | UTF-8 | 849 | 2.578125 | 3 | [] | no_license | class SortsController < ApplicationController
# ソート機能やり方は検索機能と同じ、orderメソッドで降順、昇順が選べるよ
# ASCが昇順「1、2、3、・・」、DESCが降順「10、9、8・・・」
def sort
@nutrition = params["nutrition"]
@updown = params["updown"]
@conclude = sort_for(@nutrition,@updown).page(params[:page]).per(12)
@categories = Category.all
@t... | true |
b6cd0bf17693c104a0c2dbf984e72ae30636393e | Ruby | rafaeldwan/learn_to_program | /variables/name.rb | UTF-8 | 426 | 3.359375 | 3 | [] | no_license | puts "I ALWAYS NEED NAMES. NOW IS WHEN YOU GIVE ME A FIRST NAME."
first_name = gets.chomp
puts "LAST NAME IS ALSO REQUIRED."
last_name = gets.chomp
name = first_name + " " + last_name
puts "THANK YOU SO MUCH #{name.upcase}. I AM FOREVER IN YOUR DEBT."
filename = "names.txt"
File.open(filename, 'a') do |file|
file.p... | true |
1e675e755a877f5e2194977b3d29b3fb322bf89e | Ruby | shinara03/aa_classwork | /w4d5/octopus_hw.rb | UTF-8 | 1,221 | 3.890625 | 4 | [] | no_license | #['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
#=> "fiiiissshhhhhh"
# Sluggish Octopus O(n^2)
def sluggish_octopus(arr)
longest = arr[0]
arr.each_with_index do |ele1, idx1|
arr.each_with_index do |ele2, idx2|
if ele2.length > ele1.length
longest = ar... | true |
7887269498b5674774d7adec4c70856b16393e67 | Ruby | chintas1/ormproject | /app/views/user/display_fav_movie.rb | UTF-8 | 123 | 2.6875 | 3 | [] | no_license | class DisplayFavMovieView
def render(movie)
puts "\nYour favorite movie is currently set as: #{movie.name}"
end
end | true |
429a5ee00e1a5566c64c2fdc8c826e4e63118297 | Ruby | Pennylele/Ruby | /script5.rb | UTF-8 | 932 | 4.3125 | 4 | [] | no_license | print "Thstring, pleathe!: "
user_input = gets.chomp
user_input.downcase!
if user_input.include? "s"
user_input.gsub!(/s/, "th")
else
puts "Nothing to do here!"
end
puts "You string is: #{user_input}"
#We can do that using Ruby's .include? method, which evaluates to true if it finds what it's looking for and false... | true |
4daac4107fdd43f43d9d97709e0f7fdddc6933f5 | Ruby | stevenbeales/ehr-march | /api/lib/activation.rb | UTF-8 | 163 | 2.875 | 3 | [] | no_license | module Activation
def self.code(size = 5)
(0...size).map{ (1..9).to_a.sample }.join
end
def self.colour
SecureRandom.hex(3).upcase
end
end | true |
369aaca8915a504a7bb6906a78f451c9d2663881 | Ruby | pagood/micropost | /test/models/user_test.rb | UTF-8 | 932 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
@user = User.new(email:'111',password: '123',password_confirmation: '123')
@user2 = User.new(email:'123@qq.com',password: '123456',password_confirmation: '123456')
@user3 = User.new(... | true |
91564ea02fe5fb84c10aaa6be6c03a671f62d97a | Ruby | kola22/Ruby | /ruby.tmbundle-master/Support/vendor/rcodetools/test/data/attic/rspec-output.rb | UTF-8 | 1,360 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Ruby",
"LicenseRef-scancode-boost-original"
] | permissive | class X
Y = Struct.new(:a)
def foo(b)
; b ? Y.new(2) : 2
end
def bar;
raise "No good"
end
def baz;
nil
end
def fubar(x)
; x ** 2.0 + 1
end
def babar;
[1, 2]
end
A = 1
A = 1 # !> already initialized constant A
end
describ... | true |
010a0d6d1d77c539a65977e5820d21ad9c51dd6d | Ruby | arver/arver | /lib/arver/node_with_script_hooks.rb | UTF-8 | 881 | 2.59375 | 3 | [
"MIT"
] | permissive | module Arver
module NodeWithScriptHooks
attr_accessor :pre_open, :pre_close, :post_open, :post_close
def script_hooks_to_yaml
yaml = ""
yaml << "'pre_open': '#{pre_open}'\n" unless pre_open.nil?
yaml << "'pre_close': '#{pre_close}'\n" unless pre_close.nil?
yaml << "'post_open': '#{pos... | true |
f2d17c56a0d0e16df05d307c34ee99276e171138 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/secret-handshake/3da4611b38e546008cc368280efa27ea.rb | UTF-8 | 377 | 3.328125 | 3 | [] | no_license | class SecretHandshake
attr_reader :commands
def initialize(n)
if n.is_a?(Integer)
digits = n.to_s(2).reverse
ops = ["wink", "double blink", "close your eyes", "jump", nil]
@commands = digits.chars.map.with_index { |d, i| d == "1" ? ops[i] : nil }.compact
@commands.reverse! if digits.len... | true |
7fc44d497517c462aae0b50ee9b7d82142c84304 | Ruby | alphagov-mirror/vcloud-converter | /bin/convert | UTF-8 | 732 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "bundler/setup"
require "vcloud/converter"
require "optparse"
ARGV << '-h' if ARGV.empty?
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: ./bin/convert -t vcloud-net_launcher -p path/to/file.yaml"
opts.on('-t', '--type TYPE', 'Type of YAML file for conversion.') { |v| op... | true |
ad7f6445ec64848492332c108eb3ba3efab8de44 | Ruby | speckworks/programming-univbasics-3-labs-with-tdd-dumbo-web-82619 | /calculator.rb | UTF-8 | 228 | 2.890625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Add your variables here
first_number = a
second_number = b
second_number != 0
sum = a + b
product = a * b
difference = a - b
quotient = a/b
a = gets.chomp
b = gets.chomp
puts sum
puts product
puts difference
puts quotient
end
| true |
c5360513eff0b9894bee63f6391fe9ab8d749696 | Ruby | jesus9ias/exercises | /diceware/diceware.rb | UTF-8 | 488 | 3.625 | 4 | [] | no_license | require "json"
puts "How many words do you want?"
tot_words = gets.chomp
tot_dice = tot_words.to_i * 5
rand_nums = []
num_keys = []
wordlist = File.read('wordlist.json')
word_hash = JSON.parse(wordlist)
words = {}
tot_dice.times{ rand_nums << rand(1..6) }
rand_nums = rand_nums.each_slice(5).to_a
num_keys = rand_nu... | true |
49e48568381ed979c2d1a99041208f62ab7cbe30 | Ruby | jmromer/vendtriloquist | /app/models/money.rb | UTF-8 | 1,440 | 2.75 | 3 | [] | no_license | # coding: utf-8
# frozen_string_literal: true
require "models/application_record"
require "services/change_maker"
require "utils/counter"
require "utils/currency"
class Money < ApplicationRecord
VALID_DENOMINATIONS = [
2_00,
1_00,
50,
20,
10,
5,
2,
1,
].freeze
validates :denomin... | true |
d0ce1f602dabbab863b3768ac7deb93beb6b734c | Ruby | Archeia/iek | /lib/iek/xpresso/xpresso.rb | UTF-8 | 1,370 | 3.25 | 3 | [] | no_license | # The simpliest script for 'mixing' items
module IEK
class Xpresso
class MixResultItem
attr_accessor :kind
attr_accessor :id
attr_accessor :number
def initialize(kind, id, number)
@kind, @id, @number = kind, id, number
end
def item
case @kind
when 0
... | true |
5efce94a61fe4af841b0467ee812956c10319600 | Ruby | bluespheal/etapa3 | /semana1/miercoles/gallinita_tdd/lib/laying_hen.rb | UTF-8 | 317 | 3.65625 | 4 | [] | no_license | class LayingHen
attr_reader :age, :basket
def initialize(age = 0)
@age = 0
@basket=[]
end
# Ages the hen one month, and lays 4 eggs if the hen is older than 3 months
def age!
@age += 1
if @age >= 4
4.times {@basket << Egg.new}
end
end
end
class Egg
end
| true |
6b878a6367cb4184615e48d911d7ab15eb877610 | Ruby | crazycode/cap-recipes | /test.rb | UTF-8 | 2,868 | 2.75 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require "net/http"
require "uri"
require "json"
class CmdbService
def self.get_app_role(cse_base, unit_code, stage)
url = "#{cse_base}/deploy/get-server.do?deployUnitCode=#{unit_code}&stage=#{stage}"
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
# we convert... | true |
1f2784c141ad4206a9b74e763250432d74019c47 | Ruby | clintonjnelson/twitteresque_webapp_rails | /app/controllers/users_controller.rb | UTF-8 | 3,086 | 2.53125 | 3 | [] | no_license | class UsersController < ApplicationController
# We can use whatever the before filter avails to us - IV's, etc. (See "edit")
before_filter :signed_in_user, only: [:edit, :update, :index,
:followers, :following]
before_filter :correct_user, only: [:edit, :update]
... | true |
b428d979a84d1a2700bf1cf02ec3b3b8a4cc969c | Ruby | thebravoman/software_engineering_2013 | /class6_belt_exam/Hristiqn_Zarkov_1.rb | UTF-8 | 385 | 2.84375 | 3 | [] | no_license | require 'csv'
all = Array.new()
CSV.foreach(ARGV[0]) do |row|
val = row[4].split(" ")
if (val[0] == ARGV[1])
all << [row[0],row[1],row[2],row[3],row[4],row[5]]
end
end
CSV.open("bank_result.csv","w") do |csv|
all.sort_by{|a,b,c,d,e,f| c}.each do |row|
cs... | true |
768d9b0ce560322a67fc7a1eb47306f55172c6f3 | Ruby | MichaelCrockett/snowman | /spec/player_spec.rb | UTF-8 | 673 | 2.75 | 3 | [] | no_license | require ('minitest/autorun')
require ('minitest/rg')
require_relative ('../player')
require_relative ('../game')
require_relative ('../hidden_word')
class TestPlayer < MiniTest::Test
def setup
@player1 = Player.new("Jo")
end
def test_has_lives?
assert_equal(true, @player1.has_lives?)
end
def test... | true |
54a123c217cda41ac7e7496d4075132f05d7b746 | Ruby | sshaw/explain-dependencies | /lib/xdep.rb | UTF-8 | 2,857 | 2.75 | 3 | [
"MIT"
] | permissive | require "fileutils"
require "tempfile"
require "xdep/npm"
require "xdep/ruby"
require "xdep/version"
class XDep
Error = Class.new(StandardError)
REPORT_BASENAME = "dependencies".freeze
REPORT_EXTENSION = ".explained".freeze
FORMAT_HANDLERS = {
:csv => [ Bundler::CSVOutput, RubyGems::CSVOutput, Npm::C... | true |
9d247a3101bee81cb21cd55ba8ade2f0547dfd45 | Ruby | mashiro-no-rabo/githubVisual | /cook_data.rb | UTF-8 | 1,322 | 2.65625 | 3 | [] | no_license | # encoding: utf-8
require 'rubygems'
require 'redis'
require 'byebug'
@days = [31,28,31,30,31,30,31,31,30,31,30,31]
@redis = Redis.new(port: 7755)
# calc jan hours
def calc_jan_hours
tmp = []
24.times { tmp << 0}
(1..31).each do |day|
(0..23).each do |hour|
hdata = @redis.hgetall "2013-1-#{day}-#{hou... | true |
42d3010ce16d7d160909c7a1dde68b95b21c4dc2 | Ruby | WeatherVine/back_end | /spec/services/wine_service_spec.rb | UTF-8 | 1,727 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
require 'ostruct'
RSpec.describe WineService do
describe 'happy path' do
it 'fetches wine data and returns the correct object' do
VCR.use_cassette("wine_microservice_fetch") do
response = WineService.fetch_wine("5f065fb5fbfd6e17acaad294")
expect(response).to be_an(O... | true |
1d8f00e7c3620fdf6334de4d3c3cb7a49923d667 | Ruby | albertbahia/wdi_june_2014 | /w01/d05/jon_porras/main_pokemon.rb | UTF-8 | 777 | 2.765625 | 3 | [] | no_license | require 'pry'
require_relative 'pokemon.rb'
require_relative 'trainer'
require_relative 'nurse.rb'
charmander = Pokemon.new("Charmander", 004, "fire", 39, 52, 43, 65)
pikachu = Pokemon.new("Pikachu", 025, "electric", 35, 55, 40, 50)
squirtle = Pokemon.new("Squirtle", 007, "water", 44, 48, 65, 50)
croconaw = Pokemon.n... | true |
bf6437d70bc5f4b05a47afada45b454f41a9e40d | Ruby | sugye/prolabo201610 | /takarunn.rb | UTF-8 | 1,526 | 3.34375 | 3 | [] | no_license | sleep 1
$scene = 'select1'
$kuzi = 0
$ret = 0
def story_do(paramsa,paramsb,question,reanswer,goa,gob)
case $scene
when 'select1'
puts "#{question}"
sleep 1
puts "選択肢 a:#{paramsa}, b:#{paramsb}"
#①フ繰り返し(~の間)
while true
input_country = gets
case input_country.chomp
when 'a'
... | true |
f9ab4db581d91fcb96f376519e466139ed27c17c | Ruby | markus851/eddy | /lib/definitions/segments/generated/n3.rb | UTF-8 | 1,234 | 2.734375 | 3 | [
"MIT"
] | permissive | module Eddy
module Segments
# ### Segment Summary:
#
# - Id: N3
# - Name: Address Information
# - Purpose: To specify the location of the named party
class N3 < Eddy::Models::Segment
# @param store [Eddy::Data::Store]
# @return [void]
def initialize(store)
@id = "N3"... | true |
fe8e230b140fc1714f51222934c93e41f9afccf5 | Ruby | postace/ruby | /lrthw/alias_sample.rb | UTF-8 | 425 | 3.25 | 3 | [] | no_license | # Introduce to alias
class CelestialBody
attr_accessor :type, :name
end
# Hash default blocks
bodies = Hash.new do |hash,key|
# Create new object for current key
body = CelestialBody.new
body.type = "planet"
# Assign to the hash and returns the new value
hash[key] = body
end
bodies['Mars'].name = 'Mars'
... | true |
83146822fd60d4d39d3c27cc03a543123a3db2d2 | Ruby | jsuchy/brewbook | /features/step_definitions/create_recipe_of_grains_steps.rb | UTF-8 | 836 | 2.734375 | 3 | [] | no_license | require 'brewery/use_cases/calculate_strike_temperature_and_volume'
Given /^I need (\d*\.?\d+) pounds of grain$/ do |pounds|
@pounds = pounds.to_f
end
Given /^I need (\d*\.?\d+) ounces of grain$/ do |ounces|
@ounces = ounces.to_f
end
Given /^a target mash temperature of (\d+)$/ do |temp|
@target_temp = temp.to... | true |
b2542330a3d9fd48b43928c52add83f654c383b0 | Ruby | Gevanstron/triangle-classification-v-000 | /lib/triangle.rb | UTF-8 | 881 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Triangle
attr_accessor :first_side, :second_side, :third_side, :equilateral, :isosceles, :scalene
def initialize(first_side, second_side, third_side)
@first_side = first_side
@second_side = second_side
@third_side = third_side
end
def kind
if first_side <= 0 || second_side <= 0 || third... | true |
d818d4cb448ed176558ebda7d09e9e5ed4d513f9 | Ruby | iomaraa/hw_week_07_day_01_Ruby_Loops | /rubyhw.rb | UTF-8 | 1,982 | 3.203125 | 3 | [] | no_license | # x = (1..20).to_a
# puts x
# Question 1
# i = 1
# while i < 21 do
# p i
# i = i +1
# end
# Question 2
# x = 0
# while x < 201 do
# if x % 2 == 0
# p x
# end
# x = x +1
# end
# Question 3
# wolfy = ["Wolfy", "wolf", 16, "Yukon Territory"]
# sharky = ["Sharky", "shark", 2... | true |
fffc95007f7260e1d97b113d072e47737d935c49 | Ruby | rainbough/class-day-1 | /bank.rb | UTF-8 | 3,028 | 4.03125 | 4 | [] | no_license | class BankAccount
def initialize
@balance = 0.00
puts "What is the first name on this account?"
@first_name = gets.chomp
puts "What is the last name on this account?"
@last_name = gets.chomp
puts "Please deposit money into this account."
@available_credit = 10000.00
@credit_balance = 0.00
end
def de... | true |
e82ace0e79fc548d3557778bda408ea937812faf | Ruby | Carlumbo/programming-univbasics-4-array-simple-array-manipulations-online-web-prework | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 1,132 | 3.578125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def using_push(colors_of_the_rainbow, next_color)
next_color = "violet"
updated_array = colors_of_the_rainbow.push(next_color)
end
def using_unshift(bouroughs_in_nyc, new_neighborhood)
new_neighborhood = "Staten Island"
updated_array = bouroughs_in_nyc.unshift(new_neighborhood)
end
def using_pop(contenients)
... | true |
2620f82a8e468821ff5d04e444895815c1da5a39 | Ruby | kares/ruby_speech | /lib/ruby_speech/grxml/item.rb | UTF-8 | 5,110 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'ruby_speech/xml/language'
module RubySpeech
module GRXML
##
#
# The item element is one of the valid expansion elements for the SGR rule element
#
# http://www.w3.org/TR/speech-grammar/#S2.4 --> XML Form
#
# The item element has four (optional) attributes: weight, repeat, repea... | true |
0efa8ce56d3e7aba2855cd6a1b12c6965f3726fb | Ruby | shaneoston72/takeaway-challenge | /lib/order.rb | UTF-8 | 510 | 2.96875 | 3 | [] | no_license | class Order
attr_reader :time, :order
def initialize(menu)
@time = Time.now
@order = {}
@menu = menu
end
def add_item(dish, quantity)
dish = dish.downcase.to_sym
@order[dish] = quantity if @menu.on_menu?(dish)
end
def total
total = 0
@order.each do |dish, quantity|
tota... | true |
b9dd851615039e1608b16c791874a4454281ea43 | Ruby | akicho8/albatro | /lib/albatro/graphviz_support.rb | UTF-8 | 6,129 | 2.625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require "fileutils"
require "pathname"
module Albatro
module GraphvizSupport
def initialize(*)
super
@@gv_auto_index ||= 0
@@gv_auto_index += 1
@gv_id = @@gv_auto_index
end
#
# 文字列やPNGやバイナリを返す
#
# to_dot #=> dot_as_stri... | true |
6404d664eb61ed20027e184175955f366bef9bfb | Ruby | joshado/triton-internal-gem | /spec/api_base_spec.rb | UTF-8 | 11,811 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe "ApiMapping" do
let(:fakeapi) do
Class.new(Triton::ApiBase) do
self.name = "fakeapi"
call("TestMethod", {
:method => :post,
:path => "/testmethod/path"
})
call("GetMethod", {
:path => "/testmethod/path"
})
call("Get... | true |
19a03c64ec9f4c11169197adcfefed5ba2af12bc | Ruby | powersjcb/notes | /w1-review/merge_sort.rb | UTF-8 | 481 | 3.953125 | 4 | [] | no_license | require 'byebug'
class Array
def merge_sort
return self if count < 2
left, right = self.take(count/2), self.drop(count/2)
merge(left.merge_sort, right.merge_sort)
end
def merge(left, right) # merges two sorted arrays onto the end of Array
merged_array = [ ]
until left.empty? || right.empty... | true |
7eab7609b10d9126ac8f7a312ce8e8277f93aaf0 | Ruby | jamesdphillips/throttling | /lib/throttling/limit.rb | UTF-8 | 1,190 | 2.859375 | 3 | [
"MIT"
] | permissive | module Throttling
class Limit
attr_accessor :name, :interval, :limit, :values, :default_value
def initialize(name, opts = {})
self.name = name
self.interval = opts[:period].to_i
self.limit = opts[:limit].nil? ? nil : opts[:limit].to_i
self.values = opts[:values]
... | true |
e2904c11be064bc3201c8b9dfc570fc398622ef8 | Ruby | makevoid/jasonette-roda-app | /comp/audio.rb | UTF-8 | 571 | 2.578125 | 3 | [] | no_license |
def Audio(url:, text: "Play >", type: "label", feature: {})
{
"type": type,
"text": text,
"action": {
"type": "$audio.play",
"options": {
"url": url
}
}
}.merge feature
end
# from the default example - head.actions
#
# {
# actions: {
# hahaha: {
# type: "$audi... | true |
e7faf018dced0a1c5cac29f4fb97251b80bc60dd | Ruby | YizheWill/aA_Classwork | /W4D5/two_sum_problem.rb | UTF-8 | 1,360 | 3.921875 | 4 | [] | no_license | def bad_two_sum?(array, target)
(0...array.length-1).each do |idx1|
(idx1+1...array.length).each do |idx2|
return true if array[idx1] + array[idx2] == target
end
end
false
end
arr = [0, 1, 5, 7]
# p bad_two_sum?(arr, 6) # => should be true
# p bad_two_sum?(arr, 10) # => should be false
def ok_two_... | true |
b66dc0addb331cb8834c04a631f9106bab9cbb78 | Ruby | hj1994412/teleost_genomes_immune | /S23_S25_MHC_I_target_sequence_generation_and_read_count/scripts/produce_majority_rule_consensus.rb | UTF-8 | 3,292 | 3.609375 | 4 | [] | no_license | # This script produces majority rule consensus sequences from aligned fasta files.
# Run this with like
# ruby produce_majority_rule_consensus.rb -f inputfilename -o outputfilename
class String
def identical_with(str)
return false unless str.class == String
str1 = self.downcase
str2 = str.downcase
identical =... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.