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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c63e99789402ca7ccb151f1856aebac47165e99a | Ruby | yuuyas222/class_inherit | /dvd.rb | UTF-8 | 452 | 3.546875 | 4 | [] | no_license | class DVD < Product
# attr_reader :running_time
# def initialize(name, price, running_time)
# super(name, price)
# @running_time = running_time
# end
# def to_s
# "name: #{name}" #スーパークラスのprivateメソッド
# end
private
def name
"An nice product"
end
end
# d... | true |
2aaa11745269084a41e8545d3e7266c737c499ad | Ruby | snikch/suitebar.co.nz | /app/models/diary.rb | UTF-8 | 290 | 3.609375 | 4 | [] | no_license | class Diary
def self.day_valid? date
# Sun, thur, fri, sat
date.sunday? || date.thursday? || date.friday? || date.saturday?
end
def self.hour_valid? date
date.hour >= 18 && date.hour <= 22
end
def self.minutes_valid? date
[0, 30].include? date.minute
end
end
| true |
64174e62bcf75aeed82caab31d30253152ec44d3 | Ruby | glooer/dip | /module/Widgets/PoPaginator.rb | UTF-8 | 2,980 | 2.65625 | 3 | [] | no_license | class PoPaginator < Qt::Widget
slots "_update_index(QString)", "pages_prev()", "pages_next()", "pages_stat()", "test(int)"
signals "currentPageChanged(int)"
def initialize parent = 0, pages_size_select = [30, 50, 100, 500, 1000]
super parent
@layout = Qt::HBoxLayout.new self
self.setLayou... | true |
3cf5d49e92c0bfd1bea46159a52d5f171b1438f4 | Ruby | UsmanJ/codewars | /simple_string_validation.rb | UTF-8 | 845 | 4.09375 | 4 | [] | no_license | # This method accepts a single argument, a string to be validated.
# The string can be of any length and have any contents. But to be considered valid, it must have zero or more blanks followed by zero to eight numeric digits followed by, again, zero or more blanks.
# If it is valid, the number within the string + 1 ... | true |
61db90bb636c0b28dba67019c1d2049c1ca2a657 | Ruby | Arcath/Markabb | /lib/markabb/classes/tag.rb | UTF-8 | 2,560 | 3.296875 | 3 | [] | no_license | module Markabb
# The hash which markabb stores all the avaliable tags in
Tags = {}
# Inserts a tag into Markabb::Tags
#
# Takes 3 inputs:
# name - a symbol which is used as its key
# tag - a Markabb::Tag object
# group - a way to group similar tags so they can all be disabled
... | true |
85ed68b331797afd13e8bf3cf97ef71f9e12e17a | Ruby | tjlee/OpenGenesis | /test-automation/cucumber/lib/genesis_client.rb | UTF-8 | 2,580 | 2.765625 | 3 | [] | no_license | require 'httparty'
require 'yaml'
class GenesisClient
include HTTParty
attr_accessor :auth
def initialize()
config = YAML::load(File.open(File.dirname(__FILE__) + "/../config.yml"))
@host = config["genesis"]["host"]
@port = config["genesis"]["port"]
@auth = {:username => config["genesis"]["user"... | true |
d17ae5896788acf195956c3be1ad152dc7a47215 | Ruby | chaganiu/playwright-ruby-client | /lib/playwright/route_handler_entry.rb | UTF-8 | 633 | 2.890625 | 3 | [
"MIT"
] | permissive | module Playwright
class RouteHandlerEntry
# @param url [String]
# @param base_url [String|nil]
# @param handler [Proc]
def initialize(url, base_url, handler)
@url_value = url
@url_matcher = UrlMatcher.new(url, base_url: base_url)
@handler = handler
end
def handle(route, requ... | true |
a2b1644da9e4e037f2e7ce838d8d8dc1f2ec9779 | Ruby | destinf/t5008_converter | /lib/t5008_converter.rb | UTF-8 | 1,903 | 2.875 | 3 | [] | no_license | require "t5008_converter/version"
require "t5008_converter/row_data"
require "t5008_converter/exchange_rate/exchange_rate_api"
require "csv"
module T5008Converter
class Error < StandardError; end
REQUIRED_INPUT_COLUMNS = [
"quantity",
"closing date",
"currency (original)",
"proceeds of d... | true |
5a6cc30dbc6a25649ce3249f7ee5bd560a3bc799 | Ruby | toasterbob/review | /challenges/ruby/hackerrank/implementation/birthday_choc.rb | UTF-8 | 320 | 3.375 | 3 | [] | no_license | #!/bin/ruby
def getWays(squares, d, m)
total = 0
squares.each_cons(m) do |block|
total += 1 if block.reduce(:+) == d
end
return total
end
n = gets.strip.to_i
s = gets.strip
s = s.split(' ').map(&:to_i)
d,m = gets.strip.split(' ')
d = d.to_i
m = m.to_i
result = getWays(s, d, m)
print(result)
| true |
3b1cff3c4b92b323d7255fbbf2d832292076fbfa | Ruby | cpjolicoeur/rails | /activesupport/lib/active_support/core_ext/object/try.rb | UTF-8 | 2,335 | 3.4375 | 3 | [
"Ruby",
"MIT"
] | permissive | class Object
# Invokes the public method whose name goes as first argument just like
# +public_send+ does, except that if the receiver does not respond to it the
# call returns +nil+ rather than raising an exception.
#
# This method is defined to be able to write
#
# @person.do_or_do_not(:name)
#
# ... | true |
589ba41f92d11ae37cf472086d7799380c2726b2 | Ruby | sekoudosso82/ruby-oo-relationships-practice-blood-oath-exercise-nyc-web-012720 | /app/models/flower.rb | UTF-8 | 932 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Flower
attr_accessor :name, :age, :life_motto
@@all = []
def initialize(name, age, life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def cults
# returns an Array of this follower's cults
BloodOath.all.select do |b... | true |
f2d747f87a414c939d314cddd226fcb5e5cae5bc | Ruby | MaxSechz/appacademy-exercises | /poker/spec/card_spec.rb | UTF-8 | 1,605 | 3.203125 | 3 | [] | no_license | require 'rspec'
require 'card.rb'
describe Card do
subject(:card) { Card.new(:king, :club) }
it "initializes with a suit" do
expect(card.suit).to eq(:club)
end
it "initializes with a face" do
expect(card.face).to eq(:king)
end
describe "#>" do
let(:larger_card) { Card.new(:ace, :heart) }
... | true |
8507bbf30ad9b76ed6cc09564a4004f74b079280 | Ruby | stringham/contests | /2012-mebipenny/contest/biological-entropy/solution.rb | UTF-8 | 1,613 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | KEEP_RESULT = false
def formatter(significant, next_code)
# format with the right number of hex digits for our size
result = format("%0#{significant}x", next_code)
[result, next_code + 1]
end
def compress(line, size)
# initialize
dictionary = {}
sequence = ""
result = ""
length = 0
next_code = 0
... | true |
6f976ba226a474143c28e667fc33e341bf020e1f | Ruby | codesicario/ls-intro-ruby | /exercise_string.dir/string2.rb | UTF-8 | 310 | 3.296875 | 3 | [] | no_license |
words = 'car human elephant airplane'
plural_words = words.split
plural_words.each { |x| puts x + "s"}
#another option
words.split(' ').each do |word|
puts word + 's'
end
colors = 'blue boredom pink yellow orange'
puts colors.include?("yellow")
puts colors.include?("purple")
puts colors.include?("red")
| true |
2bbc9a103fea6bbe16f95a103839129dc9a5dce2 | Ruby | AnaTeresaDona/Ruby-Ejercicios2-2020 | /calculo_notas2.rb | UTF-8 | 409 | 3.46875 | 3 | [] | no_license | data1 = open("notas.data").readlines
data = data1.map{|elemento| elemento.split(",")}
def notas_mas_alta (array)
n_arreglo = []
array.each do |arreglo_interno|
nombres = arreglo_interno[0]
notas = (arreglo_interno[1..arreglo_interno.count].map{|nota| nota.to_i}).max
nombres_y_nota = [nombres,nota... | true |
fdf4c32826fa47a2c576587798adf745e0b2ce70 | Ruby | realestate-com-au/blobby | /lib/blobby/key_constraint.rb | UTF-8 | 723 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
require "uri"
module Blobby
# Defines the keys we allow for use in BLOB-store implementations.
#
# Basically, we allow anything that would be a valid URI "path" component.
#
module KeyConstraint
BAD_PATTERNS = [
%r{\A\Z}, # blank
%r{\A/}, # leading slash
... | true |
83e5d374d7e793ecf7639568c03437493a56ebaa | Ruby | sbfaulkner/byebug | /test/commands/catch_test.rb | UTF-8 | 1,235 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | # frozen_string_literal: true
require "test_helper"
module Byebug
#
# Tests exception catching
#
class CatchTest < TestCase
def test_catch_adds_catchpoints
enter "catch NoMethodError"
debug_code(minimal_program)
assert_equal 1, Byebug.catchpoints.size
end
def test_catch_removes... | true |
cff4f887984c26146f7e80107adbf0084d48eb66 | Ruby | myoan/sudoku | /spec/sudoku/data_validator_spec.rb | UTF-8 | 1,227 | 2.625 | 3 | [
"MIT"
] | permissive | require "rspec"
RSpec.describe Sudoku::DataValidator do
describe ".validate_format!" do
subject { Sudoku::DataValidator.validate_format!(data) }
context "when line size less than 81" do
let(:data) { Array.new(80) { "1" }.join }
it { expect { subject }.to raise_error Exception }
end
cont... | true |
b26934d04be386827823da452889444b49051722 | Ruby | saintaze/Hotel-Checkin | /hotel.rb | UTF-8 | 1,078 | 3.59375 | 4 | [] | no_license |
class Hotel
attr_reader :rooms
def initialize(name = "Transalvania Inn")
@name = name
@rooms = {
"lovelace" => Room.new(2),
"hopper" => Room.new(2),
"turing" => Room.new(1)
}
end
def room_exists?(name)
@rooms.has_key?(name)
end
def check_in(room, guest)
@rooms[ro... | true |
621368d5984ae879a4cb7530c7a799f61d6b9160 | Ruby | Hansen-Nick/RB101 | /101-109_practice_problems/easy_2/greeting.rb | UTF-8 | 188 | 3.640625 | 4 | [] | no_license | print "What is your name? "
name = gets.chomp!
if name.split('').include?("!")
name.gsub!("!", '')
puts "HELLO #{name.upcase}. WHY ARE WE SCREAMING?"
else
puts "Hello #{name}."
end
| true |
c466072bee36789bfb2ca23a6de4ca9545c2fc86 | Ruby | BWStearns/Chess | /Chess_piece.rb | UTF-8 | 3,467 | 3.375 | 3 | [] | no_license | # Assumptions
# => White is on the bottom of the board (high indexes)
# => White moves first
#
# require 'debugger'
class Piece
attr_accessor :board, :pos, :color
BOARD_RANGE = (0..7).to_a
CARDINAL_DELTA = [[0,1], [1,0], [-1,0], [0,-1]]
DIAG_DELTA = [[1,1], [-1,-1], [1,-1], [-1,1]]
COMP_DELTA = CARDINAL_DELTA... | true |
8c1910a4db0c99a73162b66670eb090203b5cadc | Ruby | omahacodeschool/event-attendance | /services/meetup.rb | UTF-8 | 3,815 | 3.484375 | 3 | [] | no_license | # Wrapper for the information about one Meetup event, from the Meetup API.
# This class is the bridge between an event from Meetup and an event in our
# database--handling transformation of data as needed.
class Meetup
# event_info - api result converted to json hash
#
# itializing a meetup event will automa... | true |
3ac334e3ce127642560a173f31f71595290052e7 | Ruby | SupahNickie/WorkingPortfolio | /test/features/project_test.rb | UTF-8 | 2,626 | 2.609375 | 3 | [] | no_license | require "test_helper"
# SAD PATH FOR VISITORS
feature "a project cannot be created by a non-user" do
scenario "a site visitor doesn't see the controls to make a new post" do
# Given that some malicious user goes to my site
# When they try to change anything to my projects listing
visit projects_path
... | true |
53bd66f613418e5353a1061578bbfba53a70b667 | Ruby | Alex-Linhares/bongard_problem_generator | /spec/grid_spec.rb | UTF-8 | 15,865 | 2.765625 | 3 | [] | no_license | # Author:: Max Craigie (@MaxCraigie)
# Copyright:: Copyright (c) 2017 Max Craigie
# License:: Attribution-NonCommercial 3.0 Australia (CC BY-NC 3.0 AU)
require_relative '../grid.rb'
describe Bongard::Grid do
describe '#initialize' do
it 'fails if the cell data does not match the size' do
cells = [[1... | true |
13a23bd73a18970e82ea681dc80c67fc7b5610fd | Ruby | Odin94/RubyCollision | /Rectangle.rb | UTF-8 | 1,659 | 3.296875 | 3 | [] | no_license | class Rectangle
def initialize(x, y, w, h)
@x = x
@y = y
@w = w
@h = h
end
attr_accessor :x, :y, :w, :h
def handle_collisions(collidingRectangles)
for rect in collidingRectangles
resolve_x_collision(rect)
resolve_y_collision(rect)
... | true |
1850a0a4e1d9b7c3a8786ee1acf233b591b6a2d4 | Ruby | bluefish733/learn-and-share | /hello.rb | UTF-8 | 155 | 2.640625 | 3 | [] | no_license | #! /usr/bin/env ruby
def hello
puts 'hello world!'
puts 'test rebase'
puts 'zjl - 1'
puts 'zjll - 2'
puts 'zjl -3'
puts 'zjl -4'
end
hello()
| true |
7866be20a1fb2a55ba8e1597411537077d5fa03b | Ruby | inDuberitably/WrightCSHelpRoom | /bots/Email/EmailRequestForm.rb | UTF-8 | 308 | 2.546875 | 3 | [] | no_license | class EmailRequestForm
class << self
attr_accessor :sender, :email_id, :original_msg, :hours, :completed, :total_hours
def to_s
return "Sender:#{self.sender}\nEmail_id:#{self.email_id}\nOriginal_msg:#{self.original_msg}\nHours:#{self.hours}\nCompleted?:#{self.completed}\n"
end
end
end
| true |
eb7173e65f441849bfa2f7ad5260eecec745010b | Ruby | chendry/LSY201 | /test.rb | UTF-8 | 438 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'serialport'
serial = SerialPort.new("/dev/tty.usbmodem3a21", 38400)
buffer = []
while true
buffer << serial.readbyte
buffer = buffer.last(2)
if buffer == [ 0xFF, 0xD8 ]
while buffer.last(2) != [ 0xFF, 0xD9 ]
buffer << serial.readbyte
end
File.open("test.jpg", "w... | true |
d54e758b41a503b75f3ceff23d7e4c9968470512 | Ruby | bantic/first-word-api | /app/models/poll_item.rb | UTF-8 | 1,075 | 2.671875 | 3 | [] | no_license | class PollItem < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: :slugged
belongs_to :poll
has_one :photo, dependent: :destroy
def self.normalize_word(word)
word.split(' ')[0].downcase.gsub(/[^a-z]+/, '')
end
def add_word word
normalized_word = self.class.normalize_word(word)
... | true |
ba5f41d4f6fb7fd9618e24dbdac4aa52c296f818 | Ruby | Altovate/bearded-octo-adventure | /app/helpers/search_conditions.rb | UTF-8 | 1,537 | 2.65625 | 3 | [] | no_license |
# This class is used to generate search paramaters for offers
class SearchConditions
def initialize()
@wheres = []
@values = []
end
# Parse Key Value pairs and add them to the array
def parse_param_string(params)
# overriden in subclass
end
# Add where/value clauses to the ... | true |
251cf4cc62ce2b9c27f61c223c074f3df6ee21ff | Ruby | arkency/md_pp_string_calculator | /string_calculator_spec.rb | UTF-8 | 879 | 3.09375 | 3 | [] | no_license | require 'rspec'
require './string_calculator'
describe StringCalculator do
let(:calculator) { StringCalculator.new }
specify { expect(calculator). to respond_to(:add) }
specify { expect(calculator.add("")). to eql(0) }
specify { expect(calculator.add("1")). to eql(1) ... | true |
cc68a6ef735160f13db435603084c47528e57ff3 | Ruby | birdcarrie/CacheExercise | /MyHashMap/lib/p02_hashing.rb | UTF-8 | 567 | 3.375 | 3 | [] | no_license | class Fixnum
# Fixnum#hash already implemented for you
end
class Array
def hash
hash_key = self.length * 5717
hash_key = hash_key * self[-1] if self[-1].is_a?(Fixnum)
hash_key = hash_key * self[0].ord if self[0].is_a?(String)
hash_key
end
end
class String
def hash
hash_key = self.length * ... | true |
767e87dd39fd883cde3865ad49db3496ff864890 | Ruby | oliverpdahl/ttt-8-turn-online-web-sp-000 | /lib/turn.rb | UTF-8 | 1,122 | 4.09375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn(board)
puts "Please enter 1-9:"
input = gets.strip
index = input_to_index(input)
if valid_move?(board, index)
display_board(move(board,index))
else
puts "Please enter a valid input"
turn(board)
end
end
def input_to_index(input)
input = input.to_i
return input - 1
end
def display_b... | true |
c9d77b1c5662673f09ea63c5dbf47ae88285f412 | Ruby | ifad/eaco | /lib/eaco/acl.rb | UTF-8 | 5,242 | 3.078125 | 3 | [
"MIT"
] | permissive | module Eaco
##
# An ACL is an Hash whose keys are Designator string representations and
# values are the role symbols defined in the Resource permissions
# configuration.
#
# Example:
#
# authorize Document do
# roles :reader, :editor
# end
#
# @see Actor
# @see Resource
#
class A... | true |
8d0350b8b920b50471366ff83f7b9c19abbbb841 | Ruby | robhurring/bingo | /app/models/move.rb | UTF-8 | 255 | 3.03125 | 3 | [] | no_license | class Move
def initialize(name, word, found = true)
@name, @word, @found = name, word, found
@hash = Digest::MD5.hexdigest(word)
end
def to_h
{
name: @name,
found: @found,
word: @word,
hash: @hash
}
end
end | true |
f3e1398163af1a4877f7e6e4d4e0cac1776b19b9 | Ruby | Harmonickey/EnHabit | /Core/Accounts/update_account.rb | UTF-8 | 3,519 | 2.515625 | 3 | [] | no_license | #!/usr/local/bin/ruby
absPath = Dir.pwd
base = absPath.split("/").index("public_html")
deploymentBase = absPath.split("/")[0..(base + 1)].join("/") #this will reference whatever deployment we're in
$: << "#{deploymentBase}/Libraries"
require 'json'
require 'moped'
require 'bson'
require 'PasswordHash'
re... | true |
83c59dac15464b893bb71af50c3e29d45071386e | Ruby | ErickLedesma/E7CP2A1 | /ejercicio1.rb | UTF-8 | 1,259 | 4.5625 | 5 | [] | no_license | # Dado el array:
# a = [1, 2, 3, 9, 1, 4, 5, 2, 3, 6, 6]
# 1. Utilizando map aumentar el valor de cada elemento del array en 1.
# 2. Utilizando map convertir todos los valores a float.
# 3. Utilizando map convertir todos los valores a string.
# 4. Utilizando reject descartar todos los elementos menores a 5 en el ar... | true |
20267b98f992bde57845cbf116e4dc6bfd19ecf7 | Ruby | pcapr-local/pcapr-local | /lib/mu/pcap/sctp/chunk/data.rb | UTF-8 | 3,206 | 2.78125 | 3 | [
"MIT"
] | permissive | # http://www.mudynamics.com
# http://labs.mudynamics.com
# http://www.pcapr.net
module Mu
class Pcap
class SCTP
class Chunk
class Data < Chunk
FLAG_LAST_SEG = 0x01
FLAG_FIRST_SEG = 0x02
FLAG_UNORDERED = 0x04
attr_accessor :tsn, :sid, :ssn, :ppid
def initialize
super
... | true |
02000bd715467436926036988e5f5792d9128b49 | Ruby | ncoe/rosetta | /Faulhabers_formula/Ruby/faulhaber.rb | UTF-8 | 1,674 | 3.546875 | 4 | [
"MIT"
] | permissive | def binomial(n,k)
if n < 0 or k < 0 or n < k then
return -1
end
if n == 0 or k == 0 then
return 1
end
num = 1
for i in k+1 .. n do
num = num * i
end
denom = 1
for i in 2 .. n-k do
denom = denom * i
end
return num / denom
end
def bernoulli(n... | true |
ef3c86ef48544692906f94cfb786e655d6b98364 | Ruby | JuliaFong/OpenApp | /Ruby/Enumerables/enumerable.rb | UTF-8 | 7,668 | 4.84375 | 5 | [] | no_license | #Enumerable Methods
# In Ruby, an object enumerable is when it describes a set of
# items and a method to loop over each of them
# provides collection classes with several traversal and searching methods
# you can mix into your classes
# Enumerable module provides you with methods for
# searching, traversal, and sorti... | true |
f37b33a7c13025470ca491c1b5b3b07610af8d42 | Ruby | GIL-GALILEO/alma-user-integration-legacy-converter | /lib/classes/user_group.rb | UTF-8 | 2,698 | 2.859375 | 3 | [] | no_license | require './lib/errors/no_group_mapping_error'
# functionality for patron user_group including support for weighting
class UserGroup
attr_accessor :type, :alma_name, :banner_name, :weight, :institution, :exp_days
def initialize(institution, campus, banner_name = nil, fs_codes = nil, class_code = nil)
self.inst... | true |
ac14d7a48f57bb451ce14f18a445ab158247bf3e | Ruby | johnw188/me405 | /binary_hex_converter.rb | UTF-8 | 472 | 2.71875 | 3 | [] | no_license | filename = ARGV[0]
file = File.open(filename){|file| file.readlines}
re='([01]{8})'
binRegex = Regexp.new(re,Regexp::IGNORECASE);
fullRegex = Regexp.new('(0b[01]{8})')
file.each{|line|
if binRegex.match(line)
number = binRegex.match(line)[1].to_i(2).to_s(16)
if number.length == 1
number = "0" +... | true |
76127d18eb7953f655995ec2eb2c375af0763dc7 | Ruby | Malaber/AdventOfCode2020 | /code/14.rb | UTF-8 | 784 | 3.140625 | 3 | [] | no_license | require_relative '../input'
require_relative 'handheld/Instruction'
require_relative 'handheld/Computer'
lines = get_lines $PROGRAM_NAME
@bitmask = ""
mem = {}
def apply_bitmask(value)
new_value = value.dup
@bitmask.split("").each_with_index do |char, index|
next if char == "X"
new_value[index] = char
e... | true |
d2f499bbbdd9d2aebb03fcb5da81ef082dec621d | Ruby | haruharuharuby/iiita | /app/models/article_tagging.rb | UTF-8 | 759 | 2.515625 | 3 | [] | no_license | class ArticleTagging
def initialize(article)
@article = article
end
def register
ActiveRecord::Base.transaction do
@article.save!
update_tags
end
end
def update(article_params)
ActiveRecord::Base.transaction do
@article.update(article_params)
update_tags
end
end... | true |
2771f73ed28055119b298b1ea958b169523f5786 | Ruby | marcolee1107/su-ruby-practice | /examples/ex_203.rb | UTF-8 | 637 | 2.890625 | 3 | [] | no_license | # 當SketchUp遇見Ruby - 邁向程式化建模之路(碁峯出版)
# http://books.gotop.com.tw/v_AEC009100
# ex_203.rb - 分別用不同的方法繪出多邊形
mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
normal = [0, 0, 1]
radius = 2
# 用add_ngon方法指定6個邊線
ent.add_ngon [0, 0, 0], normal, radius, 6
# 用add_circle方法指定6個線段
ent.add_circle... | true |
862cac4060ef0ad3ee0cbc1150ad1b2eea26bc44 | Ruby | jss530/playlister-sinatra-v-000 | /app/models/song.rb | UTF-8 | 353 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
belongs_to :artist
has_many :song_genres #going to access these through the join table
has_many :genres, through: :song_genres #can access genres through song_genres table
def slug
name.downcase.gsub(" ","-")
end
def self.find_by_slug(slug)
# binding.pry
Song.all.find{|s... | true |
3163843fa9b1309540a53f7f773ddd3357ad3e9d | Ruby | 00s/depot | /depot/db/seeds.rb | UTF-8 | 4,446 | 2.9375 | 3 | [] | no_license | # encoding: utf-8
Product.delete_all
Product.create!(title: 'Antologia Front-End',
description:
%{<p>
Esse livro quer ser uma pequena celebração desse sucesso.
Um grupo de 11 autores de renome nacional na comunidade se
juntou para escrever artigos que julgamos relevantes para a Web.
... | true |
3672dad1328f0d50ae3ee7c2f248813cfd6a1b51 | Ruby | DarkWater666/rubywarrior | /rubywarrior.rb | UTF-8 | 2,019 | 3.015625 | 3 | [] | no_license | class Player
attr_accessor :warrior
def initialize()
@max_hp=nil
@current_hp=nil
@prev_hp=nil
@hp_history=[]
@vision=[]
@direction=:forward
@directions=[:forward, :backward]
@reverse_dir=[:backward, :forward]
end
def play_turn(warrior)
@max_hp=warrior.health
self.wa... | true |
f2765b4f3ba1a26ddb4618174a95b462f3ac4be8 | Ruby | projectblacklight/spotlight | /lib/migration/iiif.rb | UTF-8 | 3,728 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
module Migration
# This migrates FeaturedImages with crop coordinates into IIIF urls which
# are stored in the `iiif_url' field.
class IIIF
def self.run(hostname)
new(hostname).run
end
def initialize(hostname)
@hostname = hostname
end
def run
... | true |
3aac0a8448a19d744a6062cf19d00900307bb769 | Ruby | nmgokhale/Ruby-Programming | /src/Introduction to Programming/Array Methods & Enumerables/two_dim_arrays.rb | UTF-8 | 312 | 4.125 | 4 | [] | no_license | # Two dimensional arrays
arr = [
["a", "b", "c"],
["d", "e"],
["f", "g", "h"]
]
print arr #[["a", "b", "c"], ["d", "e"], ["f", "g", "h"]]
puts
puts arr[1][1] # e
puts arr[2][0] # f
puts "----------------"
arr.each do |subArr|
print subArr
puts
subArr.each do |element|
puts element
end
end
| true |
a2a3086b386ca7a23ac981a26c7c8b1d59688f2b | Ruby | johnktravers/project_euler | /problem_10/prime_summation_test.rb | UTF-8 | 601 | 3.359375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
class PrimeSummationTest < Minitest::Test
def prime_summation(max)
max = max - 1 if max.even?
sum = max >= 2 ? 2 : 0
(3..max).step(2) do |num|
prime = true
(2..(num ** 0.5 + 1)).each do |n|
break prime = false if num % n == 0
... | true |
58181ea17adf2045f399fa5127b4076833b7d877 | Ruby | mwagner19446/wdi_work | /w01/d05/INSTRUCTOR/objects.rb | UTF-8 | 1,435 | 4.21875 | 4 | [] | no_license | # Song
# - title
# - artist
# - genre
# - play ("Tommy by The Who is playing.")
# Instantiate a few songs to test your class.
class Song
def title=(title)
@title = title
end
def title()
return @title
end
# def title()
# return "Hamburgers"
# end
def artist=(artist)
@artist = artist
... | true |
989e99c1b38499e6a585f2b27d58a1665c5c97cd | Ruby | d3chapma/daily_bible | /app/models/reference.rb | UTF-8 | 419 | 3.203125 | 3 | [] | no_license | class Reference
def initialize(book_name, chapter, verse)
@book = Book.new(book_name)
@chapter = @book.chapters[chapter.to_i-1]
@verse = verse.to_i
end
def self.parse(ref)
_, book_name, chapter, verse = ref.match(/(.+)\+(\d+):(\d+)/).to_a
new(book_name, chapter, verse)
end
def to_s
"... | true |
eead04a1cf5e21fddb6383a75f4a9ade9a474846 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/house/b5cbdd46e0b14c2a894b6753f56bbed4.rb | UTF-8 | 1,046 | 3.578125 | 4 | [] | no_license | class House
def self.recite
new.recite
end
def recite
result = ""
(1..12).each { |i|
phrase = ""
count = 1
while count <= i
phrase = "#{what_it_is(count)}" + phrase
count += 1
end
phrase = "This is " + phrase
result += phrase
}
result.ch... | true |
b9077c4f79676cb92a0245d5a166088bcd765041 | Ruby | jfernapa/sinatra_roman_numerals | /roman_numerals.rb | UTF-8 | 953 | 3.640625 | 4 | [] | no_license | class RomanNumerals
ONE_ROMAN = "I"
def convert(number)
begin
roman_number = ONE_ROMAN * Integer(number)
equivalences = {'M' => 1000, 'D' => 500, 'C' => 100, 'L' => 50, 'X' => 10, 'V' => 5}
equivalences.each do |letter, number|
roman_number = roman... | true |
d35c0f5ff25b341288c4e714dfc5b633c594aed8 | Ruby | 28221122/mobileautomatization | /features/screens/autorized_whishlist.rb | UTF-8 | 1,001 | 2.65625 | 3 | [] | no_license | class AutorizedWhiwlist
def initialize
@first_item_homescreen = Elements.new(:xpath,'//*[@resource-id="com.view9.foreveryng:id/banner"]')
@items_to_be_liked = Elements.new(:xpath,'//*[@resource-id="com.view9.foreveryng:id/tbLove"]')
@wishlist_check_for_brand = Elements.new(:xpath,'//*[@resource-id="com.v... | true |
aada2440b6535dd1595ba2b35336032dcc694712 | Ruby | annacarey/oo-relationships-practice-nyc-web-111819 | /app/models/Location.rb | UTF-8 | 634 | 3.265625 | 3 | [] | no_license | class Location
attr_reader :name
@@all = []
def initialize(name)
@name = name
self.class.all << self
end
def self.all
@@all
end
def sessions
Session.all.select do |session|
session.location == self
end
end
def trainers... | true |
3cc17904dda0fb30a6929a08badc2e2ceb511044 | Ruby | periode/thesis | /code/render.rb | UTF-8 | 4,424 | 2.84375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'kramdown'
require 'erb'
require 'fileutils'
attention = `git diff --name-only --cached`
attention = attention.split("\n")
unless attention.length
puts "nevermind"
exit
end
puts "time to publicize"
the_only = Time.now # to
remember = "#{the_only.year}-#{the_only.month}-#{the_only.day}-#{... | true |
f852cd437f7b59240838a8ce91e97d8fc5a1e791 | Ruby | jjuarez/jabber_notifier | /lib/jabber_notifier/cli.rb | UTF-8 | 416 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'jabber_notifier/options_parser'
require 'jabber_notifier/connection'
module JabberNotifier
class Cli
def self.run(options)
config = YAML.load_file(options[:config])
connection = Connection.new(:username =>config["username"], :password =>config["password"], :delay =>opt... | true |
7ad402efc4cbc26cdaddb36171d21e1b3f83bfbe | Ruby | BlueMeadow/L3 | /S6/PROJET/Hanjie-master/Generation/Picture.rb | UTF-8 | 2,259 | 3.359375 | 3 | [] | no_license | require 'rmagick'
include Magick
class Magick::Pixel
def isBlack?()
(self.green + self.red + self.blue) / 3 < (QuantumRange / 2)
end
end
class Picture
@origine # Contient l'image original
@indicesH # Groupe d'indices de colonne (array[array])
@indicesV # Groupe d'indices de ligne (array[array])
@prec... | true |
b486346a10cd4ec53db5f1f40c885e8e9c962aa6 | Ruby | b-dalton/04_ruby_tutorial | /strings_arrays_time/time.rb | UTF-8 | 462 | 3.34375 | 3 | [] | no_license | require 'date'
# s = String.new("A man, a plan, a canal—Panama!")
# t = s.split(", ")
# p t
# a = Array.new
# a << 3 << 4
# puts a
# now = Time.now
# puts now
moon_landing = Time.new(1969, 7, 20, 20, 17, 40)
# puts moon_landing.day
# puts now - moon_landing
# DAYNAMES = Date::DAYNAMES
# DAYNAMES = ["Sunday", "Mon... | true |
6e64453d405288e6a5863bca64506cb5cf9d5a20 | Ruby | JimMcL/sampleIt | /lib/view_angle.rb | UTF-8 | 4,169 | 3.40625 | 3 | [
"MIT"
] | permissive | # Class for working with view angles of photos of specimens.
# The angle is specified by latitude (phi) and longitude (lambda). Photos
# are assumed to be directed towards the centre of the specimen, with
# the top of the specimen facing up or else the front of the specimen
# facing towards the left. Longitude (lamba)... | true |
76e73f4aa830046a84748d275fcbeb31df7e4855 | Ruby | johnantoni/plugin.tweakify | /lib/common/active_record.rb | UTF-8 | 339 | 2.578125 | 3 | [
"MIT"
] | permissive | class ActiveRecord::Base
def self.to_a_simplify
# takes table object and breaks it down into a simple array
return self.to_enum.map {|e| e::id }
end
def self.simply_paginate(id)
# converts table into array, then finds prev/next/current & returns as hash
return self.to_a_simplify.simply_paginate_a... | true |
5ba3b8edfc283490351aad1e5899ca4d7b61cc85 | Ruby | JEG2/ender | /test/tc_config.rb | UTF-8 | 864 | 2.71875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -wKU
require "test/unit"
require "tempfile"
require "config"
class TestConfig < Test::Unit::TestCase
def test_config_returns_a_customized_ostruct
assert_instance_of(OpenStruct, config)
end
def test_config_object_is_passed_into_the_file_and_used_to_set_options
c = config(<<-END_SE... | true |
094afe2138299494f6f6b683d8471a870e21360b | Ruby | rayleyva/ArangoDB | /3rdParty/mruby/mrblib/struct.rb | UTF-8 | 854 | 3.46875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | ##
# Struct
#
# ISO 15.2.18
class Struct
##
# Calls the given block for each element of +self+
# and pass the respective element.
#
# ISO 15.2.18.4.4
def each(&block)
self.class.members.each{|field|
block.call(self[field])
}
self
end
##
# Calls the given block for each element of +... | true |
c249e8b59fccbe7b0efd0be155e1daef95a11585 | Ruby | jparbros/leaderboard | /app/models/concerns/input_filters.rb | UTF-8 | 2,821 | 2.53125 | 3 | [] | no_license | module InputFilters
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def search(params)
inputs = self.includes(:user, :departament)
inputs = inputs.by_user(params[:user_id]) if params[:user_id]
inputs = inputs.by_today if params[:period] == 'today'
inputs... | true |
5c18ab4b04705437902dc4b522af2e90632ba8fb | Ruby | szib/oo-relationships-practice-london-web-career-040119 | /app/models/IMDB/Movie.rb | UTF-8 | 132 | 2.5625 | 3 | [] | no_license | require_relative './VisualProduct'
class Movie < VisualProduct
def self.most_actors
all.max_by(&:number_of_actors)
end
end
| true |
145fddeecb88889417783957828b40222f2bd4d3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/2ea7d59f423b4a75b8d2db7c8b796d70.rb | UTF-8 | 774 | 3.953125 | 4 | [] | no_license | #!/usr/bin/env ruby
class Bob
@@responses = {
question: "Sure.",
silence: "Fine. Be that way!",
yelling: "Woah, chill out!",
default: "Whatever."
}
def hey(phrase)
result = :default
case
when silence?(phrase)
result = :silence
... | true |
bd2c4e21ed88d79a8d95472c1c85de159e66813b | Ruby | vgelinski/home_sinatra | /src/model/user.rb | UTF-8 | 687 | 2.796875 | 3 | [] | no_license | require 'data_mapper'
require 'digest/sha1'
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :password, String
property :salt, String
def User.create(params)
params[:salt] = (0..8).map{(33 + rand(92)).chr}.join
plain_pass = params[:password]
params... | true |
41b829cd54c3e872096b4dd560351c1f6d9b1032 | Ruby | Jylia/xyz | /xyz.rb | UTF-8 | 255 | 3.484375 | 3 | [] | no_license | def mult(x,y,z)
if (x < y) ?
if ((y < z) || (x < z)) ?
a = [y, z] : a = [y, x]
end
:
if ((x < z) || (y < z))?
a = [x, z] : a = [y, x]
end
end
return a[0]*a[0] + a[1]*a[1]
end
puts mult(-10, -9 ,-22)
| true |
66f979f8c23ed9f71e0bf491762f564ea05f67e1 | Ruby | alansparrow/learningruby | /benchmarkexample2.rb | UTF-8 | 236 | 2.8125 | 3 | [] | no_license | require 'benchmark'
iterations = 1000000
Benchmark.bmbm do |bmbm|
bmbm.report("for:") do
for i in 1..iterations do
x = i
end
end
bmbm.report("times:") do
iterations.times do |i|
x = i
end
end
end
| true |
71a162184d00779ea2e21462ef19492c3a7aa618 | Ruby | npatel007/Computer-Science-Notes | /Ruby/RubyLect9.progs/RubyLect9.14.progs/closure.rb | UTF-8 | 2,534 | 2.78125 | 3 | [] | no_license | #!/opt/local/bin/ruby2.0 -w
# CLOSURE
# Copyright Mark Keane, All Rights Reserved, 2011
arr1 = ["john", "jim","mary", "james"]
arr2 = ["A", "B","C", "D"]
def assign_marks(people, marks, time1 = 0, procs = [])
people.each do |person|
time2 = 0
marks.each do |mark|
fn = lambda {p [person, mark, time1, time2]}
... | true |
f11a357e083cf04a3f6889b5e77568d3aa3325f5 | Ruby | parrot-studio/rdgc-dm | /lib/rdgc/maker/divide_temp_block.rb | UTF-8 | 7,099 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # coding: UTF-8
module RDGC
module Maker
class DivideTempBlock < TempBlock
attr_accessor :divide_direction
attr_writer :depth, :min_size
def depth
@depth ||= 0
@depth
end
def min_size
@min_size = Util::Config.min_block_size if @min_size.to_i <... | true |
803967a84198386138106048acacbd1a99502042 | Ruby | SuhaylTFaris/XASJS | /XAS Tool HUD 0.1.rb | UTF-8 | 23,885 | 2.6875 | 3 | [] | no_license | #==============================================================================
# ■ +++ MOG - XAS TOOL HUD (v1.0) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com
#=======================================================================... | true |
f4b5535ff352b373fab7bd6135e6899b11a5f696 | Ruby | yumidev/memory | /game.rb | UTF-8 | 572 | 3.453125 | 3 | [] | no_license | require_relative 'board'
class Game
def initialize
@board = Board.new
@previous_guess
end
def play
@board.populate
while !@board.won?
@board.render
guessed_pos = gets.chomp.to_i
@board.reveal(guessed_pos)
make_guess(guessed_pos)
end
end
def make_guess(pos)
if... | true |
70b9d8386b8cfb199ab330fec129246d54e0d353 | Ruby | jesusmaldonado/primes | /lib/primes/prime_parser.rb | UTF-8 | 359 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative 'prime_table'
require_relative 'prime_generator'
module Primes
class PrimeParser
def initialize(opts = {})
@prime_generator = Primes::PrimeGenerator.new(opts)
@prime_table = Primes::PrimeTable.new()
end
def print
@prime_table.primes = @prime_generator.primes
@pri... | true |
b72bf55a7f445da02360fe482b6e204d707d78c2 | Ruby | nonsensery/ar_validation_sample | /test/models/post_test.rb | UTF-8 | 1,938 | 2.875 | 3 | [] | no_license | require 'test_helper'
class PostTest < ActiveSupport::TestCase
test 'duplicate tag is detected when added to new post' do
tag = Tag.first
# Create a new post:
post = Post.new
# Add a tag:
post.post_tags.new tag: tag
# Post should be valid
assert post.valid?
# Add a duplicate tag:
... | true |
c069811d01e1b47eaed9320fe07c84bf342d4c6c | Ruby | DavidMcKenzie218/Week_1_Homework | /Day_2/functions_practice_lab/ruby_functions_practice.rb | UTF-8 | 1,879 | 3.5625 | 4 | [] | no_license | def return_10()
return 10
end
def add(number1, number2)
result = number1 + number2
return result
end
def subtract(number1, number2)
result = number1 - number2
return result
end
def multiply(number1, number2)
result = number1 * number2
return result
end
def divide(number1, number2)
result = number1/n... | true |
fc00a59c5bce5b15c32aaa1dbe92fc331bebb4ad | Ruby | nkirkus/testing | /Game/testloop.rb | UTF-8 | 99 | 3 | 3 | [] | no_license | i = -99
puts "Before : " + i.to_s
(1..10).each{|i| print 1; puts " haha"}
puts "After : " + i.to_s
| true |
551367efc3da1488541449746a16d92ee11ba24b | Ruby | mezbahalam/script_quote_city | /run.rb | UTF-8 | 1,312 | 2.640625 | 3 | [] | no_license | ### Health Leads Lead Type — > 114 input fields https://leads.usacoverage.com/pingPostSpec.php?TYPE=6
# require 'nokogiri'
# file = File.open('ping.html')
# html = Nokogiri::HTML(file)
# data = html.css("a+ .hilite .left:nth-child(3)")
# #xpath("//a+//*[contains(concat( ' ', @class, ' ' ), concat( ' ', 'hilite', ' ... | true |
0be33067f6434e405c634ecfea3125a89fc6f56b | Ruby | salomekbg/prime-ruby-001-prework-web | /prime.rb | UTF-8 | 286 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
numbers = (2...num).to_a
check = false
numbers.each do |item|
if num < 2
check = false
elsif num == 2
check = true
elsif num % item != 0
check = true
elsif num % item == 0
check = false
break
end
end
check
end
| true |
8def2db9abea87b94b693b9dcb90bf26c0865b8e | Ruby | kennym/saas-class | /hw1/cartesian_product.rb | UTF-8 | 229 | 3.515625 | 4 | [] | no_license | class CartesianProduct
include Enumerable
attr_accessor :xs, :ys
def initialize(lhs, rhs)
@xs, @ys = lhs, rhs
end
def each
@xs.each do |x|
@ys.each do |y|
yield x, y
end
end
end
end
| true |
5559f9c6a99d2a2963b74267697b08f00a8dcb12 | Ruby | ShinyVerse/anagram-app | /spec/feature/app_spec.rb | UTF-8 | 1,037 | 2.796875 | 3 | [] | no_license | require 'app'
require 'anagram'
describe 'Feature' do
let(:app) { App.new(Anagram.new) }
before(:each) do
app.parse_user_input("era cat rat are pear ear")
end
context 'found anagrams' do
it 'prints expected positive output' do
allow(STDIN).to receive(:gets).and_return("tac\n", "exit\n")
exp... | true |
63a4e6ebc06ad3c7637b29f90c161244cdb122cf | Ruby | mcwaller422/Intro_to_Ruby | /Arrays/Mutate.rb | UTF-8 | 180 | 3.75 | 4 | [] | no_license | a = [1,2,3,4,5,6]
def mutate(arr)
arr.pop
end
def not_mutate(arr)
arr.select{|i| i >3}
end
a = [1,2,3,4,5,6]
mutate(a)
puts a
a = [1,2,3,4,5,6]
not_mutate(a)
puts a
| true |
ae72def25a8499bb36f655c78c42ecb8881853c3 | Ruby | robopro/2019-06-14-Cookbook-day-1 | /controller.rb | UTF-8 | 825 | 3.078125 | 3 | [] | no_license | require_relative 'view'
class Controller
def initialize(cookbook)
@cookbook = cookbook
@view = View.new
end
def list
# first get all recipes from cookbook
recipes = @cookbook.all
# send data to view
@view.display(recipes)
end
def create
# add a new recipe:
# ask user for nam... | true |
7dcdfc4cbfe1f04524604c3f6474c938cc004deb | Ruby | rimuhosting/fog | /lib/fog/model.rb | UTF-8 | 1,971 | 2.75 | 3 | [
"MIT"
] | permissive | module Fog
class Model
def self.attribute(name, other_names = [])
class_eval <<-EOS, __FILE__, __LINE__
attr_accessor :#{name}
EOS
@attributes ||= []
@attributes |= [name]
for other_name in [*other_names]
aliases[other_name] = name
end
end
def self.ide... | true |
22a205d2e20118269cad67337cfc3832f979697d | Ruby | cesartalves/ruby_metaprogramming_as_spec | /spec/callables/blocks_spec.rb | UTF-8 | 1,392 | 3.359375 | 3 | [] | no_license | require 'spec_helper'
describe "Ruby Blocks" do
def method_using_block_implicitly
yield
end
def method_using_block_explicity(&block)
block.call
end
it "they will run the code which is passed to the method" do
expect(method_using_block_implicitly { 5 }).to eq 5
end
... | true |
7e3c8b4fd45faabb5021633ee46caa44c3a50580 | Ruby | adambeynon/opal | /lib/opal/nodes/if.rb | UTF-8 | 1,619 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'opal/nodes/base'
module Opal
module Nodes
class IfNode < Base
handle :if
children :test, :true_body, :false_body
RUBY_ENGINE_CHECK = [:call, [:const, :RUBY_ENGINE],
:==, [:arglist, [:str, "opal"]]]
RUBY_PLATFORM_CHECK = [:call, [:const, :RUBY_PLAT... | true |
7c504d0ae57cc77fa63d4b1d70373c7a87e9c3f3 | Ruby | Tim-Feng/learn-to-program | /ch12-2.rb | UTF-8 | 177 | 3.25 | 3 | [] | no_license | puts "Please enter the year you born:"
born_y = gets.chomp
puts "Please enter the month you born:"
born_m = gets.chomp
puts "Please enter the date you born:"
born_y = gets.chomp | true |
bf00e71275725e61820bbf02d6ffb4dc65ba0a66 | Ruby | hawthornehaus/astronom-web | /app/models/nutrient_loss.rb | UTF-8 | 2,298 | 2.53125 | 3 | [
"MIT"
] | permissive | class NutrientLoss
include Enumerable
delegate :[], :each,
:to => :loss_table
attr_reader :from, :to, :gender, :duration_in_seconds, :significance
def initialize(from: , to: , gender: , significance: 6)
@gender = gender # currently unused
@from = from.to_time
@to = to.to_time
... | true |
7e833c69b16cc89afe8f1795e77dac67d4365856 | Ruby | zauzaj/prime_number_list | /lib/concern/prime_number_generator.rb | UTF-8 | 451 | 3.390625 | 3 | [] | no_license | require 'pry-rails'
module PrimeNumberGenerator
def generate starting_value, ending_value
primes_list = []
input_order_changing(starting_value, ending_value).to_a.each do |value|
primes_list << value if isPrime(value)
end
primes_list
end
def isPrime argument
(2..(argument/2)).to_a.all? {|div| argume... | true |
ce3568e273896e8872369bb4a204231114444382 | Ruby | chiensiTB/OpenStudio-server-orig | /gems/gems/dencity-0.1.0/lib/dencity/client/structure.rb | UTF-8 | 4,497 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | module Dencity
# Structure methods
class Structure
include Request
attr_accessor :analysis_id
attr_accessor :user_defined_id
attr_accessor :structure
attr_accessor :measure_instances
# initialize
def initialize(analysis_id = nil, user_defined_id = nil, path = nil, connection)
@an... | true |
e5bddb0675f89233850d478eb4e152d095de422f | Ruby | ak061295/Radlibs | /mad_libs.rb | UTF-8 | 488 | 2.53125 | 3 | [] | no_license | require 'sinatra'
get '/' do
erb :form
end
get '/upload' do
erb :upload
end
get '/story' do
erb :story
end
post '/' do
@name = "#{params[:post][:first_name]} #{params[:post][:last_name]}"
@fname = "#{params[:post][:first_name]}"
@lname = "#{params[:post][:last_name]}"
if @name == "Brennan Kinney"
... | true |
81d57a9e7ea135b60ab5cb48984c6f4c380b1804 | Ruby | h11z/ruby-oo-relationships-practice-blood-oath-exercise-chi01-seng-ft-080320 | /app/models/Followers.rb | UTF-8 | 841 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Follower
attr_accessor
attr_reader :name, :age, :life_motto
@@all = []
def self.all
@@all
end
def initialize(name,age,life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def cults
cults_im_in = BloodOat... | true |
b856ed8910a721ee6cea960c5bf55657908a348d | Ruby | realgam3/ysoserial.rb | /lib/ysoserial/gadgets.rb | UTF-8 | 637 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | require 'pathname'
module YSoSerial
module Gadgets
def self.load
pattern = File.join(Pathname(__FILE__).dirname, "gadgets", "*.rb")
Dir.glob(pattern).each do |path|
Kernel.load(path)
end
end
def self.table
gadgets = {}
self.load
YSoSerial::Gadget... | true |
7ac9e5ac4bc5ac300000ad92e631310e8fce7800 | Ruby | ministryofjustice/offender-management-allocation-manager | /lib/working_day_calculator.rb | UTF-8 | 369 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'bank_holidays'
require 'business_time'
class WorkingDayCalculator
def initialize(holidays = BankHolidays.dates)
BusinessTime::Config.holidays = Set.new(holidays)
end
def working_days_between(date1, date2)
date1.business_days_until(date2)
end
def self.working_days_between(date1, date2)
... | true |
5c092562fb4b50d6fdd4415bbb5ed6257b8d2069 | Ruby | danielevans/gutenberg_text_search_compiler | /parse.rb | UTF-8 | 7,245 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'stemmify'
require 'fileutils'
require 'shellwords'
require 'json'
require 'benchmark'
require 'pp'
require 'pry'
require 'optionparser'
require 'set'
require 'progressbar'
STOP_WORDS = [ # ripped off from https://github.com/brez/stopwords/blob/master/lib/stopwords.rb
'a','cannot','into','... | true |
be653cd5e01d9bf7faeae459adedf0f05a71e694 | Ruby | Steimel/Thomas | /lib/thomas/canvas.rb | UTF-8 | 910 | 3.0625 | 3 | [
"MIT"
] | permissive | module Thomas
class Canvas
attr_reader :width, :height, :things
def initialize(width, height)
@width = width
@height = height
@things = []
end
def drawable_things
@things.select{|thing| thing.drawable}
end
def place_thing(thing, r, c)
thing.set_position(r,c)
... | true |
7191bae7995ed1457716218e7d945de263d3e8c2 | Ruby | soutaro/querly | /lib/querly/pattern/kind.rb | UTF-8 | 1,603 | 2.734375 | 3 | [
"MIT"
] | permissive | module Querly
module Pattern
module Kind
class Base
attr_reader :expr
def initialize(expr:)
@expr = expr
end
end
module Negatable
attr_reader :negated
def initialize(expr:, negated:)
@negated = negated
super(expr: expr)
... | true |
75136031563b97cec3cbbc1ec40018eee9b8ca04 | Ruby | splashinn/Warmups | /main.rb | UTF-8 | 1,268 | 3.84375 | 4 | [] | no_license | # Load in all the shakespeare and remove newline characters
def load_shakespeare
File.read(File.dirname(__FILE__) + '/Shakespeare.txt').delete("\n")
end
shakespeare = load_shakespeare()
# ********************
# REGEX DRILLS
# Use regular expressions to answer the following questions:
# How many words does Shakesp... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.