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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b284fa9190a3330a2b5229ee3985680b56db0ade | Ruby | Youngv/shepherd | /school_student_course/school.rb | UTF-8 | 1,514 | 3.921875 | 4 | [] | no_license | #!usr/bin/ruby -w
class School
attr_writer :school,:address,:students,:courses
attr_reader :school,:address,:students,:courses
def initialize(school,address,students,courses)
@school = school
@address = address
@students = students
@courses = courses
end
def count
@students.length
end
... | true |
ae66c0ca22e97e39861c400fabdacfb16e73b817 | Ruby | Enocruz/SWArchitectureClass | /Werewolves and Wanderer/main.rb | UTF-8 | 18,148 | 3.515625 | 4 | [] | no_license | # WEREWOLVES AND WARDERER
# Date: 23-Mar-2018
# Authors:
# A01374527 Luis Daniel Rivero Sosa
# A01374648 Mario Lagunes Nava
# A01375640 Brandon Alain Cruz Ruiz
# File: main.rb
# WEREWOLVES AND WANDERER
#
# COMMANDS:
# 1. I -> Opens the inventory
# 2. F -> Starts a fight
# 3. N -> Go to the ... | true |
626205ab3f312748598f05c7685a767abcb2f6c3 | Ruby | greendog/clots | /spec/drop_spec.rb | UTF-8 | 1,434 | 2.671875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/spec_helper'
class ChildModel
def parent
"parent"
end
def parent_id
15
end
def tags
["tag1", "tag2"]
end
def tag_ids
[1, 2]
end
end
describe "A Drop" do
context "which has associations" do
context "when belongs to an item" do
before(:al... | true |
bdf7be463b65c30409046d4487b59bf16703f755 | Ruby | procchio6/active-record-project | /lib/support/cli.rb | UTF-8 | 330 | 3.03125 | 3 | [] | no_license | class CLI
def initialize
puts "Hello and welcome to the Flatiron library!"
end
def get_user_info
while @user.nil?
puts "What is your name?"
name = gets.chomp.downcase
@user = User.find_by_name(name)
if @user.nil?
puts "User not found! Please try again."
end
end
... | true |
850a3a2bfaa5fcafaab6d79ed704491f90683976 | Ruby | ChaeOkay/CoreRuby | /4week/W4C1.rb | UTF-8 | 1,320 | 4.34375 | 4 | [] | no_license | =begin
Exercise1. Write a class called Dog, that has name as an instance variable and the following methods:
bark(), eat(), chase_cat()
I shall create the Dog object as follows:
d = Dog.new('Leo')
=end
class Dog
attr_accessor :name, :tricks
def initialize(name)
@name = name
@tricks = {}
end
def ... | true |
b876317afccdd5ad6efb96159cc7bf648342588a | Ruby | clarissa2448/kwk-pattern-lab | /pattern.rb | UTF-8 | 2,277 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class String
def black; "\e[30m#{self}\e[0m" end
def red; "\e[31m#{self}\e[0m" end
def green; "\e[32m#{self}\e[0m" end
def brown; "\e[33m#{self}\e[0m" end
def blue; "\e[34m#{self}\e[0m" end
def magenta; "\e[35m#{self}\e[0m" end
def cyan; "\e[36m#{self}\e[... | true |
c68e9d39b2f0409e8bbae96480f9ed092ce5e703 | Ruby | eugenesavenko/hammer-gem | /functional.rb | UTF-8 | 2,173 | 2.75 | 3 | [] | no_license | require "tmpdir"
require "pathname"
require "fileutils"
require "open3"
include Open3
def compare_directories a, b
_compare_directories(a, b)
_compare_directories(b, a)
end
def _compare_directories a, b
a_files = Dir.glob(File.join(a, "**/*"))
b_files = Dir.glob(File.join(b, "**/*"))
a_files.each do |a_f... | true |
1ccc0e016df3e251543fca91cef34d38504f2dd1 | Ruby | traciechang/algorithm-problems | /unique_email_addresses.rb | UTF-8 | 685 | 3.375 | 3 | [] | no_license | # leetcode
def num_unique_emails(emails)
unique_emails = []
emails.each do |email|
temp_word = ""
on_domain = false
ignore = false
email.each_char do |char|
if char == "@"
on_domain = true
ignore = false
elsif... | true |
e5b8493cb925ba9813a3663328ba6e877a817e69 | Ruby | jeffren716/W3D2 | /SQL/question_like.rb | UTF-8 | 2,303 | 2.921875 | 3 | [] | no_license | require 'sqlite3'
require_relative 'template'
require_relative 'question'
require_relative 'reply'
require_relative 'question_follow'
require_relative 'user'
class QuestionLike
attr_reader :likes
def self.all
data = QuestionsDatabase.instance.execute("SELECT * FROM question_likes")
data.map { |datum| Que... | true |
9985ccd70e70dbeb2a70db564bc24711bac6de60 | Ruby | jonfoster9999/never_ending_tape_cli | /lib/_task_runner.rb | UTF-8 | 1,691 | 2.75 | 3 | [] | no_license | require 'pry'
require 'active_support/core_ext/time/conversions'
class TaskRunner
attr_accessor :tasks_doc, :completed_tasks_doc, :path, :transfer_path
def initialize(path: nil, transfer_path: nil)
@path = path
@tasks = []
@transfer_path = transfer_path
end
def read_tasks
raw_tasks_doc = File... | true |
342893ce8e81e6bacea5e6c5b79c1796876e6f15 | Ruby | jaredm4/opsworks-scripts | /execute-instance-recipes.rb | UTF-8 | 3,181 | 2.890625 | 3 | [
"MIT"
] | permissive |
require 'rubygems'
require 'json'
def usage
puts 'Usage: execute-instance-recipes.rb <layer-id> <recipes> [\'custom-json\']'
puts
puts 'Runs recipes on all online instances in a layer, and reports their success via shell status_code.'
puts
puts 'layer-id: The OpsWorks Layer ID where the instances are loc... | true |
f327b91aacd5a4740e4f45d3b3a7872f1ed1def5 | Ruby | CaptConrado/SillyCode | /digiroot.rb | UTF-8 | 304 | 3.640625 | 4 | [] | no_license | # Challenge #122 [Easy] Sum Them Digits
# Answer: 10
num = 1073741824
def spliter challenge
challenge = challenge.to_s.split('')
fill = []
challenge.each do |i|
i_convert = i.to_i
fill.push(i_convert)
end
fill.inject(:+)
end
first_set = spliter num
answer = spliter first_set
puts answer
| true |
086de31f6bb11f9a1295a759a1bd028a7a045210 | Ruby | sajithpremadasa/Bakery | /Bakery.rb | UTF-8 | 9,612 | 3.21875 | 3 | [] | no_license | #!/usr/bin/ruby
# ==================================
# Author: Sajith Premadasa
# Date : 01 Dec 2016
# ==================================
require 'minitest/autorun'
# ==================================
# Bakery class Implementation
# Represents a certain bakery
# Bakery sells different types of
# products in diffe... | true |
96b66014bed6ac47653c9569aeda862f53b36158 | Ruby | doerte/LearningRuby | /8Ex2.rb | UTF-8 | 383 | 3.40625 | 3 | [] | no_license | title = [['Getting Started', 1],['Numbers', 9],['Letters', 13]]
puts 'Table of Contents'.center(50)
puts ''
chapterNum =1
title.each do |table|
tabtit = table[0]
tabpage = table[1]
beginning = 'Chapter ' + chapterNum.to_s + ': ' + tabtit.to_s
ending = 'page ' + tabpage.to_s
puts beginning.ljust(30) +... | true |
12c365946208efd45abe3950c41d9d68515dbb21 | Ruby | ruby-stars/lessons | /Subjects/Classes-Objects/classes_attr.rb | UTF-8 | 392 | 3.734375 | 4 | [] | no_license | class Friend
attr_accessor :name, :age, :phone_number
def initialize(name, age, phone_number)
@name = name
@age = age
@phone_number = phone_number
end
def present
puts "Hi, my name is #{name}, I am #{age} years old and my phone number is #{phone_number}"
end
end
friend3 = Friend.new('Fernan... | true |
410fe26224d9fc24f1d6148f63ed9bed97a5a901 | Ruby | victortyau/CodeEval | /Mixed Content/mixed_content.rb | UTF-8 | 845 | 3.296875 | 3 | [] | no_license | class Mix
def initialize
@lines = ""
open_file()
end
def open_file
file_name = ARGV[0]
if File.exist?(file_name)
@lines = IO.readlines(file_name);
end
end
def split_data
@lines.each do |line|
line.delete!("\n")
array = line.split(",")
string = ""
number = "... | true |
f43b4eee08d2a2252d968e39c17a760573bd1a46 | Ruby | lukepistolesi/CircularDependecyTest | /spec/unit/models/node_spec.rb | UTF-8 | 1,828 | 2.578125 | 3 | [] | no_license | require_relative '../../spec_helper'
require_relative '../../../circular_dep_app/models/node'
module CircularDepApp::Models
describe Node do
describe :initialize do
it 'sets the node name' do
node = Node.new 'My Name'
expect(node.name).to eql 'My Name'
end
it 'sets the outboun... | true |
2c5cd227049cb6afef9ba2eb915c513f2b7fb6a8 | Ruby | kukareka/lemon_fresh | /app/word_counter.rb | UTF-8 | 1,259 | 2.9375 | 3 | [] | no_license | require 'influxdb'
require 'securerandom'
class WordCounter
INFLUX_DB_NAME = ENV['INFLUX_DB_NAME'] || 'word_count'
INFLUX_HOST = ENV['INFLUX_HOST'] || 'localhost'
INFLUX_PORT = ENV['INFLUX_PORT'] || 8086
def add(word)
# InfluxDB will overwrite points with same tags/timestamp, so need either to hack the ta... | true |
17ee4bef65f6cf8e4ba7b06d6d9d088a34bea5ba | Ruby | augustinevt/learn-how-to-program-clone | /app/models/lesson.rb | UTF-8 | 414 | 2.546875 | 3 | [] | no_license | class Lesson < ActiveRecord::Base
belongs_to :course
has_many :sections
def next
new_lesson = Lesson.find_by(number: self.number + 1, course_id: self.course_id)
if new_lesson
new_lesson
else
nil
end
end
def previous
new_lesson = Lesson.find_by(number: self.number - 1, cours... | true |
639da70bad5edbeb048db66810b298908005c27e | Ruby | alejandroclaro/katas | /ruby/roman-numerals/test_roman_numerals.rb | UTF-8 | 1,259 | 3.5 | 4 | [] | no_license | #
# Roman numerals code kata unit tests.
#
require_relative "roman_numerals"
require "test/unit"
class TestRomanNumerals < Test::Unit::TestCase
def test_to_roman_1
assert_equal("I", to_roman(1))
end
def test_to_roman_2
assert_equal("II", to_roman(2))
end
def test_roman_3
asser... | true |
e4045dc21b6b5aff1791418979d9be7d87ae8324 | Ruby | awebneck/crypto-demo | /block-encrypt-authenticate | UTF-8 | 550 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'openssl'
require 'base64'
message = ARGV[0]
cipher = OpenSSL::Cipher::AES128.new :CBC
cipher.encrypt
if ARGV[1]
key = cipher.key = Base64.strict_decode64(ARGV[1])
else
key = cipher.random_key
end
iv = cipher.random_iv
ciphertext = cipher.update(message) + cipher.final
hmac = OpenSSL... | true |
a1a2f0307fdf4eb90d6bd84472ca187584c2d361 | Ruby | ltrainor1/ttt-10-current-player-v-000 | /lib/current_player.rb | UTF-8 | 324 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
turns = 0
board.each do |index|
if index == "X" || index == "O"
turns += 1
else
turns = turns
end
end
return turns
end
def current_player(board)
moves = turn_count(board)
remainder = moves % 2
if remainder == 0
return "X"
else
return "O"
end
... | true |
274e012b635fff4e9bbdd697dce5ed1a5cf76880 | Ruby | larry-cherry/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 2,560 | 4.125 | 4 | [] | no_license |
#create a method to convert fahrenheit to celcius and pass block into method
def f_to_c
puts "Please provide a temperature in Fahrenheit:"
fahrenheit = gets.chomp.to_i
celcius = ((fahrenheit - 32) * 5.0/9.0).round(2)
yield(fahrenheit, celcius)
end
f_to_c { |fahrenheit, celcius| puts "#{fahrenheit} conve... | true |
a95fefccd85f8a3e81891a2bd9328c97fc622b02 | Ruby | LiamCusack/rails-engine | /spec/requests/api/v1/merchants_request_spec.rb | UTF-8 | 2,620 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
require 'faker'
describe "Merchant API" do
describe "Merchant Index" do
it "sends a list of merchants" do
create_list(:merchant, 3)
get '/api/v1/merchants'
merchants = JSON.parse(response.body, symbolize_names: true)
expect(response).to be_successful
expect... | true |
926fc0e8901ef231106fa964b2e8b09a4d1a7241 | Ruby | stephan-nordnes-eriksen/ruby_ship | /bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/minitest-5.8.3/test/minitest/test_minitest_mock.rb | UTF-8 | 10,511 | 2.703125 | 3 | [
"MIT"
] | permissive | require "minitest/autorun"
class TestMinitestMock < Minitest::Test
parallelize_me!
def setup
@mock = Minitest::Mock.new.expect(:foo, nil)
@mock.expect(:meaning_of_life, 42)
end
def test_create_stub_method
assert_nil @mock.foo
end
def test_allow_return_value_specification
assert_equal 42,... | true |
227036bf9b1fda09a03d787772e80d72725a80eb | Ruby | TinyGoat/freshrewards | /app/models/profile.rb | UTF-8 | 1,214 | 2.71875 | 3 | [] | no_license | class Profile
def initialize(customer)
@customer = customer
end
attr_reader :customer
delegate :id, to: :customer
def current_reward_progress
@customer.balance
end
def amount_remaining_for_current_reward
reward_threshold - current_reward_progress
end
def reward_threshold
@customer... | true |
7624c659d58e3664025ae597a9ffff96be504f6b | Ruby | aha-app/calculated_attributes | /spec/lib/calculated_attributes_spec.rb | UTF-8 | 4,650 | 2.625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
def model_scoped(klass)
if klass.respond_to? :scoped
klass.scoped
else
klass.all
end
end
describe 'calculated_attributes' do
it 'includes calculated attributes' do
expect(model_scoped(Post).calculated(:comments_count).first.comments_count).to eq(1)
end
it 'includes param... | true |
c8778afcc93829d3ed521515e1746341555ba2e3 | Ruby | KalebGz/Flatiron | /code/module-2/Because-project/app/models/reply.rb | UTF-8 | 1,187 | 2.5625 | 3 | [] | no_license | class Reply < ApplicationRecord
belongs_to :comment
belongs_to :post
belongs_to :user
validates :content, presence: true, if: :because?, unless: -> { content.include?('?')}
validates :content, length: { minimum: 250, message: "A post must contain at least 250 characters, or include a question mar... | true |
41e835fe591f41305bdd4a6609029d5cdedda4ec | Ruby | wasabigeek/aoc2020 | /day2/day2.rb | UTF-8 | 1,574 | 3.296875 | 3 | [] | no_license | require_relative '../helpers'
class PartOne
include FileHelpers
INPUT_REGEX = /(\d+)-(\d+) ([a-z]): ([a-z]+)/
def check_passwords_in_file(path)
passwords = readlines_from_file(path)
valid_passwords = passwords.reduce(0) do |count, password|
count += 1 if check_password(password)
count
e... | true |
f80c16444952052c36078d9cc0fe2141087b336a | Ruby | tuenti/sensu-community-plugins | /plugins/etcd/etcd-metrics.rb | UTF-8 | 1,868 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-free-unknown"
] | permissive | #! /usr/bin/env ruby
#
# etcd-metrics
#
# DESCRIPTION:
# This plugin pulls stats out of an etcd node
#
# OUTPUT:
# metric data
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
# gem: etcd
# gem: socket
#
# USAGE:
# #YELLOW
#
# NOTES:
#
# LICENSE:
# Copyright (c) 2014, Sean Clerkin
# Rel... | true |
b469b5b8b3a9c2b31a9eaf368d74e1094b2e0bf8 | Ruby | bankair/rt | /features/step_definitions/materials.rb | UTF-8 | 2,781 | 2.515625 | 3 | [] | no_license | require 'material'
Given("m ← material") do
@m = Material.new
end
Then("m.color = color {int}, {int}, {int}") do |int, int2, int3|
expect(@m.color).to eq(Color.new(int, int2, int3))
end
Then("m.ambient = {float}") do |float|
expect(@m.ambient).to eq(float)
end
Then("m.diffuse = {float}") do |float|
expect(@... | true |
d1cc4539cca5bb603e60cf192dfd80c34b120c6d | Ruby | yesnik/pricing_rules | /lib/pricing_rule/free_item.rb | UTF-8 | 464 | 3.09375 | 3 | [] | no_license | module PricingRule
class FreeItem
attr_reader :product, :free_item_num
def initialize(product, free_item_num)
@product = product
@free_item_num = free_item_num
end
def price(items)
count = rule_items(items).size
free_items_count = count / free_item_num
(count - free_ite... | true |
e7650de3bd087e7b845b372ad582df298f9df41b | Ruby | chmohit4/blogger | /app/controllers/blogs_controller.rb | UTF-8 | 1,918 | 2.5625 | 3 | [] | no_license | class BlogsController < ApplicationController
before_filter :authenticate_user!, :except => [:index, :show]
#before_filter :load_blog, :only => [:show, :edit, :update, :destroy]
before_filter :load_blog, :except => [:index, :new, :create]
def index
@blogs = Blog.all
end
def new
@blog = Blog.new
end
d... | true |
0823b05f7fd20f5c3437bf4388e08bbbd545e4c5 | Ruby | jekyll/jekyll | /benchmark/conditional_liquid.rb | UTF-8 | 3,769 | 2.75 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require "liquid"
require "benchmark/ips"
# Test if processing content string without any Liquid constructs, via Liquid,
# is slower than checking whether constructs exist ( using `String#include?` )
# and return-ing the "plaintext" content string as is..
#
# Ref: http... | true |
dbd9c9fa3d2bc7299c71c703acedc733095a68f2 | Ruby | scpike/rails-units | /lib/rails_units/unit.rb | UTF-8 | 42,912 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'date'
if RUBY_VERSION < "1.9"
require 'parsedate'
require 'rational'
end
# = Ruby Units
#
# Copyright 2006-2011 by Kevin C. Olbrich, Ph.D.
#
# See http://rubyforge.org/ruby-units/
#
# http://www.sciwerks.org
#
# mailto://kevin.olbrich+ruby-units@gmail.com
#
# See README for detailed usage instructions and... | true |
efa4c5dcbbb5199b1025e2b39c5e358364a8daac | Ruby | Iscaraca/Iai-ruby | /deck_of_cards.rb | UTF-8 | 336 | 3.65625 | 4 | [] | no_license | # Suits: C, D, S, H
# Numbers 1 to 10
# Pictures J, Q, K
# Jokers 2
deck_of_cards = ["Joker", "Joker"]
suits = ["C", "D", "S", "H"]
values = ("1".."10").to_a
values.append("J", "Q", "K")
suits.each do |suit|
values.each do |value|
deck_of_cards.append(value + suit)
end
end
print deck_... | true |
3da3165ca4172a3e85939d13bff9f465df714962 | Ruby | nasnick/scripts | /ruby/wordpress_not_touched_for_3_months.rb | UTF-8 | 871 | 2.65625 | 3 | [] | no_license |
wp_content = []
wp_includes = []
wp_admin = []
a = File.open('/Users/nickschofield/Desktop/wordpress/wp-content') do |a|
a.each_line do |line_a|
wp_content << line_a
end
end
b = File.open('/Users/nickschofield/Desktop/wordpress/wp-includes') do |b|
b.each_line do |line_b|
wp_includes << line_b
end
end
... | true |
f37be847d70aa7f5b524657d1d531bf1460ddf24 | Ruby | durerSV/ruby | /lesson7/route.rb | UTF-8 | 840 | 3.6875 | 4 | [] | no_license | class Route
attr_reader :stations, :name
def initialize(from, to)
@stations = [from, to]
@name = "#{from.name}-#{to.name}"
validate!
end
def add_station (station)
@stations.insert(-2, station)
end
def delete_station(station)
@stations.delete(station)
end
def print_route
@... | true |
963e69ac46a4a2c4eb2cc26b254918032035cf87 | Ruby | kealanmcd/Ruby | /Week 6/Assignment: OOPsie Project/children.rb | UTF-8 | 1,828 | 3.1875 | 3 | [] | no_license | require './parent.rb'
require './modules.rb'
class Wizard < LifeForm
include BaseWizardSpells
attr_reader :wizard_type
@@acceptable_items[:cloak] = 1
def initialize(name, age, height, wizard_type)
super(name, age, height)
self.wizard_type=(wizard_type)
end
def speak
puts "I am a #{wizard_typ... | true |
6f696820278acc884333203d6b90f156cb8b503d | Ruby | ritabc/library-system | /lib/Patron.rb | UTF-8 | 640 | 3.109375 | 3 | [
"MIT"
] | permissive | class Patron
attr_reader(:name, :id)
def initialize(attributes)
@name = attributes.fetch(:name)
@id = attributes.fetch(:id)
end
def ==(another_thing)
self.name().==(another_thing.name())
end
def save
result = DB.exec("INSERT INTO patrons (name) VALUES ('#{@name}') RETURNING id;")
@id ... | true |
a773254098bfccccaab11175a5ff415c37b06686 | Ruby | JAtherton1072/Julie_Atherton_PDA | /Static_and_Dynamic_Task_A/specs/card_game_spec.rb | UTF-8 | 674 | 3.125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../card_game')
require_relative('../card')
class TestCardGame < Minitest::Test
def setup
@card1 = Card.new("Hearts", 1)
@card2 = Card.new("Spades", 8)
@card3 = Card.new("Clubs", 5)
@card4 = Card.new("Diamond", 3)
@cards = [@car... | true |
c92db39d19f03c8356f91e77997758dece636385 | Ruby | aki1502/pypret | /pypret.rb | UTF-8 | 39,735 | 2.765625 | 3 | [] | no_license | =begin
所属: 総合人間学部3回生
氏名:
学生番号:
概要: Pythonの翻訳機
操作法: ruby pypret.rb [Pythonの文法で書かれたプレーンテキスト]
動機: 似た課題を提出しそこねたため。
アピールポイント: 手間が掛かっている。
自己評価: 99点
改良すべき点: 下記のとおり機能に制限があるため、本物に寄せたい。
注意点: import文,raise文,try文,class文,yield文,async文,with文,
global文,nonlocal文には対応していません。
複素数に対応していません。
tuple,set,frozensetに対応し... | true |
d0e713cf63d8796ddc1f2f0cbfe5ad0886984da7 | Ruby | xdkernelx/phase-0-tracks | /ruby/client.rb | UTF-8 | 2,981 | 3.359375 | 3 | [] | no_license | #Nestor Alvarez
#DBC, Bobolinks
#5.3, 20160808, 17:17 PDT
class Client
# Initializes Client object with keyword arguments
# Params:
# +args+:: arguments match parameters, have default values
def initialize(first_name: "", last_name: "", age: 0, children: 0,\
decor_theme: "", vip_me... | true |
2e01db67a6dd99d2ca6fb5ef1a48719bea06b5e7 | Ruby | youngorchen/ruby-codesnippet | /scripts/nodes-man/test_ip.rb | UTF-8 | 943 | 2.734375 | 3 | [] | no_license | ip_list=%w(
172.16.0.85
172.16.0.86
172.16.0.87
172.16.0.88
172.16.0.89
172.16.0.90
172.16.0.91
172.16.0.92
172.16.0.93
172.16.0.94
172.16.0.95
172.16.0.96
172.16.0.97
172.16.0.98
172.16.0.99
172.16.0.100
172.16.0.101
172.16.0.102
172.16.0.103
172.16.0.104
172.16.0.105
172.16.0.106
... | true |
010a3c4500cf85f2f2876126f5162135460fb83c | Ruby | cheezenaan/procon | /atcoder/abc115/b.rb | UTF-8 | 109 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
n = gets.to_i
ps = n.times.map { gets.to_i }
puts ps.inject(:+) - ps.max / 2
| true |
8b0341d5586e51355f60fea8b82ca961869f825f | Ruby | gadgetguy82/codeclan_caraoke_hw | /room.rb | UTF-8 | 1,122 | 3.421875 | 3 | [] | no_license | require_relative('./bar_tab')
class Room
attr_reader :number, :guests, :songs
def initialize(number, capacity)
@number = number
@guests = []
@songs = []
@capacity = capacity
@bar_tab = BarTab.new
end
def check_in(guest)
if @guests.length < @capacity
@guests << guest
else
... | true |
4b4867c532c99594c991203088ed726e987bc18e | Ruby | JoinJanay-JS/my-each-online-web-pt-090819 | /my_each.rb | UTF-8 | 131 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "pry"
def my_each(array) # put argument(s) here
i = 0
while i < array.length
yield(array[i])
i = i + 1
end
end
end
| true |
9949ef17b06de8e088e1d44b9853181e7a68698e | Ruby | Fernandocgomez/crypto-trading-app-api | /app/models/user.rb | UTF-8 | 2,031 | 2.578125 | 3 | [] | no_license | class User < ApplicationRecord
# DB relationships
has_secure_password
has_one :portafolio
# Global validations
validates :username, :email, :password, :first_name, :last_name, presence: true
validates :password_confirmation, presence: true, on: :create
validates :email, :username, uniquene... | true |
2581fc4637f4650525db2cb5daf883d5d588c1e5 | Ruby | codyruby/cursus_thp_bis | /week4/the_gossip_project/lib/gossip.rb | UTF-8 | 715 | 2.796875 | 3 | [] | no_license | class Gossip
attr_accessor :author, :content
def initialize(author, content)
@author = author
@content = content
end
def save
CSV.open("./lib/db/gossip.csv", "ab") do |csv|
csv << [@author, @content]
end
end
def self.all
all_gossips = []
... | true |
0750121637328aaa407462a090e90d104b2679c2 | Ruby | stefanosu/ruby-objects-belong-to-lab-dumbo-web-051319 | /lib/song.rb | UTF-8 | 126 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "artist.rb"
class Song
attr_accessor :title, :artist
def initialize()
@title = title
end
end
| true |
e91894ae9def35b6e5f267473bb6e6f16846ac55 | Ruby | MrSnickers/FIS | /todos/todo14/triangle_class.rb | UTF-8 | 615 | 3.421875 | 3 | [] | no_license | ### CLASS TRIANGLE
class Triangle
exception :TriangleError
attr_reader :side1, :side2, :side3, :kind
def initialize(a, b, c)
@kind
@side1 = a
@side2 = b
@side3 = c
self.assign_kind
end
def assign_kind
if side1 == side2
if side1 == side3
@kind = :equilateral
els... | true |
e672805e83a682d961581dbb4d834cf724395c00 | Ruby | KrisHolley/hello_world | /numbers_minedminds.rb | UTF-8 | 206 | 2.84375 | 3 | [] | no_license | count = 1
until count == 101
if count %3 == 0 &&
count %5 == 0
puts"mined minds"
elsif
count %3 == 0
puts"mined"
elsif
count %5 == 0
puts"minds"
else
puts count
end
count = count+1
end | true |
6382e6b6f8f963b1ee2fb4dc117303f86ef0c080 | Ruby | tmknom/tech-news | /lib/tasks/command/sidekiq.rake | UTF-8 | 3,746 | 2.59375 | 3 | [] | no_license | namespace :command do
namespace :sidekiq do
require 'sidekiq/api'
require 'awesome_print'
# SidekiqのAPIドキュメント
# https://github.com/mperham/sidekiq/wiki/API
desc 'Sidekiqのジョブ一覧を表示'
task :show_all do
queues, scheduled_set, retry_set, dead_set = [], [], [], []
queue_names.each { |q... | true |
c9dbcb793d2a652e2046222eb9b02ef0e57d2a61 | Ruby | TransformCore/trade-tariff-backend | /app/services/meursing_measure_component_resolver_service.rb | UTF-8 | 1,545 | 2.59375 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | class MeursingMeasureComponentResolverService
def initialize(root_measure, meursing_measures)
@root_measure = root_measure
@meursing_measures = meursing_measures
end
def call
# Iterate root measure components and replace placeholder meursing components with meursing measure answer components
root... | true |
bc1d84090d6ca6513b27a9b37f9400af3ca7d1b8 | Ruby | prurph/algo-practice | /merge_sort.rb | UTF-8 | 1,404 | 4 | 4 | [] | no_license | # merge sort: O(n*log n) average and maximum; quicksort usually faster in prac
# not in-place, there are stable implementations but this is not
# recursive: base case return array if length <= 1
# otherwise divide array into left, right halves, call merge(left, right)
# merge merges arrays by checking if left or right... | true |
30157929353bcd1483e7af9db154cec5cd01299a | Ruby | drakontis/hackerrank | /tutorial/cracking_the_code_interview/ransome_note.rb | UTF-8 | 754 | 3.5625 | 4 | [
"MIT"
] | permissive | # https://www.hackerrank.com/challenges/ctci-ransom-note/problem
#!/bin/ruby
def check_words_availability(magazine, ransom)
all_words_available = true
ransom.each do |ransom_element|
magazine.each_with_index do |magazine_element, magazine_index|
if ransom_element != magazine_element
all_words_a... | true |
ed0580c6de46ea7000d1733e6e1f6dd2561dee93 | Ruby | geckods/CodeChef | /February19/chefing.rb | UTF-8 | 288 | 2.796875 | 3 | [] | no_license | require 'set'
if File.exists?("input")
$stdin = File.open("input")
$stdout = File.open("output","w")
end
t = gets.to_i
t.times do
n = gets.to_i
myset = gets.chomp.each_char.to_a
(n-1).times do
set = gets.chomp.each_char.to_a
myset = myset&set
end
puts myset.uniq.size
end | true |
476a48d3fe63e47783f444682b017e165ea26304 | Ruby | bdarfler/CodeKata | /ruby/02/KataTwo.rb | UTF-8 | 1,815 | 3.59375 | 4 | [] | no_license | class KataTwo
def self.chop_iterative(target, list)
first = 0
last = list.size - 1
while first <= last do
mid = (first + last) / 2
if list[mid] < target
first = mid + 1
elsif list[mid] > target
last = mid - 1
else
return mid
end
end
return -1
... | true |
eec013b0a21111b305a61fd6be94a6c3e2c1916f | Ruby | wangjohn/eager_db | /lib/eager_db/prediction/probability_calculator.rb | UTF-8 | 2,389 | 2.671875 | 3 | [
"MIT"
] | permissive | module EagerDB
module Prediction
class ProbabilityCalculator
attr_reader :time_threshold, :probability_storage
def initialize(logs, time_threshold)
@logs = logs
@time_threshold = time_threshold
@probability_storage = Hash.new { |h,statement| h[statement] = MarkovProbabilitySt... | true |
61550c84b69e2bf6565bb603afb041115f340a69 | Ruby | ninjudd/rupture | /lib/rupture/reader.rb | UTF-8 | 2,116 | 3.328125 | 3 | [
"MIT"
] | permissive | require 'set'
module Rupture
class Reader
def initialize(input)
@input = input
@buffer = []
end
def ungetc(*chars)
@buffer.concat(chars)
@space = false
chars.last
end
def getc
while c = (@buffer.shift || @input.getc.chr)
if c =~ /[\s,;]/
ne... | true |
8c38d0681cd141d6120e233285dffc56871dbfa0 | Ruby | audy/phylograph | /lib/cluster.rb | UTF-8 | 1,502 | 2.96875 | 3 | [
"MIT"
] | permissive | # A SIMPLE INTERFACE FOR CDHIT
class Cluster
def self.compute_clusters(similarity, filename)
output = "#{filename}_out"
# Compute clusters
run_cdhit filename, output, similarity
# Parse CDHIT Output
parse_cdhit output
# Return results
end
def self.run_cdhit(input, output, si... | true |
9e5b295c69d45a231ec2b8315f3207e8d1c1d084 | Ruby | sebaquevedo/desafiolatam | /mayorque.rb | UTF-8 | 183 | 3.546875 | 4 | [
"MIT"
] | permissive | #fixnums
puts " ingrese dos numeros"
numero1=gets.chomp.to_i
numero2=gets.chomp.to_i
if numero1 > numero2
puts "el primer numero es mayor"
else puts "el segundo numero es mayor"
end | true |
08674258dc6106a238ca158cb9bc4cc9754b5fe3 | Ruby | vitorkaio/controle-estoque-ruby | /outros/learn/arrays_loops.rb | UTF-8 | 879 | 4.34375 | 4 | [] | no_license | # Array com 10 primeiros números.
lista = Array(0..10)
puts "***** For ****"
for cont in lista
puts "Número: #{cont}"
end
# Entrar com dados em uma array.
=begin
l = Array.new()
for cont in 0..3
print "Entre com uma string: "
l.push(gets())
end
for cont in l
puts "Dado: #{cont}"
end
=end
puts "***** While ... | true |
d729c9abb3d44d19cb888b37729489e69199f7b3 | Ruby | wmleidy/advent-of-code-ruby | /problems/9-minimum-distance.rb | UTF-8 | 1,424 | 4.1875 | 4 | [] | no_license | # --- Day 9: All in a Single Night ---
##### A Version of The Traveling Salesman Problem #####
# Every year, Santa manages to deliver all of his presents in a single night.
# This year, however, he has some new locations to visit; his elves have provided him the distances between every pair of locations. He can star... | true |
c2a33d06ffb2d91fcac8bada02c50ebf3061c141 | Ruby | exp-ndrew/triangle_classifier | /lib/Triangle.rb | UTF-8 | 534 | 3.765625 | 4 | [] | no_license | class Triangle
def initialize side1, side2, side3
@side1 = side1.to_i
@side2 = side2.to_i
@side3 = side3.to_i
end
def side1
@side1
end
def side2
@side2
end
def side3
@side3
end
def classify
tri_arr = []
tri_arr << @side1
tri_arr << @side2
tri_arr << @side3
... | true |
204fc567be77e935c3f7a485e9978a1042865a35 | Ruby | plkujaw/boris-bikes | /spec/dockingstation_spec.rb | UTF-8 | 1,413 | 2.875 | 3 | [] | no_license | require "dockingstation"
describe DockingStation do
it "responds to 'release_bike'" do
expect(subject).to respond_to(:release_bike)
# expect{DockingStation.new.release_bike}.not_to raise_error
end
it "releases working bike" do
bike = Bike.new
expect(bike).to be_working
end
it "responds to ... | true |
da9e98e643097a8013c0f4305184b1fce9e7c85b | Ruby | oneiros/canned_meat | /lib/canned_meat/template_renderer.rb | UTF-8 | 615 | 2.765625 | 3 | [
"MIT"
] | permissive | module CannedMeat
class TemplateRenderer
def initialize(template, markdown)
@template = template
@markdown = markdown
end
def render_html
html = render_markdown(::Redcarpet::Render::HTML)
VariableReplacer.new(content: html)
.replace @template.html
end
def render_... | true |
f888e8af9862a641ea37b01304a3a9b823a47273 | Ruby | DavidBarriga-Gomez/market_1908 | /lib/market.rb | UTF-8 | 1,364 | 3.375 | 3 | [] | no_license | class Market
attr_reader :name, :vendors
def initialize(name)
@name = name
@vendors = []
end
def add_vendor(vendor)
@vendors.push vendor
end
def vendor_names
@vendors.map do |vendor|
vendor.name
end
end
def vendors_that_sell(food_item)
@vendors.find_all do |vendor|
... | true |
3d4c04cfbd0e6112d534432a6d71cb0f23545d5c | Ruby | AdrienTchinda/scrapping | /lib/bourse.rb | UTF-8 | 513 | 2.8125 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
page = Nokogiri::HTML(open("https://coinmarketcap.com/all/views/all/"))
all_prices_links = page.xpath('//a[@class="price"]')
arrayprices = []
i = 0
all_symbols_links = page.xpath('//td[@class="text-left col-symbol"]')
arraysymbol = []
all_symbols_links.each do |symbol_... | true |
5b03afb847017057f9e75dfd32e212356be17240 | Ruby | bucknermr/algorithms | /interview_cake/stock_price/stock_price.rb | UTF-8 | 1,447 | 4.03125 | 4 | [] | no_license | def get_max_profit(stock_prices)
raise "Need at least 2 stock prices" if stock_prices.length < 2
min = stock_prices.first
best_profit = -1/0.0
stock_prices.drop(1).each do |price|
profit = price - min
best_profit = profit if profit > best_profit
min = price if price < min
end
best_profit
end
... | true |
3a247b18897d05c616ac48f3f1f4073dfdbdd269 | Ruby | arbonap/interview-practice | /stringcompression.rb | UTF-8 | 873 | 4.125 | 4 | [] | no_license | #Implement a method to perform basic string compression
#usign the counts of repeated characters.
# For example, the string 'aabcccccaaa' would
#become 'a2b1c5a3'. If the "compressed" string
# would not become smaller than the original string, your
# method should return the original string.
#Assume string has only upp... | true |
dba869a3f34eda75573b85209def4edaf16f9962 | Ruby | Hives/makers-process-reviews | /03-checkout/lib/checkout.rb | UTF-8 | 401 | 3.453125 | 3 | [] | no_license | def checkout(basket)
return -1 if basket.is_a?(Integer)
return -1 if basket != basket.upcase
a_count = basket.count("A")
b_count = basket.count("B")
c_count = basket.count("C")
d_count = basket.count("D")
price = 50 * a_count
discount = (a_count/3) * 20
price += 30 * b_count
discount += (b_count/... | true |
e8c6ef6f673a598d1aa1cfca84370a349cff9a94 | Ruby | zombiecalypse/SinatraStory | /iteration06/app/models/user.rb | UTF-8 | 1,432 | 3.0625 | 3 | [] | no_license | require 'rubygems'
require 'bcrypt'
module Models
class User
attr_reader :name, :password_hash, :password_salt
@@users = {}
def initialize(name, password)
# Promise me to never store a password in clear text in your
# database!
# BCrypt is good *because* it is slow, making it hard to ... | true |
da7f3e2a78604da648b45784c8335b3b7d09a133 | Ruby | schacon/cucumber | /lib/cucumber/ast/feature.rb | UTF-8 | 2,430 | 2.65625 | 3 | [
"MIT"
] | permissive | module Cucumber
module Ast
# Represents the root node of a parsed feature.
class Feature #:nodoc:
attr_accessor :file, :language
attr_writer :features
attr_reader :name
def initialize(background, comment, tags, name, feature_elements)
@background, @comment, @tags, @name, @feat... | true |
614d8bb68024d1ac8e0b9889071be56f8c4683a6 | Ruby | steve-lynx/DuckQuack | /examples/test11.rb | UTF-8 | 587 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | #-*- ruby -*-
# Supporto per database sqlite
DB = app.database_connect
DB.create_table!(:contatti) {
String :nome
String :cognome
String :telefono
}
DB[:contatti].insert(
nome: "Massimo",
cognome: "Ghisalberti",
telefono: "1234567890")
DB[:contatti].insert(
nome: "Stefano",
cognome: "Penge",
... | true |
4ce213a33f9953288a0252ed62ba31665bdf0f3e | Ruby | WitoldSlawko/Ruby_Files_Tamer | /lib/rft/mutation.rb | UTF-8 | 2,801 | 3.140625 | 3 | [
"MIT"
] | permissive | module Mutation
def self.create(to_create)
File.open(to_create, "w");
end
def self.overwrite_text(to_overwrite)
puts "Write text to " + to_write + ' :'
new_text = STDIN.gets.chomp
File.open(to_write, "w").syswrite(new_text)
end
def self.append_text(to_write)
puts "Append text to " + to_... | true |
04a4d1139673474fcc2eeafe6de06d3dd926037f | Ruby | Thorsson/open-weather | /app/models/weather.rb | UTF-8 | 1,333 | 2.8125 | 3 | [] | no_license | class Weather < ActiveRecord::Base
validates :description, :temperature, :speed, :data, :lat, :lon, presence: true
TIME_RANGE = 15.minutes
LOCATION_PRECISION = 2
def self.current_weather location
location = optimize_location(location)
if (report = latest_weather(location))
report
else
... | true |
ae6979bb73e6ff83a56fcf4bc7117c2de024f3ad | Ruby | SanaNasar/ruby_inheritance | /inheritance.rb | UTF-8 | 478 | 4.09375 | 4 | [] | no_license | class Box
def initialize(w, h)
@width = w
@height = h
end
def get_area
@width * @height
end
end
class BigBox < Box
def print_area
@area = @width * @height
end
end
# 1.) How would I create a box? How could I create a BigBox?
# 1.) How would I print the area of the BigBox?
b1 = Box.new... | true |
4da61343d1463ef95118c5336d84431cba89ab25 | Ruby | benwbrum/antique_date | /lib/antique_date/documentary_date.rb | UTF-8 | 720 | 2.890625 | 3 | [
"MIT"
] | permissive | module AntiqueDate
class DocumentaryDate
@regime = nil
@verbatim = nil
# # proleptic Gregorian
# def to_gregorian
#
# end
#
# produces a YYYY-MM-DD string resembling ISO-8601 containing a version of the date on the document with year normalized to a January 1 New Year'... | true |
1f53c87203c27eee253b7420c1e7ec1c4f4f7a92 | Ruby | nybblr/dotfiles | /bin/mlv_batch | UTF-8 | 381 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
videos = ARGV.map do |path|
if File.directory?(path)
Dir[File.join(path, "*.MLV")]
else
path
end
end.flatten
videos.each do |video|
directory = video.chomp(File.extname(video))
Dir.mkdir(directory)
puts "Extracting #{video}..."
# puts "mlv_dump --dng -o \"#{directory}\" \"#{vi... | true |
0b1de178dbab393cbf5ca7101187b8d6f8f49c40 | Ruby | urimaro/progate_ruby | /ruby_v/11_index.rb | UTF-8 | 87 | 3.15625 | 3 | [] | no_license | require "date"
birthday = Date.new(1974, 12, 13)
puts birthday
puts birthday.sunday?
| true |
df6ccdf444cf046249d9620f4ab7e2c720e04550 | Ruby | caporta/oo-data-normalization-001 | /lib/song.rb | UTF-8 | 265 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :artist, :title
def initialize() end
def slugify
slug = @title.gsub(" ", "_").downcase
file = Tempfile.new([slug, ".txt"], "tmp")
file.write("#{self.artist.name} - #{self.title}")
file.close
end
end
| true |
e0ac94c9da6558d518e314cb1092d8e3de556e22 | Ruby | enspirit/wlang | /spec/unit/scope/test_null_scope.rb | UTF-8 | 815 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module WLang
class Scope
describe NullScope do
let(:scope){ NullScope.new }
it 'throws on fetch' do
lambda{ scope.fetch(:who) }.should throw_symbol(:fail)
end
it 'throws on fetch even on `self`' do
lambda{ scope.fetch(:self) }.should throw_symbol(:f... | true |
4bd6a6822e6ce489afc974f2de096fede9c9d076 | Ruby | Victor-Arruda/Gerenciador-de-Matriculas | /app/models/student.rb | UTF-8 | 464 | 2.71875 | 3 | [] | no_license | class Student < ActiveRecord::Base
has_many :enrollments
validates_uniqueness_of :cpf
validates_presence_of :cpf, :rg, :birth_date, :name, :phone
validate :check_cpf
def check_cpf
require 'cpf_cnpj'
errors.add(:cpf, 'Esse CPF não é válido!') unless CPF.valid? self.cpf
end
def bissextile_year
... | true |
e2f952b943db3bc791e85675b8d204c0919f162d | Ruby | BCI-AR/RubyNeuroServer | /command_handler.rb | UTF-8 | 2,278 | 3.171875 | 3 | [] | no_license | require 'optparse'
class CommandHandler
def initialize(client)
@client = client
end
def help_message
{
hello: "Healthcheck",
close: "Close client connection",
role: "Displays client role [CONTROLLER, EEG, DISPLAY]",
control: "Sta... | true |
46932c0640dfa85abe1d9dccdfd7e194671cd93f | Ruby | shioimm/til | /practices/exercism/ruby/2019/luhn.rb | UTF-8 | 736 | 3.71875 | 4 | [] | no_license | # Luhn from https://exercism.io
class Luhn
def self.valid?(string)
new(string).valid?
end
def initialize(string)
@string = string
end
def valid?
return false if numbers.length <= 1
return false if string.match? /[^\d\s]/
(checksum % 10).zero?
end
private
attr_reader :string
... | true |
13df071994bebf5865f18b8524ebea303de7ea9c | Ruby | learn-co-curriculum/roman-numerals | /spec/roman_numerals_spec.rb | UTF-8 | 1,372 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | describe Integer, '#to_roman' do
it 'converts 1 to I' do
expect(1.to_roman).to eq('I')
end
it 'converts 2 to II' do
expect(2.to_roman).to eq('II')
end
it 'converts 3 to III' do
expect(3.to_roman).to eq('III')
end
it 'converts 4 to IV' do
expect(4.to_roman).to eq('IV')
end
it 'conv... | true |
cda071cf5f6f5a04fc871d5c4858fed721bbb687 | Ruby | Krolmir/ruby-exercises | /rb101_rb109_small_problems/easy_8/fizz_buzz.rb | UTF-8 | 965 | 4.5 | 4 | [] | no_license | # Write a method that takes two arguments: the first is the starting number,
# and the second is the ending number. Print out all numbers between the two
# numbers, except if a number is divisible by 3, print "Fizz", if a number is
# divisible by 5, print "Buzz", and finally if a number is divisible by 3 and
# 5, print... | true |
7e4e25f588e3b7ca859741699400600a4a737421 | Ruby | mwagner19446/wdi_work | /w02/d04/Etan/gladiator/lib/gladiator.rb | UTF-8 | 559 | 3.21875 | 3 | [] | no_license | class Gladiator
def initialize(name, weapon)
@name = name
@weapon = weapon
end
def name
return @name
end
def weapon
return @weapon
end
end
class Arena
def initialize(name)
@name = name.capitalize
@gladiators = []
end
def name
return @name
end
def gladiators
re... | true |
5013c26ec7428dd5b046443aaa3521789506b4ac | Ruby | niklas/ilhan-cci | /lib/annual.rb | UTF-8 | 576 | 2.9375 | 3 | [] | no_license | class Annual < Crunch
def unpack
list = []
csv = File.read 'db/annual.txt'
csv.lines.each do |line|
datum, op, cl, hi, lo = line.split
if op && cl && hi && lo && datum =~ /(\d\d)\.(\d\d)\.(\d{4})/
epoch = Time.new($3.to_i, $2.to_i, $1.to_i).to_i
list << Pupple.new(
... | true |
5af40a9d0f1496375b97f3359492693666e188b6 | Ruby | jasonkwong11/flatiron-bnb-methods-v-000 | /app/models/city.rb | UTF-8 | 539 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
def city_openings(date1, date2)
self.listings.find_all{|listing| listing.available?(date1, date2)}
end
def total_reservations
self.listings.inject(0) {|sum, listing| sum + listing.reservations.c... | true |
89be28380aaf0d4942819960848fb5c67186bc40 | Ruby | jlangley3/programming-univbasics-4-finding-the-maximum-value-in-an-array-lab-wdc01-seng-ft-042020 | /lib/finding_the_max_value.rb | UTF-8 | 178 | 3.234375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_max_value(array)
count = 0
max_value = -1
while count < array.length do
if max_value < array[count]
max_value = array[count]
end
count += 1
end
max_value
end | true |
87db6db79cedad99df2aaabc9e33796a33347778 | Ruby | IanVaughan/random-ruby | /dn_query.rb | UTF-8 | 1,307 | 2.65625 | 3 | [] | no_license | require 'sequel'
require 'mysql2'
require 'yaml'
DB = Sequel.connect('mysql2://root@127.0.0.1:3306/death_star_development')
def show_tables_sql
"SHOW TABLES"
end
def get_fields_sql table
"SELECT DISTINCT(c.column_name) FROM INFORMATION_SCHEMA.COLUMNS c WHERE c.table_name = '#{table}';"
end
def get_count_sql tab... | true |
b477128abceab973996e0f402c18b998765a4830 | Ruby | felipegruoso/dojos | /07_checkbook/checkbook_spec.rb | UTF-8 | 916 | 3.296875 | 3 | [] | no_license | require 'rspec'
require_relative 'checkbook'
RSpec.describe 'Checkbook' do
context 'units' do
it { expect(Checkbook.convert(1)).to eq('um real') }
it { expect(Checkbook.convert(9)).to eq('nove reais') }
end
context 'tens' do
it { expect(Checkbook.convert(10)).to eq('dez reais') }
it { expect(Ch... | true |
7bd2f15a3851d6e3f71d8401299b88417c188d90 | Ruby | boaromayo/pagr | /scripts/window/Window_Escape.rb | UTF-8 | 2,034 | 2.765625 | 3 | [] | no_license | class Window_Escape < Window_Base
# --------------------------------
def initialize
super(440, 256, 192, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 5000
refresh
end
# --------------------------------
def refresh
if $scene.is_a?(Scene_Battle)
@escape_pro... | true |
c0d16ea6c47eefd855a0d25e8db519dbbd724544 | Ruby | csmartinez/Ruby-Dictionary | /lib/dictionary.rb | UTF-8 | 774 | 2.953125 | 3 | [
"MIT"
] | permissive | class Dictionary
@@dictionaries = []
define_method(:initialize) do |name|
@name = name
@terms = []
@id = @@dictionaries.length().+(1)
end
define_method(:name) do
@name
end
define_method(:terms) do
@terms
end
define_method(:id) do
@id
end
define_singleton_method(:all) do
... | true |
4de63fa28b6a5b61b363e979ffaa98e46ea4bab8 | Ruby | ViaMarcus/ruby_exercises | /my_group.rb | UTF-8 | 461 | 3.8125 | 4 | [] | no_license | my_group = Array.new
person_1 = {name:"Leah",age:1,gender:"female"}
person_2 = {name:"Simba",age:13,gender:"male"}
person_3 = {name:"Mufasa",age:53,gender:"male"}
my_group.push person_1
my_group.push person_2
my_group.push person_3
my_group.each do |entry|
if entry[:gender] == "male"
puts "#{entry[:name]} is #{entr... | true |
47b14f76588c2365a2b54662e26fc55fcfcc60d0 | Ruby | tabasano/wavseq | /sequence-record.rb | UTF-8 | 1,218 | 2.5625 | 3 | [
"MIT"
] | permissive | tmp="seq-byseqrec.txt"
tmp=ARGV.shift
adjustlevel=ARGV.shift
adjustpercent=ARGV.shift
def hint
puts "usage: #{$0} outputfile (adjust-level adjust-percent)"
puts " make sequence data by series of enter keys. first 3 enters are for making minimum unit span only."
puts " adjust-parameters for quantize"
puts " ... | true |
f4d916421c761208d81bae3fbad8f58399324018 | Ruby | markprzepiora/crave | /lib/crave/serializers/direnv_serializer.rb | UTF-8 | 1,102 | 2.625 | 3 | [
"MIT"
] | permissive | require 'crave'
module Crave::Serializers::DirenvSerializer
def self.serialize_many(dependencies)
dependencies.map do |dependency|
serialize(dependency)
end.join("\n") +
"\n" +
"# Finally, add the .bin directory to the path\n" +
"PATH_add .bin\n"
end
def self.serialize(satisfied_depend... | true |
890b7e789748cf5e9d023cc1cfb588fa1d88c6cf | Ruby | festinalent3/boris_bikes | /spec/van_spec.rb | UTF-8 | 1,224 | 2.5625 | 3 | [] | no_license | require 'bike_container'
require 'van'
describe Van do
let(:working_bike) { double(:working_bike, working: true) }
let(:broken_bike) { double(:broken_bike, working: false) }
let(:garage) { double(:garage) }
let(:ds) { double(:ds) }
it 'takes broken bikes from the docking station' do
allow(ds).to receive(:bikes... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.