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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0162647e2035bb4259cbd7a627cff178c1c0d88c | Ruby | aneeshkhera/sp16-hw2 | /app/controllers/concerns/persons.rb | UTF-8 | 320 | 3.828125 | 4 | [] | no_license | class Person
def initialize(name, age)
@name = name
@age = age
@nickname = name[0,4]
end
def nickname
return @nickname
end
def birth_year
curr = Time.now.year
curr - @age.to_i
end
def introduce
"Hello, My name is " + @name.to_s + " and I am " + @age.to_s + " years old"
end
end | true |
bd5f200368c254c14b5abf49e80d6d8fa7a4428e | Ruby | winber2/sql | /reply.rb | UTF-8 | 1,004 | 2.84375 | 3 | [] | no_license | require_relative 'questions'
class Reply < ModelBase
attr_accessor :id, :question_id, :parent_id, :author_id, :body
def initialize(options)
@author_id = options['author_id']
@question_id = options['question_id']
@parent_id = options['parent_id']
@body = options['body']
@id = options['id']
en... | true |
73738fe58d6e091c5b93cfc18977366f696a5215 | Ruby | 18F/ruby-saml | /lib/onelogin/ruby-saml/logoutresponse.rb | UTF-8 | 8,645 | 2.578125 | 3 | [
"MIT"
] | permissive | require "xml_security"
require "onelogin/ruby-saml/saml_message"
require "time"
# Only supports SAML 2.0
module OneLogin
module RubySaml
# SAML2 Logout Response (SLO IdP initiated, Parser)
#
class Logoutresponse < SamlMessage
# OneLogin::RubySaml::Settings Toolkit settings
attr_accessor :s... | true |
8c533248fab0ecf58355c84e6b0702f852b3299e | Ruby | RJTaylor8286/ruby-objects-has-many-through-lab-online-web-pt-110419 | /lib/patient.rb | UTF-8 | 256 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Patient
attr_accessor :appointment, :doctor
@@all = []
def initialize(appointment, doctor)
@appointment = appointment
@name = name
@@all << self
end
def self.all
@@all
end
end
ferris = Patient.new("Ferris Bueller")
| true |
fbc245b5ea879b49b14bac3a65e2bc564731e09b | Ruby | byungminsa/cucumber-template | /features/step_definitions/general_steps.rb | UTF-8 | 1,124 | 2.765625 | 3 | [] | no_license | #Data hash to store the IDs of all editable fields
fields = {
}
When /^I visit "(.*)"$/ do |site|
visit site
end #Navigates to site
When /^I wait "(.*)"$/ do |time|
sleep(time.to_i)
end #Pauses execution, typically to allow elements to fully load
When /^I should see "(.*)"$/ do |content|
page.should have_content... | true |
118a8340a9f2d066d92fad628055fcad073ec33f | Ruby | danajackson2/cli-applications-simple-blackjack-sea01-seng-ft-111620 | /lib/blackjack.rb | UTF-8 | 825 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
rand(1...11)
end
def display_card_total(num)
puts "Your cards add up to #{num}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
gets.chomp
end
def end_game(num)
puts "Sorry, you hit #{num}. Thanks for p... | true |
1a75c822d25d3189e3ad96fc0c4217b0dcc1474c | Ruby | jfigueras/duckduckgoose | /it.rb | UTF-8 | 718 | 3.015625 | 3 | [] | no_license | class It < Player
attr_reader :name, :goose, :nplayer
attr_accessor :speed, :energy, :arms, :nplayer
def post_initialize(args)
@nplayer = args[:nplayer]
@goose = _choose_goose
end
def introduction
puts "player #{name} is the IT"
puts "It has energy #{self.energy} energy"
end
def... | true |
6d0e750028a52fa721183129133bebc7d10459d5 | Ruby | lequangcanh/blog_korea | /app/forms/post_form.rb | UTF-8 | 1,915 | 2.59375 | 3 | [] | no_license | class PostForm
include ActiveModel::Model
attr_accessor :status, :translation_title, :translation_content, :language_id, :user_id,
:post, :post_translation
validates :status, presence: true
validates :translation_title, presence: true
validates :translation_content, presence: true
def initialize args... | true |
5c2531862dbe3d74b234909d99e375a63ff8f0da | Ruby | jskrwc/sep-assignments | /02-algorithms-and-complexity/02-algorithms-searching/fibonacci_iterative.rb | UTF-8 | 353 | 3.15625 | 3 | [] | no_license | def fib_i(n)
return 0 if n == 0 # needed bc fib(0) = 0***
fib_0 = 0
fib_1 = 1
(0..n-2).each do # can correct by using n-2, fixes fib(1) as well
temp = fib_0
fib_0 = fib_1
fib_1 = temp + fib_1
end
fib_1
end
## *** NOTE most fibonacci code examples start from 1, so 1,1,2,...
# h... | true |
0f2264a53bb1a87df1ea901a87fea56c7412ea05 | Ruby | rcjara/Random-Twitter | /lib/TwitterConnector.rb | UTF-8 | 1,191 | 2.78125 | 3 | [] | no_license | require 'twitter'
require File.expand_path(File.dirname(__FILE__) + '/SimpleConfigParser')
class TwitterConnector
attr_reader :username
include SimpleConfigParser
def initialize(config_path)
parse_config_file(config_path, :username, :password)
end
def tweet(post)
raise "Not logged on" unless... | true |
6a5a3c4131b937d3b563344d7da1264f8965f269 | Ruby | hmcts/hwf-calculator | /app/services/calculation_service.rb | UTF-8 | 4,337 | 2.984375 | 3 | [] | no_license | # The primary interface for the calculator
#
# This class is used with sanitized data in the form of a hash
#
# @example Example usage for a complete calculation with no further info needed:
# inputs = {
# marital_status: 'single',
# fee: 1000.0,
# date_of_birth: Date.parse('1 December 2000'),
# dispo... | true |
79bb676b060156aea0bae830356855550e8a859a | Ruby | b-studios/doc.js | /lib/code_object/base.rb | UTF-8 | 1,234 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative '../token/container'
require_relative '../token/handler'
require_relative '../dom/dom'
require_relative '../parser/meta_container'
module CodeObject
class Base
include Token::Container
include Dom::Node
include Parser::MetaContainer
attr_reader :docs, :name, :path
#... | true |
d3f8a9e44f7f9b9b8d0c856c07360545b3d76f51 | Ruby | lissdy/CODEWARS | /Fluent_Calculator.rb | UTF-8 | 2,215 | 3.9375 | 4 | [] | no_license | #https://www.codewars.com/kata/fluent-calculator/solutions?show-solutions=1
class Calc
def initialize(*args)
if args.size == 2
@operation = args[0]
@number = args[1]
end
end
%w(zero one two three four five six seven eight nine).each_with_index do |number,index|
define_method n... | true |
4518be142a2e92d2553e361a86d7a2f963b640df | Ruby | tosik/automazerb | /lib/automaze.rb | UTF-8 | 2,336 | 3.046875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require "active_support/inflector"
require "panel"
module Automaze
class OddLengthMaze < Exception; end
class Automaze
DEFAULT_ALGORITHM = :dug_tunnels
class << self
def include_algorithm(algorithm)
raise "cannot include because algorithm is nil" if algorithm.nil?
... | true |
5d8f9ae2c4697c2e06c0ceabce36971976188d2b | Ruby | almihoil/TECH.C | /submit/Masahiro1118/post_search_count.rb | UTF-8 | 1,316 | 3.46875 | 3 | [] | no_license | require 'sqlite3'
# DB操作用
class DBc
def initialize
@dbname = 'rb14'
@tableName = 'zips'
end
def check_table?
# 0の場合テーブルは存在しない
sql = "SELECT COUNT(*) from sqlite_master where type='table' and name = ?;"
SQLite3::Database.open(@dbname) do |db|
db.execute(sql,@tableName) do |num|
if (n... | true |
4f8e945f5677263b78f1896ba83ec4f8db188eeb | Ruby | DanElbert/thermostat | /lib/thermostat/sensors/relay_sensor.rb | UTF-8 | 725 | 3.171875 | 3 | [] | no_license | module Thermostat
module Sensors
# Class to represent a 1 wire network branch controller (DS2405)
# However, in this case, it is assumed the chip is controlling a relay.
# This class has a property to determine if the relay is on or off,
# and includes methods for switching the relay on or off
cl... | true |
5348e3dacdbaf4e727d0857497b089c2e5046f28 | Ruby | fornext1119/Numeric-calculation | /rb/0101.rb | UTF-8 | 180 | 3.59375 | 4 | [] | no_license | puts 3 + 5
puts 3 - 5
puts 3 * 5
puts 3 ** 5
puts 5 / 3.0
puts 5.0 / 3
puts 5 / 3
puts 5 % 3
print 3 * 5, "\n"
printf "%3d\n", 3 * 5
printf "%23.20f\n", 5 / 3.0
| true |
10ef2582f785b9705549486d4dcb5370541c63f3 | Ruby | opal/opal | /stdlib/logger.rb | UTF-8 | 2,227 | 3.125 | 3 | [
"MIT"
] | permissive | # backtick_javascript: true
class Logger
module Severity
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
FATAL = 4
UNKNOWN = 5
end
include Severity
SEVERITY_LABELS = Severity.constants.map { |s| [(Severity.const_get s), s.to_s] }.to_h
class Formatter
MESSAGE_FORMAT = "%s, [%s] %5s -- %s: ... | true |
bef2424403d9301c7c2dfe0384156838e8629a45 | Ruby | mykhaylomakhnovskyy/TeachBase | /lesson_08/Carriages/cargo_carriage.rb | UTF-8 | 554 | 3.34375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'carriage'
# Cargo Carriage Class
class CargoCarriage < Carriage
attr_accessor :carriage_number, :capacity
attr_reader :occupied_volume
def initialize(carriage_number, capacity)
super
@carriage_number = carriage_number
@capacity = capacity
@occupied... | true |
fd8a599de92fdc30c67a90724ac39c623d4ecf28 | Ruby | Belkot/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 387 | 3.984375 | 4 | [] | no_license | def echo(str)
str
end
def shout(str)
str.upcase
end
def repeat(str, n=2)
("#{str} " * n).chop
end
def start_of_word(str, n)
str[0...n]
end
def first_word(str)
str.split.first
end
NO_CAPITALIZE_WORDS = %w( over )
def titleize(str)
str[0] = str[0].upcase
str.split
.map { |e| e.length < 4 || NO_CAP... | true |
2ec17970f21d6f10af91755b6bb25c3917c34ca0 | Ruby | oneilld136/mechanics-of-migrations-dumbo-web-career-042219 | /artist.rb | UTF-8 | 233 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_reader :name, :age
@@all = []
def initialize
@name = "Jon"
@age = 30
@@all << self
end
end
def save
self.create
end
def find_by (name)
self.all.find |info|
info.self == name
end
ActiveRecord::Base
| true |
887adb058cc43188e4fa1fd5bb28e51337d64347 | Ruby | katrinapriya/lime | /app/models/campus.rb | UTF-8 | 218 | 2.515625 | 3 | [] | no_license | class Campus < ActiveRecord::Base
belongs_to :resource
def self.get_values
['Berkeley', 'Davis', 'Merced', 'Santa Cruz']
end
def self.count(label)
return Campus.where(:val => label).length;
end
end
| true |
af5cce85fe7246a5e48fd914e8f0bf94d7e44a41 | Ruby | ashifmanjur/cryptor | /lib/cryptor/symmetric_encryption/ciphers/aes128cbchmacsha256128.rb | UTF-8 | 1,183 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'cryptor/symmetric_encryption/ciphers/aescbchmacsha2'
module Cryptor
class SymmetricEncryption
module Ciphers
# A concrete implementation of the generic AES_CBC_HMAC_SHA2 algorithm
# using the HMAC message authentication code [RFC2104] with the SHA-256
# hash function [SHS] to provide m... | true |
5a01f771c113c81b7a9e75e5666a31ef4c17c9c3 | Ruby | kouki-matsuura/ruby_study | /use-inheritance.rb | UTF-8 | 729 | 3.296875 | 3 | [] | no_license | class General_User
attr_accessor :name
def self.usage
puts "会員でない人は閲覧のみとなります"
puts "会員の人は記事を書き込むことができます"
end
def initialize(name)
@name = name
end
def browse_article
puts "1.~~~~~~の記事"
puts "2.~~~~~~の記事"
end
end
class Member < General_User
attr_writer :password
def initialize(... | true |
93f8e8060ff40595ed85da21d3726bf4eec8fd3b | Ruby | tartansinatra/Classwork-Week1-4 | /functions.rb | UTF-8 | 334 | 3.828125 | 4 | [] | no_license | def greeting(day, name)
case day
when 1
print_message(name, "Monday")
when 2
print_message(name, "Tuesday")
when 3
print_message(name, "Wednesday")
when 4
print_message(name, "Thursday")
end
end
def print_message(name, day)
"Hello #{name} it is #{day}. It is awesome!"
end
puts greeti... | true |
62c19ed922eef4708a68a6e67909a6dc8316d3dc | Ruby | MetinLamby/Selectfit | /lib/tasks/tester.rb | UTF-8 | 430 | 2.578125 | 3 | [] | no_license | require_relative("scrape")
require "open-uri"
puts "deleting all fake products"
products = scraper("https://de.gymshark.com/collections/t-shirts-tops/mens")
file = products.first[:photo]
puts file
fileOpen = URI.open(file)
puts fileOpen
product = Product.new(name: products.first[:name])
product.photo.attach(io:... | true |
35ca9ca15d0921ce9d4be091d28673431210e76a | Ruby | JOCOghub/key-for-min-value-onl01-seng-ft-070620 | /key_for_min.rb | UTF-8 | 334 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(hash)
if hash.empty?
return nil
end
ans = [hash.first[0],hash.first[1]]
hash.each do |k,v|
if v < ans[1]
ans[1] = v
ans[0] = k
end
end
retu... | true |
6a4094e9e3a375dd82300f12b6546077880c46dc | Ruby | jbonAA/AAHomework | /W3D4/map.rb | UTF-8 | 529 | 3.453125 | 3 | [] | no_license | class Map
def initialize(array)
raise TypeError unless array.all? { |el| el.class == Array && el.length == 2 }
@array = array
end
def set(key, value)
@array.map { |subArr| subArr[1] = value if subArr[0] == key }
end
def get(key)
@array.select { |subArr| subArr if su... | true |
b2f6d595c1a8456ada7921fab372a078c1859d7b | Ruby | aberant/tuio-ruby | /lib/tuio-ruby/core_ext/object.rb | UTF-8 | 855 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # this is a little meta magic to clean up some of the repetition in the client
# i noticed that i kept making the same similiar methods for each event such as
#
# client_events :object_creation
#
# which causes these two methods to be created
# def on_object_creation( &object_creation_blk )
# @object_creation_callbac... | true |
b8585d126319dd1b809709d68c417b47b0e7a497 | Ruby | Alexis-Trainee/ruby | /return.rb | UTF-8 | 114 | 3.359375 | 3 | [
"MIT"
] | permissive | def compare(a, b)
a > b
end
a= 1
b= 2
result = compare(a, b)
puts "O resultado da comparação é '#{result}'"
| true |
f391bac9ece1d358016bd779755831f8e0564579 | Ruby | phaedryx/mediaforge | /run | UTF-8 | 571 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
require './lib/ball_clock'
require 'trollop'
options = Trollop::options do
opt :file, "file with ball count, one per line, 0 is ignored", type: :string
end
Trollop::die :file, "option not provided" unless options[:file]
Trollop::die :file, "#{options[:file]} not found" unless File.exist?(option... | true |
c04b27cf46e12ed454f1c7130bfedba1e6f34aab | Ruby | arn-e/misc-utility-scripts | /list_comparison.rb | UTF-8 | 516 | 3.15625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require 'csv'
file1 = ARGV[0]
file2 = ARGV[1]
list1 = CSV.read(file1).flatten
list2 = CSV.read(file2).flatten
puts "List Comparatinator Initialized"
#ad-hoc column modification examples :
list1.map! {|hash| hash.gsub(/^.*\//,"")}
list1.map! {|hash| hash.gsub(".txt","")}
missing_1 = list1 - list2
missing_2 = list2 ... | true |
ed08a540e542e1df21433853f1f671102b845281 | Ruby | gzstudio/meal-picker | /meal-picker-server/app/controllers/users_controller.rb | UTF-8 | 2,256 | 2.53125 | 3 | [] | no_license | class UsersController < ApplicationController
# will be used to register a new user
before_action :authorize_request, only: [
:get_by_id, :update_user, :delete_user
]
def create_user
userParams = params.require(:user)
.permit(:name, :email, :password, :password_confirmation)
... | true |
e79f77d9b91682a40d3297afa8385344f39efed7 | Ruby | alyssa0528/oo-student-scraper-v-000 | /lib/student.rb | UTF-8 | 780 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Student
attr_accessor :name, :location, :twitter, :linkedin, :github, :blog, :profile_quote, :bio, :profile_url
@@all = []
def initialize(student_hash)
student_hash.each do |key, value|
self.send("#{key}=", value)
end
@@all << self
end
#takes in an array with student... | true |
c733f818172460e6d046d100662295e7f17bfb0c | Ruby | MerrilCode/Ruby | /classes/oo-basics/starter-code/app.rb | UTF-8 | 219 | 2.96875 | 3 | [] | no_license | # Squares
require_relative 'area_perimeter.rb'
square = Square.new(4)
puts "Area: #{square.area} Perimeter: #{square.perimeter}"
scale = square.scale 10
puts "Area: #{square.area} Perimeter: #{square.perimeter}"
| true |
31e81e3700a110e2a2a10c70d34bdc21a5c2b734 | Ruby | JoePascale/Kele | /lib/kele.rb | UTF-8 | 1,837 | 2.65625 | 3 | [] | no_license | require 'httparty'
require 'json'
require './lib/roadmap'
class Kele
include HTTParty
include Roadmap
def initialize(email, password)
@url = 'https://www.bloc.io/api/v1'
response = self.class.post("#{@url}/sessions",
body: { email: email, password: password })
@auth_token = response['auth_toke... | true |
dafa396f946cbe3a515ee40a4c854e07b28d9094 | Ruby | vvlee/cos-ruby-sdk | /lib/cos/resource.rb | UTF-8 | 4,574 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # coding: utf-8
module COS
class Resource
attr_reader :bucket, :path, :dir_count, :file_count
# 实例化COS资源迭代器
def initialize(bucket, path, options = {})
@bucket = bucket
@path = path
@more = options
@results = Array.new
@dir_count = 0
@file_co... | true |
251136cbf6c677dfc69feb2926e7234fcf081de1 | Ruby | byu/junkfood | /spec/junkfood/ceb/bus_spec.rb | UTF-8 | 5,818 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe 'Ceb::Bus' do
it 'should acts_as_bus' do
class TestFoo
def initialize(valid)
@valid = valid
end
def valid?
@valid
end
end
# Test that we have the proper attributes and methods create... | true |
a3fb8a5dc4f034a433b3d1fc8a3e92032773449f | Ruby | Mewtch/learn_ruby | /03_simon_says/simon_says.rb | UTF-8 | 417 | 3.859375 | 4 | [] | no_license | def echo(word)
word
end
def shout(word)
word.upcase
end
def repeat(word, n=2)
word = word + " "
(word*n).strip
end
def start_of_word(word,n)
word[0,n]
end
def first_word(word)
word.split(' ')[0]
end
def titleize(word)
small = ["and", "or", "the", "over", "to", "the", "a", "but","bung"]
word.split('... | true |
5a9262efc0f2c0d5d19a7d372f5303397adebf3a | Ruby | dhanesana/yongBot | /lib/old_plugins/p101_scrape.rb | UTF-8 | 1,986 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
module Cinch
module Plugins
class P101
include Cinch::Plugin
match /(p101)$/
match /(p101) (.+)/, method: :with_num
match /(help p101)$/, method: :help
def execute(m)
with_num(m, '.', 'p101', 1)
end
def with_num(m, prefix,... | true |
f7717e8796e60dccd0f6d0ab144e2a9697579208 | Ruby | my0shym/atcoder | /ABC/117/a.rb | UTF-8 | 205 | 3.09375 | 3 | [] | no_license | # 4:05 1回ミス
# 整数同士の割り算は、結果が切り捨てられて整数になるのを知らなかった。
# 特に他の回答に学びはない。
T, X = gets.split.map(&:to_f)
puts T/X | true |
3e4ac5e2468d9ee6a935f0c32fc4ad457786cc02 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex0040.rb | UTF-8 | 172 | 3.734375 | 4 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 20
animals = %w( ant bee cat dog elk ) # create an array
animals.each {|animal| puts animal } # iterate over the contents
| true |
7b9a846c8cff6937d9f3f21fb3821c10dca3c4f9 | Ruby | drewjparker91/title-case | /lib/title_case.rb | UTF-8 | 257 | 3.21875 | 3 | [] | no_license | def title_case(title)
split_sentence = title.split
split_sentence.each do |word|
if word != ("above") && word != ("below") && (word.length > 3)
word.capitalize!()
end
# elsif word.length <=3
end
split_sentence.join(" ")
end
| true |
1b5212d42cffdf5efb18dab1375d2deecc81a5a7 | Ruby | Ramaze/ramaze | /lib/ramaze/helper/upload.rb | UTF-8 | 19,939 | 2.78125 | 3 | [
"MIT"
] | permissive | module Ramaze
module Helper
##
# Helper module for handling file uploads. File uploads are mostly handled
# by Rack, but this helper adds some convenience methods for handling
# and saving the uploaded files.
#
# @example
# class MyController < Ramaze::Controller
# # Use upload h... | true |
bf7652ee0451d5cdf0ea17f4693b7af21c82bb69 | Ruby | ExtractOfCactus/week_4_homework_3 | /db/seeds.rb | UTF-8 | 974 | 2.875 | 3 | [] | no_license | require_relative('../models/students')
require_relative('../models/houses')
require('pry-byebug')
house_1 = House.new({
"name" => "Gryffindor",
"logo" => "../images/Gryffindor.jpg"
})
house_2 = House.new({
"name" => "Ravenclaw",
"logo" => "../images/Ravenclaw.jpg"
})
house_3 = House.new({
"name" => "Slythe... | true |
6fbfe53319e180b6ddf35471ca03640745ac2475 | Ruby | Rakatashii/cpp_ch11 | /P11_12/generate_names.rb | UTF-8 | 1,014 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'Faker'
require 'as-duration'
n = 200
filename = "/Users/christianmeyer/cpp/ch11/P11_10/data.txt"
File.open(filename, 'w') {|f|
Faker::Config.random.seed
printline = ""
sep = "|";
endl = "\n";
n.times do |name, salary|
name = Faker::Name.name
printline +... | true |
b635bd904b4fc1b4a14d22dd92d3e625ebfe2a91 | Ruby | lgleasain/rock_paper_scissors | /test/lib/judge_test.rb | UTF-8 | 831 | 3.296875 | 3 | [] | no_license | require 'test/unit'
class JudgeTest < Test::Unit::TestCase
def base_strategy
lambda{|players| players.first}
end
private :base_strategy
def test_when_player_1_is_bye
assert Judge.winner(base_strategy, [nil, :player2]) == :player2
end
def test_when_player_2_is_bye
assert Judge.winner(base_strat... | true |
023adfff13853aa0434c74c05cb70e70621e3d79 | Ruby | klatour324/enigma | /lib/encrypt.rb | UTF-8 | 328 | 2.90625 | 3 | [] | no_license | require './lib/enigma'
enigma = Enigma.new
handle = File.open(ARGV[0], 'r')
message = handle.read
handle.close
encrypted = enigma.encrypt(message)
writer = File.open(ARGV[1], 'w')
writer.write(encrypted[:encryption])
writer.close
puts "Created '#{ARGV[1]}' with the key #{encrypted[:key]} and date #{encrypted[:... | true |
42f4c79c2b8c07398dc392f2dde1364a1dbddacb | Ruby | koad/My-Wallet-V3 | /check-dependencies.rb | UTF-8 | 8,008 | 2.640625 | 3 | [] | no_license | # This script ensures that all dependencies (NPM and Bower) are checked against a whitelist of commits.
# Only non-minified source if checked, so always make sure to minify dependencies yourself. Development
# tools - and perhaps some very large common libraties - are skipped in these checks.
# npm-shrinkwrap.json sho... | true |
efa8f51c3bbb84c2676e2d32c67a22e7c6452989 | Ruby | p-reznick/trumpku | /phrases.rb | UTF-8 | 4,486 | 3.53125 | 4 | [] | no_license | require 'pry'
require 'ruby_rhymes'
class Phrases
attr_accessor :all_sentences, :start_phrases, :mid_phrases, :end_phrases, :text
ONES = %w(zero one two three four five six seven eight nine)
TENS = %w(zero ten twenty thirty forty fifty sixty seventy eighty ninety)
TEENS = {'ten one' => 'eleven',
't... | true |
43fd23d3b47460df0df4d5687127afa24edec64c | Ruby | Universe-Man/code_challenge_practice_1.3 | /airline.rb | UTF-8 | 637 | 3.15625 | 3 | [] | no_license | class Airline
ALL = []
attr_reader :name, :hq
def initialize(name, hq)
@name = name
@hq = hq
ALL << self
end
def self.all
ALL
end
def flights
Flight.all.select do |flight|
flight.airline == self
end
end
def destinations
flights.map do |flight|
flight.desti... | true |
8c3c61c13703a06ea8b9f8a836258647382f9bd2 | Ruby | jpclark6/advent-of-code-2018 | /solutions/day_6.rb | UTF-8 | 2,145 | 3.375 | 3 | [] | no_license | require 'pry'
input = File.read('./puzzle_txt/day_6.txt')
input = input.split("\n").map { |line| [line.split(", ")[0].to_i, line.split(", ")[1].to_i]}
def find_grid_dims(input)
[input.max_by { |a, b| a }[0], input.max_by { |a, b| b }[1]]
end
def find_manhattan_distance(x1, y1, x2, y2)
(x1 - x2).abs + (y1 - y2).a... | true |
9b5bf44e66ba48dd8581934879aaf79759480084 | Ruby | carol-yao/coding_challenges | /adding_array.rb | UTF-8 | 286 | 3.4375 | 3 | [] | no_license | # animals = []['dog', 4], ['cat', 3], ['dogs',7]]
# becomes { 'dogs' => 11, 'cats' => 3}
animals = [['dogs', 4], ['cats', 3], ['dogs',7]]
hash = {}
animals.each do |animal|
if hash[animal[0]] != nil
hash[animal[0]] += animal[1]
else
hash[animal[0]] = animal[1]
end
end
| true |
0f4e2b01cbe9c8b7621c9df889acfc11033619cc | Ruby | elibar-uk/pixel | /lib/editor.rb | UTF-8 | 1,277 | 3.65625 | 4 | [] | no_license | require './lib/image'
class Editor
attr_reader :image
COMMANDS = {
'I' => :create,
'H' => :horizontal,
'V' => :vertical,
'L' => :colourize,
'C' => :clear,
'S' => :show
}.freeze
def create(*args)
@image = Image.new(*args)
end
def run
@running = true
while @running
print ... | true |
0432bbf21b7c6fe92b05b049d318dc6ded43810a | Ruby | tamsenrochelle1/RubyLearnings | /rubyBranching.rb | UTF-8 | 422 | 4.09375 | 4 | [] | no_license | # if else conditions
# sunday, dec 15
#condition = false
#another_condition = false
#if condition || another_condition
# puts "one condition met"
#else
# puts "no conditions"
#end
# puts "la la la"
# || or
# && and
name = "Joe"
if name == "Tamsen"
puts "welcome to the program, tamsen"
elsif name == "Jaron" #elsi... | true |
8e21a1c9166653314633afab308a42185b2ddf0a | Ruby | Slav666/pub_lab_week_02 | /specs/customer_spec.rb | UTF-8 | 941 | 2.921875 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../customer")
require_relative("../drink")
require_relative("../pub")
class CustomerTest < MiniTest::Test
def setup
@drink_L = Drink.new({name: "gin and tonic", price: 10})
@drink_S = Drink.new({namee: "red wine", price: 8})
@custome... | true |
59154aef0b1a9074c5f4ec27076688838a3014eb | Ruby | StevenClontz/roman_scrabble_words | /spec/roman_scrabble_word_spec.rb | UTF-8 | 558 | 2.578125 | 3 | [] | no_license | require_relative '../main'
describe 'The Roman scrabble word identifier' do
it 'recognizes CIVIC' do
expect('CIVIC'.is_roman?).to be_truthy
end
it "doesn't recognize EFFACED or FOOBAR" do
expect('EFFACED'.is_roman?).to be_falsy
expect('FOOBAR'.is_hexy?).to be_falsy
end
end
describe 'The Hex scrabb... | true |
5e11313e72aab9549ea225379b0d5a4e452b8210 | Ruby | counterThreat/chess_app | /spec/models/piece_spec.rb | UTF-8 | 13,471 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe Piece, type: :model do
# VALIDATIONS
it "has a valid factory" do
game1 = FactoryGirl.create(:game)
elvis = FactoryGirl.create(:user)
queen = FactoryGirl.create(:piece, game: game1, user: elvis)
expect(queen).to be_valid
end
it "is not valid without an id" d... | true |
06752c0efa71bb4e9c28f1b45c844e229b2c4d2a | Ruby | jondot/ratom | /lib/atom/extensions/media.rb | UTF-8 | 872 | 2.75 | 3 | [
"MIT"
] | permissive | require 'atom'
#
# Media extension (see http://video.search.yahoo.com/mrss)
#
# Exaple:
# f.entries << Atom::Entry.new do |e|
# e.media_content = Media.new :url => article.media['image']
# end
#
class Media
include Atom::Xml::Parseable
include Atom::SimpleExtensions
attribute :url, :fileSize... | true |
536b23efb217f81b16fdc88b1d22acf899b5af2e | Ruby | aaishaa/psychedelic-dream-game | /extra_gosu_app/gosutest.rb | UTF-8 | 8,048 | 4.03125 | 4 | [
"MIT"
] | permissive | require 'Gosu'
# class Welcome
# attr_accessor :x, :y, :w, :h
# def initialize(window)
# # all setup is done in reset so it can be reused
# reset(window)
# end
# def reset(window)
# # create a new image using a random one from the candyList
# @image = Gosu::Image.new(window, "welcome.png", false... | true |
e1c9458f79783d55072e936be927755bc2c8e49b | Ruby | snags88/euler-club | /project-euler-summation-of-primes/Problem_10_summation_of_primes.rb | UTF-8 | 874 | 4.1875 | 4 | [] | no_license | # The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
# Find the sum of all the primes below two million.
# To solve this problem user Sieve of Eratosthenes.
# The basis is to go through min through limit numbers and eliminating incremental values.
def primes_up_to(max)
repository = (0..max).collect{true} #=> Cr... | true |
3f6ab04aeca5039fec080c896e44363c4a08cf0e | Ruby | mafaher/TPFINAL | /classes/usuario.rb | UTF-8 | 337 | 2.6875 | 3 | [] | no_license |
class Usuario
attr_accessor :nombre, :apellido, :sexo, :edad
attr_reader :idusuario, :fechacreacion
def initialize(nombre="noname", apellido="nosurname", sexo="blank", edad="blank", fechacreacion="blank")
@nombre = nombre
@apellido = apellido
@sexo = sexo
@edad = edad.to_i
@fechacreacion = fechacreacio... | true |
b70d16a5b4bcc257a6803f5f24a23f21af00fb25 | Ruby | omkz/algorithms-in-ruby | /lib/linked_lists/node.rb | UTF-8 | 165 | 3.015625 | 3 | [] | no_license | class Node
attr_accessor :next, :prev, :value, :key
def initialize(value, key: nil)
@value = value
@key = key
@next = nil
@prev = nil
end
end
| true |
136544a5c41cbd2b563063da75a043ed377e1257 | Ruby | anorico/project-euler-even-fibonacci-q-000 | /lib/oo_even_fibonacci.rb | UTF-8 | 452 | 3.625 | 4 | [] | no_license | # Implement your object-oriented solution here!
class EvenFibonacci
def initialize(limit)
@fibonacci_array = Array.new(2,1)
@limit = limit
end
def sum
sum = 0
i = 1
while @fibonacci_array.last < @limit
@fibonacci_array << (@fibonacci_array[i-1] + @fibonacci_array[i])
i += 1
e... | true |
cffeba8c040eec90193e79e990486449467d1008 | Ruby | popo03/furima-35693 | /spec/models/user_spec.rb | UTF-8 | 4,939 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'ユーザー新規登録' do
before do
@user = FactoryBot.build(:user)
end
context '内容に問題がない場合' do
it 'すべての情報があれば登録できる' do
expect(@user).to be_valid
end
end
context '内容に問題がある場合' do
it 'nicknameが空では登録できないこと... | true |
5762e3ab7a8f04232887a1dae67d44bf4a4293fd | Ruby | andreatl/rails_reviews | /app/models/restaurant.rb | UTF-8 | 266 | 2.828125 | 3 | [] | no_license | class Restaurant < ActiveRecord::Base
#attr_accessible :name, :phone
has_many :reviews
def average_stars
avg = self.reviews.average(:stars)
# rounds ratings to nearest integer; returns that many asterisks. Don't need to round!
"*" * avg.round(1)
end
end
| true |
48ef7bb27aafc0707095be00be1eba9edb5992b1 | Ruby | guyogev/lazy_load | /server.rb | UTF-8 | 195 | 2.578125 | 3 | [] | no_license | require 'sinatra'
require 'json'
counter = 0
get '/' do
redirect 'index.html'
end
get '/give_me_more' do
counter += 1
counter <= 3 ? ((1..10).map { rand 100_000_000 }).to_json : nil
end
| true |
a17747455beaeeff910ef094344472256b7e91c3 | Ruby | ValRmo/learn_to_program | /cap10/dictionary_sort.rb | UTF-8 | 555 | 3.640625 | 4 | [] | no_license | def dictionary_sort list_words
recursive_dictionary list_words, []
end
def recursive_dictionary unsorted, sorted
if unsorted.length <= 0
return sorted
end
smallest = unsorted.pop
still_unsorted = []
unsorted.each do |small_word|
if small_word.downcase < smallest.downcase
still_unsorted.push... | true |
5ba5c61b5c3fca10b45b81b5b697689e0f858e4c | Ruby | geomsb/video-store-api | /app/models/movie.rb | UTF-8 | 504 | 2.625 | 3 | [] | no_license | class Movie < ApplicationRecord
has_many :rentals
validates :title, :overview, :release_date, presence: true
validates :inventory, numericality: true, presence: true
def movie_avail?
if self.available_inventory >= 1
return true
else
return false
end
end
def reduce_avail_inv
se... | true |
0fe6df3b414377098a1eb987b6277b9ff8851a1a | Ruby | pfaithmtan/W2D3 | /poker/lib/card.rb | UTF-8 | 713 | 3.046875 | 3 | [] | no_license | require 'rspec'
require 'spec_helper'
class Card
CARD_VALUES = {
two: 2,
three: 3,
four: 4,
five: 5,
six: 6,
seven: 7,
eight: 8,
nine: 9,
ten: 10,
J: 11,
Q: 12,
K: 13,
A: 14
}
CARD_SUITS = {
spades: '♠',
hearts: '♥',
diamonds: '♦',
clubs: '♣... | true |
29a7d05e75248fffa1f5d5785a295c98cea2f0f8 | Ruby | AcademicWorks/reveal | /lib/reveal.rb | UTF-8 | 462 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class Reveal
def self.read(file_or_text)
file = coerce_to_file(file_or_text)
gzip_reader = Zlib::GzipReader.new(file )
unzipped_data = gzip_reader.readlines.join
gzip_reader.close
return unzipped_data
rescue Zlib::GzipFile::Error => e
file.rewind
return file.readlines.join
end
... | true |
2190f3a09d9e1d549195968cb44c116fd6e5005d | Ruby | GSergeevich/ror | /Ruby_basic/lesson1/triangle_area.rb | UTF-8 | 360 | 3.15625 | 3 | [] | no_license | #! /usr/bin/env ruby
puts 'Введите длину основания треугольника:'
base = gets.chomp.to_i
puts 'Введите высоту треугольника:'
height = gets.chomp.to_i
puts "Площадь треугольника с основанием #{base} и высотой #{height} составляет #{0.5 * base * height}"
| true |
781fc4fc8249a5abf413da8b26867336573bbb92 | Ruby | kfili/codewars | /6kyu-difficulty-level/find-the-odd-int/solution.rb | UTF-8 | 135 | 2.65625 | 3 | [] | no_license | def find_it(seq)
tracker = Hash[seq.group_by { |x| x }.map { |k, v| [k, v.count] }]
tracker.each { |k, v| return k if v.odd? }
end
| true |
4c1ddac7fa7c033c5a1aac732f9577cb12cc997a | Ruby | bardoloi/projecteuler | /problems/009.rb | UTF-8 | 769 | 3.890625 | 4 | [] | no_license | # http://projecteuler.net/problem=9
# The math:
# ----------
# a + b + c = 1000
# => (a + b + c)**2 = 1,000,000
# => a**2 + b**2 + c**2 + 2ab + 2bc + 2ca = 1,000,000
# Replace c**2 with (a**2 + b**2) as they are Pyth. triplets
# => 2*(a**2 + b**2) + 2ab + 2c(a + b) = 1,000,000
# Replace c with (1000 - a - b)
# => 2*(... | true |
732645e96ad0e0938fbeb35a7be245f5eafe9deb | Ruby | fleeree2013/ruby-challenges | /case.rb | UTF-8 | 478 | 3.84375 | 4 | [] | no_license |
puts "What is the weather?"
weather = gets.chomp
case (weather)
when 'sunny'
puts "Put on lots of suncreen and get out in the sun."
when 'cloudy'
puts "Don't forget your umbrella. It's cloudy"
when 'foggy'
puts "It might be hard to see today, it's foggy"
when 'rainy'
puts "Don't forget your raincoat and rubber boo... | true |
2bb7ad7637137c8afa515d4df28759f6c6625949 | Ruby | georgecode/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 2,794 | 4.25 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:create an empty hash
# add a create list method(food_str)
# .split it
# set default to 1 test 0 too
#loop through list
# print the list to the console [can you use one of your other methods ... | true |
a9f257ac3e63c33c6ec72834bb1ff03a53c3d09b | Ruby | aendra-rininsland/monocle-assets | /lib/asset.rb | UTF-8 | 1,671 | 2.828125 | 3 | [] | no_license | require 'uri'
require 'net/http'
require 'net/https'
module Asset extend self
class ConnectionError < StandardError
attr_reader :response
def initialize(response, message = nil)
@response = response
@message = message
end
def to_s
message = "Failed."
message << " Response ... | true |
3354855d7e48e33621a7a84399abdfef38fa00b6 | Ruby | hironobuochiai/kadai-ruby-1 | /kadai-introduce.rb | UTF-8 | 126 | 2.875 | 3 | [] | no_license | myoji = '落合'
namae = '博宣'
nenrei = 29
shimei = myoji + namae
puts shimei + "です。" + nenrei.to_s + '歳です。' | true |
63cd14b57c9b0c2c74343c5b89909fa2bedbc731 | Ruby | biancamutaquiha/desafio-coffee-app | /spec/builder/drink_builder_spec.rb | UTF-8 | 1,339 | 2.71875 | 3 | [] | no_license | require 'builder/drink_builder'
require 'json'
describe 'drikn builder' do
it 'should return a list price' do
prices_json = [
{ "drink_name": "long black", "prices": { "small": 3.25, "medium": 3.50 } },
{ "drink_name": "flat white", "prices": { "small": 3.50, "medium": 4.00, "large": 4.50 } },
... | true |
01889d2d60b37e3e8eb720444b5873096fc250c9 | Ruby | gdean123/configuration-encryptor | /src/value_encryptor.rb | UTF-8 | 798 | 2.796875 | 3 | [] | no_license | require 'openssl'
require 'base64'
require 'ostruct'
module ValueEncryptor
KEY_LENGTH = 4096
def self.generate_keypair
keypair = OpenSSL::PKey::RSA.new(KEY_LENGTH)
OpenStruct.new(
public_key: OpenSSL::PKey::RSA.new(keypair.public_key.to_pem),
private_key: OpenSSL::PKey::RSA.new(keypair.to_pem... | true |
676e3a7880de1f6cb2eb5ff4d2ce593662c52e96 | Ruby | badCompany110/LearningProjectcs | /Projects/Ruby/Blocks/library_block_examples.rb | UTF-8 | 1,481 | 4.84375 | 5 | [] | no_license | # Code Samples
# Given the following array:
array = [1, 2, 3]
Array#each
array.each { |item| print "-#{item}-" }
Prints out:
-1--2--3-
Array#select:
array.select { |item| item > 2 }
This returns a new array with the following:
[3]
Array#delete_if
array.delete_if { |item| ite... | true |
6abfb0d607fda7b4f0941146367a70278ad016b2 | Ruby | cvaleriac/my-each-v-000 | /my_each.rb | UTF-8 | 133 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each (array)# put argument(s) here
w = 0
while w < array.length
yield array[w]
w = w + 1
end
return array
end
| true |
b989d8b985ce032447516fdcec1ba3a357227b28 | Ruby | illacceptanything/illacceptanything | /code/rails/activesupport/test/encrypted_file_test.rb | UTF-8 | 1,626 | 2.546875 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
require "abstract_unit"
require "active_support/encrypted_file"
class EncryptedFileTest < ActiveSupport::TestCase
setup do
@content = "One little fox jumped over the hedge"
@content_path = File.join(Dir.tmpdir, "content.txt.enc")
@key_path = File.join(Dir.tmpdir, "content... | true |
3c1731f4416aef7ef2babc8a35e37b95ac16b3b6 | Ruby | RouanThompson/ruby-oo-object-relationships-kickstarter-lab-nyc04-seng-ft-053120 | /lib/project.rb | UTF-8 | 424 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Project
attr_reader :title
def initialize(title)
@title = title
end
def add_backer(backer)
ProjectBacker.new(self, backer)
end
def backers
all_project_projectbackers = ProjectBacker.all.select do |projectbacker_instance|
projectbacker_instance.project == self
end
all_proj... | true |
875feb5d1ea46954220a172f48d723879f0fc265 | Ruby | TIYZAP/w2d1-lipsum-wanted | /lipsum.rb | UTF-8 | 2,987 | 3.375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'erb' #Needed in order to run index.html.erb!
require 'shellwords' #Needed in order to run shellescape!
lipsum_wanted = ARGV[0].to_s.downcase
#Arguments below were created to display more than one paragraph!
multiple_paragraphs = ARGV[1].to_i
if multiple_paragraphs < 1
multiple_... | true |
bcf1132f9ebe7b1d72a552f739e6bc33acdcdb86 | Ruby | PauloGuilhermeAlmeida/Curso-Ruby | /Tipo_Dados.rb | UTF-8 | 5,475 | 3.59375 | 4 | [] | no_license | =begin Informacoes
*************************************************************
* Curso de Ruby *
*************************************************************
* Aluno.....: Paulo Guilherme Almeida *
* Linguagem.: Ruby ... | true |
f84b2b0605b4b8e1f423ed6c8ac3123e62d82f23 | Ruby | charlag/Mmmail | /lib/email.rb | UTF-8 | 1,023 | 2.984375 | 3 | [
"MIT"
] | permissive | require './lib/parser'
require './lib/contact'
require './lib/parts'
class Email
attr_reader :id
attr_reader :headers
attr_reader :subject, :from, :to, :part
def initialize(id, string)
@id = id
@headers, @part = RFC822Parser.parse_message(string)
@subject = headers['Subject'].f... | true |
3dc8572c38ff26943c37963048ac9528e845b119 | Ruby | cyberarm/mruby-gosu | /examples/classic_shooter.rb | UTF-8 | 12,352 | 3.1875 | 3 | [] | no_license | # A simple Gorilla-style shooter for two players.
# Shows how Gosu to generate a map, implement
# a dynamic landscape and generally look great.
# Also shows a very minimal, yet effective way of designing a game's object system.
# Doesn't make use of Gosu's Z-ordering. Not many different things to draw, it's
# easy to ... | true |
30242f3c30976dd1943183306b1961cab763eff8 | Ruby | duboviy/algoholic | /algoholic/ruby_solutions/codewars/jaden_casing_string.rb | UTF-8 | 359 | 3.90625 | 4 | [
"MIT"
] | permissive | # Public: To convert strings to how they would be written by Jaden Smith (always capitalizing every word).
#
# Examples
#
# "How can mirrors be real if our eyes aren't real".toJadenCase
# # => "How Can Mirrors Be Real If Our Eyes Aren't Real"
#
# Returns the modified string.
class String
def toJadenCase
self.... | true |
6dd7393c3e9494879a5ee31f2f8268eec512097f | Ruby | WaffleHacks/hackathon-manager | /app/lib/webhooks.rb | UTF-8 | 5,315 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'discordrb/webhooks'
require 'net/http'
module Webhooks
READABLE_EVENTS = {
questionnaire_pending: "New Application",
questionnaire_late_waitlist: "New Late Application",
questionnaire_rsvp_confirmed: "RSVP Confirmed",
questionnaire_rsvp_denied: "RSVP Denied",
questionnaire_discord: "Disc... | true |
d3086eaf254639b1f5dca4026d0764a8b692111f | Ruby | mflorin/greenlight | /examples/example_lib.rb | UTF-8 | 902 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'greenlight'
# we can wrap only the request in a function and use it afterwards
def login_request(username, password)
post(data['hosts']['auth'] + '/login', {
headers: {
'Content-Type' => 'application/json'
},
body: {
username: username,
password: password
... | true |
3d908cbd033371fcc52f7a86fe4bd4450686374b | Ruby | Gary1690/ruby-oo-practice-relationships-domains-nyc01-seng-ft-051120 | /app/models/actor.rb | UTF-8 | 446 | 3.421875 | 3 | [] | no_license | class Actor
@@all = []
attr_accessor :name
def initialize(name)
@name = name
Actor.all << self
end
def characters
Character.all.select{|x| x.actor == self}
end
def character_count
self.characters.count
end
def self.most_characters
self.al... | true |
1e253ad6ec119af09bc6153a82919f423b41ff46 | Ruby | filipay/graphicKanagroo | /grid.rb | UTF-8 | 279 | 3.453125 | 3 | [] | no_license | require_relative "point"
class Grid
attr_reader :dimension
def initialize (dimension)
@dimension = dimension - 1
end
#Checks if a given point is outside
def lies_outside? point
x = point.x
y = point.y
x < 0 or x > @dimension or \
y < 0 or y > @dimension
end
end | true |
981f0d2778a3474ca75c71cf6d04405eca98c9b2 | Ruby | singhanilk1959/rpl | /library_intro_4/bk/x.rb | UTF-8 | 45 | 2.921875 | 3 | [] | no_license | s = "hello world" #
print s.chars.to_a
| true |
fa60c7fcf5a4036f326ddab817558bb9f7003206 | Ruby | jfitisoff/marqeta-example | /spec/user_spec.rb | UTF-8 | 2,841 | 2.53125 | 3 | [] | no_license | require_relative 'spec_helper'
describe "/users" do
before(:all) do
if CREDS.keys.length < 3 || CREDS.values.any? { |v| v.blank? }
raise "credentials.yml must be populated before running tests (see README.)"
end
@api = MarqetaCore.new(
CREDS['base_url'],
CREDS['app_token'],
CREDS... | true |
a4e0d8fff46a88db5943fa9a115c84e4969fda89 | Ruby | higginsmt/githug | /levels/reorder.rb | UTF-8 | 775 | 2.640625 | 3 | [
"MIT"
] | permissive | difficulty 4
description "You have committed several times but in the wrong order. Please reorder your commits."
setup do
repo.init
FileUtils.touch "README"
repo.add "README"
repo.commit_all "Initial Setup"
FileUtils.touch "file1"
repo.add "file1"
repo.commit_all "First commit"
FileUti... | true |
2b7fec4a69d6dacc886c42aa7e6280e449c1154f | Ruby | rhysd/TwitPrompt | /src/twit_prompt.rb | UTF-8 | 5,344 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# encoding: utf-8
# Monkey patch to making String colorful
class String # {{{
{
dark_blue: "0;34",
dark_green: "0;32",
dark_cyan: "0;36",
dark_red: "0;31",
dark_purple: "0;35",
dark_yellow: "0;33",
red: "1;31",
blue: "1;34",
en: ... | true |
e7adeab81fd69bb4526d0124983d762f23a51a2c | Ruby | vinodmunagala/seat_availablity | /lib/best_seats/finder.rb | UTF-8 | 2,190 | 3.25 | 3 | [] | no_license | require "forwardable"
require "ostruct"
require "best_seats/matrix"
require "best_seats/best_seat_index_finder"
require "best_seats/seat_group"
require "best_seats/venue"
module BestSeats
class Finder
extend Forwardable
DEFAULT_OPTIONS = {
matrix_builder: BestSeats::Matrix,
index_finder: BestSea... | true |
32f50755a69248b3456330a03f5910d0f001d6a9 | Ruby | mateuszalmannai/dmtk | /spec/models/tool_spec.rb | UTF-8 | 372 | 3.078125 | 3 | [] | no_license | describe "A tool" do
it "is free if the price is $0" do
tool = Tool.new(price: 0)
expect(tool.free?).to eq(true)
end
it "is not free if the price is non-$0" do
tool = Tool.new(price: 10.00)
expect(tool.free?).to eq(false)
end
it "is free if the price is blank" do
tool = Tool.new(price:... | true |
aef48e9312cfa76a5832fe659233fdefa5e6d89c | Ruby | cdimartino/schedulizr | /app/models/schedule.rb | UTF-8 | 968 | 2.6875 | 3 | [] | no_license | class Schedule < ActiveRecord::Base
has_many :activities
validates :schedule_date, uniqueness: true, presence: true
def display_date format='%A, %B %d, %Y'
schedule_date.strftime(format)
end
def ordered_activities
activities.order('start_time asc, end_time asc')
end
def deep_clone date
dup... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.