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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cca23d292596613ab772f2c221c7405afe92ba79 | Ruby | bobthecow/forematter | /lib/forematter/commands/list.rb | UTF-8 | 565 | 2.6875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
usage 'list <field> <file> [<file>...]'
aliases :ls
summary 'list values for a field'
description <<-EOS
List the values for a given frontmatter field in a set of files.
EOS
module Forematter::Commands
class List < Forematter::CommandRunner
include Forematter::Arguments::FieldFil... | true |
afc38d5c2ee1092182abb7de69dcbc97ccefb3ac | Ruby | danielng09/simple_cli_search | /db/seeds.rb | UTF-8 | 472 | 2.578125 | 3 | [] | no_license | require 'json'
class_names = [ "organization", "user", "ticket" ]
class_names.each do |class_name|
require_relative "../app/models/#{class_name}"
file = File.read("assets/#{class_name + "s"}.json")
instances_data = JSON.parse(file)
instances_data.each do |instance_data|
instance = eval(class_name.capita... | true |
9a460d35f0e6404fb79fdaaf8ffc263307ae569a | Ruby | south37/gmsc | /lib/gmsc.rb | UTF-8 | 456 | 2.734375 | 3 | [
"MIT"
] | permissive | require "base64"
require "gmsc/version"
module GMSC
class << self
# @param [{ String => String }] metadata
# @return [{ String => String }]
def safe_convert(metadata)
h = {}
metadata.each do |k, v|
if k.match?(/-bin$/)
# If the value is binary, encode with Base64
h... | true |
96cc1eed29dab3368504245f8d23d215a62ee859 | Ruby | liangcarrie20/phase-0-tracks | /databases/8-5-challenge/reading_log.rb | UTF-8 | 6,132 | 3.609375 | 4 | [] | no_license | # READING LOG PROGRAM
# Program that allows users to enter books read during each month.
# User can add books read for multiple months.
# Three tables with one-to-many relationship: months, books, rating. month_id FOREGIN KEY for books and rating.
# User can remove month, remove book, remove rating, print books read f... | true |
968b2ff922984e1805a7b18281873381120cd8ed | Ruby | mjonx/Ironhack | /Week-1/Day-4/login.rb | UTF-8 | 625 | 3.703125 | 4 | [] | no_license | class Login
def initialize(user,password)
@users = {
:user => "albz",
:password => "letmein!"
}
@user = user
@password = password
end
def validate_login
return true if @user = @users[:user] && @password == @users[:password]
end
end
class AI
def self.powerful_algorithm
puts ... | true |
a0d790fa6f34861a11ed3a2d4578f2c0e48e0990 | Ruby | jasbur/rcrawl | /lib/rcrawl/crawler.rb | UTF-8 | 4,093 | 2.84375 | 3 | [
"MIT"
] | permissive | module Rcrawl
class Crawler
attr_accessor :links_to_visit, :site, :user_agent
attr_reader :visited_links, :external_links, :raw_html, :rules, :sites,
:errors, :meta
# Initializes various variables when a new Crawler object is instantiated
def initialize(site)
puts "Rcrawl Version #{VERSION} initia... | true |
94767e0e48cdabb0f4769812dc5c67572ca3f3ed | Ruby | gitter-badger/vedeu | /lib/vedeu/api/api.rb | UTF-8 | 10,504 | 2.8125 | 3 | [
"MIT"
] | permissive | module Vedeu
# Provides the API to Vedeu. Methods therein, and classes belonging to this
# module expose Vedeu's core functionality.
#
# @api public
module API
extend Forwardable
def_delegators Keymap, :keys
# Configure Vedeu using a simple configuration DSL.
#
# @param block [Proc]
... | true |
5a6b46f9cdf3558647e33cc879a2529e07c04239 | Ruby | reggie-c/vivixx-1 | /lessons/sampleprocess.rb | UTF-8 | 657 | 2.953125 | 3 | [] | no_license | $Trans_List = [
{ num: '1', tname: 'Balance Inquiry'},
{ num: '2', tname: 'Withdrawal'},
{ num: '3', tname: 'Transfer'},
{ num: '4', tname: 'Payment'}
]
def startcreen
puts '='*80
puts " "
puts "START SCREEN".center(80, " ")
puts " "
puts '='*80
end
def enterpin
puts "INSERT CARD AND ENTER YOUR ... | true |
7b6f2e45183d857e5b7e89075a23754cc4272cc0 | Ruby | stveep/bioruby-plates | /spec/plate_spec.rb | UTF-8 | 1,824 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'fakefs/spec_helpers'
describe BioPlates::Plate do
context "accessing wells by row and column" do
before(:all) do
p96 = BioPlates.read(File.join(File.dirname(__FILE__),"fixtures","4x96.csv"))
@plate = p96["Plate1"]
end
... | true |
27c44334fe505fd01866ad31f21e67bede1d6d29 | Ruby | al-nattahnam/ma-zmq | /lib/ma-zmq/connection_handler.rb | UTF-8 | 1,964 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module MaZMQ
class ConnectionHandler < EM::Connection
def initialize(socket_handler)
@socket_handler = socket_handler
@socket_type = socket_handler.socket_type
@on_read_lambda = lambda {|m|}
@on_write_lambda = lambda {|m|}
@on_timeout_lambda = lambda {}
end
def on_read(bloc... | true |
387d476b15184977c48624626bd6b40ecde64298 | Ruby | hthieu576/timesheet_entry | /app/models/timesheet.rb | UTF-8 | 878 | 2.640625 | 3 | [] | no_license | # == Schema Information
#
# Table name: timesheets
#
# id :bigint not null, primary key
# user_id :bigint not null
# date :date not null
# start_time :time not null
# finish_time :time not null
# created_at :datetime not null
# ... | true |
1613c5854a16a0578de1a00f801cae7681da9a74 | Ruby | zarakay/comp2310_ass1_marker | /mark.rb | UTF-8 | 2,230 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
BASE_FOLDER = './base'
SUBMISSIONS_FOLDER = './submissions'
MODE_FOLDER = './modes'
TMP_FOLDER = './tmp'
if ARGV.length == 0 || ARGV[0] == "help"
puts "Usage: mark.rb [uid [a|b|c|d|e] | help ]"
puts
puts "\t a: Single_Globe_In_Orbit"
puts "\t b: Dual_Globes_In_Orbit"
puts "\t c: Dual_Gl... | true |
6ac5ae9489a8a18facf8f505db16ae199b97028d | Ruby | gulnara/algo_practice | /binary_search_tree/validate_bst.rb | UTF-8 | 883 | 3.90625 | 4 | [] | no_license | class BST
attr_accessor :value, :left, :right
def initialize(value)
@value = value
@left = nil
@right = nil
end
end
# O(n) T | O(d) S
def validate_bst(tree)
return validate_bst_helper(tree, - 1.0 / 0, 1.0 / 0)
end
def validate_bst_helper(tree, min_value, max_value)
if tree.nil?
return tr... | true |
5ea9b72e3953ca28cd58c1663d8bf3fcd9d036ff | Ruby | renatodex/exploria-poc | /app/models/modifier.rb | UTF-8 | 317 | 2.953125 | 3 | [] | no_license | class Modifier
def self.calculate(value)
bonus = {
1 => -1,
2 => -1,
3 => 0,
4 => 0,
5 => 1,
6 => 1,
7 => 2,
8 => 2,
9 => 3,
10 => 3,
11 => 4,
12 => 4,
13 => 5,
14 => 5,
15 => 6,
16 => 6
}
((BigDecimal(value)/BigDecimal(2)).ceil - BigDecimal(2)).to_i
end
end | true |
a6837ba51bac8055b2ae8d8187beb3bd0910590f | Ruby | Esseh/Misc | /University-Assignments/Computer Organization and Design/16BitALU.rb | UTF-8 | 6,902 | 3.453125 | 3 | [
"MIT"
] | permissive | #=======================================================================
# Simulation for 16Bit ALU and 16Bit Multiplier
# By Kenneth Willeford
# This simulation imitates the two titled modules by copying them
# structurally. This program handles the structuring with more of a
# functional approach than object orient... | true |
3634a210d2e11421e48c870192c21bb0a5e98f5b | Ruby | ROCHAAL/secret_diary | /spec/secret_diary_spec.rb | UTF-8 | 672 | 2.78125 | 3 | [] | no_license | require 'secret_diary'
describe ' SecretDiary' do
it ' shows that the diary is locked' do
diary = SecretDiary.new
expect(diary.lock).to eq(true)
end
it 'shows that the diary is locked' do
diary = SecretDiary.new
expect(diary.unlock).to eq(false)
end
it ' adds an entry in the diary' do
diary = SecretDiary.... | true |
f208a822ea5a38cabd0a299d14c3210bfb58c469 | Ruby | andyw8/fig-leaf | /lib/fig_leaf.rb | UTF-8 | 2,896 | 3.25 | 3 | [
"MIT"
] | permissive | # Tools for making inherited interfaces private to a class.
module FigLeaf
module Macros
private
# Given a list of classes, modules, strings, and symbols, compile
# a combined list of methods. Classes and modules will be queried
# for their instance methods; strings and symbols will be treated
# a... | true |
a5a62dd3f5c29abd1cead04c6eb18e080021116b | Ruby | annakiuber/isbn5 | /isbn_csv.rb | UTF-8 | 338 | 3.109375 | 3 | [] | no_license | require 'csv'
def csv_open(isbn_array)
CSV.open('isbn_file.csv', 'wb') do |csv|
# csv << ["ISBN", "Status"]
isbn_array.each do |isbn|
# p isbn
csv << isbn
end
end
end
# csv_open([["1234567890", "Invalid"],["54326", "Invalid"]])
p CSV.read("isbn_file.csv")
# csv_open("1234567890", "Invalid")
# csv_open("... | true |
ea129a36bfe67f558a4df0686c7291a2c9f526fd | Ruby | saghourkhalil/vendredi | /exo_12.rb | UTF-8 | 110 | 3.5 | 4 | [] | no_license | puts "choisi un nombre"
print "> "
number = gets.chomp.to_i
number.times do
puts number
number += 1
end | true |
0c01ba90bfe325098ddc9a0a0b4455b04e9609ec | Ruby | annakiuber/minedmindskata | /teamwork_app.rb | UTF-8 | 616 | 3.9375 | 4 | [] | no_license | # array = []
#start by buliding array
def anna_3_5
annas_counter = 0 #variable used inside the function
a = (1..100).to_a #building array of a hundred elements
while annas_counter < 100
annas_counter += 1
if annas_counter % 3 == 0 && annas_counter % 5 == 0 #way to do both 3 and 5 together(15 a factor of both)
... | true |
2d4a8f3138fe2521ca465e9a315fffd821513273 | Ruby | cam-ron-90/food-delivery-d2-master | /app/models/meal.rb | UTF-8 | 728 | 3.09375 | 3 | [] | no_license | class Meal
# need to be able to read and write all when we edit
attr_accessor :id, :price, :name
# Meal.new({})
def initialize(attributes = {})
# Set initial instance
@id = attributes[:id]
@name = attributes[:name]
@price = attributes[:price]
end
# This CLASS METHOD (note the self.csv_head... | true |
fd54d74224f787cb67db82c66a79ba4bf9653c8b | Ruby | zachjamesgreen/rails-engine | /spec/requests/merchant/merchants_spec.rb | UTF-8 | 1,404 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'Merchants API' do
before(:all) do
create_list(:merchant, 150)
end
def get_merchants(page: 1, per_page: 20)
get '/api/v1/merchants', params: { page: page, per_page: per_page }
expect(response).to be_successful
expect(response.content_type).to eq 'application... | true |
8d1a990a2f77802ddd10f98e7e544eaaf0a5d335 | Ruby | Ejguzman3988/regex-lab-onl01-seng-ft-052620 | /lib/regex_lab.rb | UTF-8 | 589 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
require 'pry'
def starts_with_a_vowel?(word)
!word.match(/\b[aeiouAEIOU]/).nil?
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/un\w*ing/)
end
def words_five_letters_long(text)
text.scan(/\b(\S...\S)\b/).flatten
end
def first_word_capitalized_and_ends_with_punctuation?(text)
t... | true |
3465f7c5c61d82880de748ca2c771e4373a93c2e | Ruby | ben-harvey/Small-problems-Ruby | /more topics/easy2/1.rb | UTF-8 | 132 | 3.265625 | 3 | [] | no_license | def step(start, stop, step)
start.step(by: step, to: stop) {|n| yield n}
end
p step(1, 10, 3) { |value| puts "value = #{value}" } | true |
5ff2f38dc22d05a9bdc1c27e7a197fae59c2360b | Ruby | fx/polymer | /lib/polymer/source.rb | UTF-8 | 1,287 | 3.015625 | 3 | [
"BSD-3-Clause"
] | permissive | module Polymer
# Represents a single source file used in a sprite.
#
class Source
# @return [String] The sprite name; the filename sans-extension.
attr_reader :name
# @return [Pathname] The path to the source file on disk.
attr_reader :path
# Creates a new Source instance.
#
# @para... | true |
f4289aab3150a0809f64391bcc00f4cbf8c363ba | Ruby | Jayashree3699/Active-Record-Ruby | /todo.rb | UTF-8 | 1,759 | 3.15625 | 3 | [] | no_license | require 'active_record'
class Todo < ActiveRecord::Base
def due_today?
due_date == Date.today
end
def to_displayable_string
display_status = completed ? "[X]" : "[ ]"
display_date = due_today? ? nil : due_date
"#{id} #{display_status} #{todo_text} #{displ... | true |
993c91c4fc03cdf71b0e2e0c6ab1b9988c2ed9b9 | Ruby | LuqiPan/The-Odin-Project | /Ruby/Learn-to-Program/alter_loop.rb | UTF-8 | 164 | 3.203125 | 3 | [] | no_license | command = ''
while command != 'bye'
#now it will never echo a blank line
if command != ''
puts command
end
command = gets.chomp
end
puts 'Come again soon!'
| true |
bae9dd94f5c564924b4aa0c39e947d651b3a2578 | Ruby | mimizotti/black_thursday | /lib/customer_repository.rb | UTF-8 | 965 | 2.921875 | 3 | [] | no_license | require_relative 'customer'
class CustomerRepository
attr_reader :repository
def initialize(data, sales_engine = nil)
@sales_engine = sales_engine
@repository = {}
load_csv_file(data)
end
def load_csv_file(data)
CSV.foreach(data, :headers => true, :header_converters => :symbol) do |row|
... | true |
ec5984285345e8e2301dee33adf6593dce69d759 | Ruby | Michael-Xie/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 3,285 | 2.625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
# validation examples here
it "should be created with password and password_confirmation fields" do
user = User.new({ password: "testing", password_confirmation: "testing" , first_name: "first", last_name: "last", ema... | true |
726bf5185050da0ff8121a1bbe8a7dfe7ec67eac | Ruby | melodycodes/exercism_ruby | /sum-of-multiples/sum_of_multiples.rb | UTF-8 | 626 | 3.484375 | 3 | [] | no_license | class SumOfMultiples
def initialize(*n)
@factors = n
end
def self.to(max, *factors)
factors = (factors.empty? ? [3, 5] : factors.flatten)
sum_multiples(factors, max)
end
def to(max)
self.class.to(max, @factors)
end
private
def self.sum_multiples(factors_arr, max)
factors_arr.inje... | true |
91fceb1c92ee0d59f4c19965085e41810ddd91c2 | Ruby | stephennimako/fbl-predictions | /features/step_definitions/fixture_steps.rb | UTF-8 | 1,556 | 2.625 | 3 | [] | no_license | require 'fbl/helpers/fixtures'
Given(/^There is a fixture involving (none|one|two) of the selected teams in the (current|next) round of fixtures$/) do |number_of_selected_teams, round|
kick_off = round == 'current' ? Date.today.next_day.strftime('%Y-%m-%d 15:00:00') : Date.today.next_day(3).strftime('%Y-%m-%d 15:00:... | true |
677fadb63711ff4ce48dad7029ddaff4a837d7c8 | Ruby | network-chess/chess-backend | /app/controllers/games_controller.rb | UTF-8 | 3,932 | 3.015625 | 3 | [
"Zlib"
] | permissive | class GamesController < ApplicationController
# Display an index of all open games
def index
@games = Game.all
@running_games = []
@open_games = []
# Only include the open games in the array
for item in @games
if item.p2 == nil
@open_games << item
else
@running_game... | true |
859542b055fe9f8c888ba6ec025be747b4e3e03b | Ruby | ARERA-it/del_342_2016_data_analysis | /lib/del_342_2016_data_analysis/sheet_row.rb | UTF-8 | 393 | 2.59375 | 3 | [
"MIT"
] | permissive | module Del3422016DataAnalysis
class SheetRow
include ValidateValues
def join(sep)
to_a.join(sep)
end
def parse_date(date)
if date=~/\d\d-\d\d-\d\d/
mdy = date.split("-")
Date.parse("20#{mdy[2]}-#{mdy[0]}-#{mdy[1]}")
elsif date=~/\w\w\w-\d\d/
Date.parse("01-#... | true |
bccda6a4d1f4f8a0beb0e7e0b5c79dccc41b7a00 | Ruby | freebz/Beginning-Ruby | /ch12/ex12-16.rb | UTF-8 | 343 | 2.796875 | 3 | [] | no_license | # The response_to Method
# Accepting Input and Performing Substitutions
def response_to(input)
end
def response_to(input)
prepared_input = preprocess(input).downcase
end
private
def preprocess(input)
perform_substitutions input
end
def perform_substitutions(input)
@data[:presubs].each { |s| input.gsub!(s[0... | true |
f9f23c591fd5413dad0507b34feb5bcebc022973 | Ruby | peachykeen5/ar-exercises | /exercises/exercise_4.rb | UTF-8 | 695 | 2.9375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
puts "Exercise 4"
puts "----------"
surrey = Store.create(name: "Surrey", annual_revenue: 224000, mens_apparel:false, womens_apparel:true)
whistler = Store.create(name: "Whistler", annual_revenu... | true |
1a487495d9ae6c447faa6fd2734c4388eb97cb4c | Ruby | vinmaster/fuzzycd.rb | /lib/fuzzycd/command.rb | UTF-8 | 806 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'optparse'
require 'tty'
module Fuzzycd
module Command
extend self
CMD = TTY::Command.new(printer: :null)
def run(command, options = {})
output, err = CMD.run(command, options)
raise err unless err.empty?
output
end
def pwd
run('pwd').delete!("\n")
end
d... | true |
fa872cadffbdc0bbb6716652d7b0b43a51ff9ad6 | Ruby | pskarlas/FridgeJam | /app/models/concerns/recipe_import_helper.rb | UTF-8 | 1,535 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
# Helper methods for importing recipes
module RecipeImportHelper
def calculate_ttl_cook_time(string)
return if string.strip.nil? || string.strip.blank?
arr = extract_time_from(string)
ttl_mins_from_days = arr[0] * 1440
ttl_mins_from_hours = arr[1] * 60
ttl_mins ... | true |
1bc59b3bdc3afd7b20fdc0f9ca3188085bcef675 | Ruby | dvkry/robot | /lib/robot.rb | UTF-8 | 2,604 | 3.546875 | 4 | [] | no_license | class Robot
attr_accessor :position
attr_accessor :items
attr_accessor :health
attr_accessor :equipped_weapon
attr_accessor :shields
@@robot_list = []
def initialize
@position = [0, 0]
@items = []
@health = 100
@shields = 50
@@robot_list << self
end
def list
@@robot_list.len... | true |
15db993f7356c3a3651f72d3b1e8013f348d049e | Ruby | zenaton/zenaton-ruby | /lib/zenaton/refinements/date.rb | UTF-8 | 468 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'date'
module Zenaton
# :nodoc
module Refinements
refine Date do
# Convert to a simple hash
def to_zenaton
{
'y' => year,
'm' => month,
'd' => day,
'sg' => start
}
end
end
end
end
# Reimpleme... | true |
43a8e8f775f9747bbbd4ee655688f43fcdf17681 | Ruby | DonutWorks/Ari | /app/services/authenticates/user_session.rb | UTF-8 | 374 | 2.515625 | 3 | [] | no_license | module Authenticates
class UserSession < UserStorage
UserStorage::KEYS.each do |key|
# session getter
define_method("#{key.to_s}") do
@session[key]
end
# session setter
define_method("#{key.to_s}=") do |value|
@session[key] = value
end
end
def initiali... | true |
bcd772cdd49b460abce732ab12ea9cbbffad616c | Ruby | ncalibey/Launch_School | /exercises/101-109_small_problems/easy_08/easy_809.rb | UTF-8 | 636 | 4.40625 | 4 | [] | no_license | # easy_809.rb - Convert number to reversed array of digits
def reversed_number(num)
num.to_s.reverse.to_i
end
p reversed_number(12345) == 54321
p reversed_number(12213) == 31221
p reversed_number(456) == 654
p reversed_number(12000) == 21 # Note that zeros get dropped!
p reversed_number(1) == 1
=begin
u... | true |
de4c4a377909c1484a0ad1d00c0c681e1b716343 | Ruby | aseroff/ruby-marc | /bin/marc | UTF-8 | 161 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'marc'
# the filename
filename = ARGV[0]
reader = MARC::ForgivingReader.new(filename)
for record in reader
puts record
end
| true |
d5e6042f28f191d594e23397b7696f52a42401d7 | Ruby | jasnow/medlink | /app/services/sms/assistant.rb | UTF-8 | 1,333 | 2.671875 | 3 | [
"MIT"
] | permissive | class SMS::Assistant < SMS::Handler
def run! error
key = "recent-errors:#{sms.phone_id}:last-error"
last, times, at = stats_for key
if last == error.class.name && at > 5.minutes.ago
add_count key
if times == 0
%|Sorry, but I'm just a robot, and I don't know what you're saying. You can... | true |
62b2b86fe589b88ebf1f440784f493d5eec75b5b | Ruby | Finale100/cartoon-collections-dc-web-062518 | /cartoon_collections.rb | UTF-8 | 519 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)
dwarves.each_with_index{|cartoon, index| puts "#{index +1}." "#{cartoon}"}
end
def summon_captain_planet(array)
array.collect do |items|
items.capitalize << "!"
end
end
def long_planeteer_calls(calls)
calls.map do |items|
if calls.size > 4
return true
elsif ... | true |
836943471cc830f0bf757e23e9abaccce17ce96a | Ruby | nanamin135/edit | /app/controllers/articles_controller.rb | UTF-8 | 2,036 | 2.546875 | 3 | [] | no_license | class ArticlesController < ApplicationController
#only onryと書かないように
before_action :set_article ,only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
#@articles = Article.all
@articles = current_user.articles
end
def show
end
def new... | true |
0e39669472b10cd9044888d01c6783ba3826c3ad | Ruby | gina-alaska/shiplog-parser | /lib/shiplogs/parser/old_weather.rb | UTF-8 | 1,356 | 2.609375 | 3 | [
"MIT"
] | permissive | module Shiplogs
module Parser
class OldWeather
def initialize(file)
@filename = file
@pages = []
end
def data_field(type, content)
Shiplogs::OldWeather::DataFields.send(type, content)
end
def json_content
@json_content ||= JSON.parse(File.read(@filen... | true |
4ea99b9e97005eb435a39fa8d464874062f5f04f | Ruby | mqshaikh8/ruby-boating-school-dumbo-web-111819 | /app/models/instructor.rb | UTF-8 | 746 | 2.984375 | 3 | [] | no_license | class Instructor
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def pass_student(student,name,status = name.status)
if name.instance_of? BoatingTest
@answer = name
@ans... | true |
039fa1c66216f11f805015360e2aa27dcbc24ed6 | Ruby | JimmehWong/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 645 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
badge_messages = []
attendees.each do |attendees|
badge_messages.push(badge_maker(attendees))
end
badge_messages
end
def assign_rooms(attendees)
room_assignments = []
attendees.each_with... | true |
d523ad7c26fd13164cfb05c6034613b4bb4110fa | Ruby | CBrammar/ruby-challenges | /blog.rb | UTF-8 | 1,593 | 3.296875 | 3 | [] | no_license | class Blogpost
@@total_blogposts = 0
def initialize
@@total_blogposts +=1
@timestamp = Time.now
@blog_id = @@total_blogposts
end
def self.current_count
puts "There are currently #{@@total_blogposts} blogposts"
end
def set_title=(blog_title)
@title = blog_title
end
def get_title
return @title
e... | true |
4b45d761d2c5260fd18294a6e09e6c742fe63501 | Ruby | ehoffmanncsa/eric_test | /test/ted/sort_and_filter_activity_page_test.rb | UTF-8 | 3,284 | 2.625 | 3 | [] | no_license | # encoding: utf-8
require_relative '../test_helper'
# TS-561: TED Regression
# UI Test: Verify activity page sort and filter functionality
=begin
This test uses coach Eric of the Bears organization.
We navigate to the activity page, and we want to make sure a coach can filter
their athletes by team and sort the... | true |
e2d61112368c566b64416c6c33a0f5780729e0b4 | Ruby | zeuslocker/hancer | /app/services/alerts_view_handler.rb | UTF-8 | 362 | 2.546875 | 3 | [] | no_license | class AlertsViewHandler
attr_reader :result
class << self
def call(result)
new(result).perform
end
end
def initialize(result)
@result = result
end
def perform
setup_alerts!
end
def setup_alerts!
result['contract.default'].errors.full_messages.inject('') do |acc, elem|
... | true |
d180c240262ca93c5ab71e7cdc0a6e7361ef68a1 | Ruby | Saoki11111/nlp100rb | /ruby/08.rb | UTF-8 | 827 | 4.5 | 4 | [] | no_license | # 与えられた文字列の各文字を,以下の仕様で変換する関数cipherを実装せよ.
#
# 英小文字ならば(219 - 文字コード)の文字に置換
# その他の文字はそのまま出力
# この関数を用い,英語のメッセージを暗号化・復号化せよ.
def cipher(str)
map = str.chars.map do |c|
# [:lower:] POSIX 文字クラス 小文字
# String#ord -> Integer 最初の文字の文字コードを整数で返す
# Integer#chr 与えられた Integer を 文字コードと見たとき、それに対する1文字を返す(ord n逆)
/[[:low... | true |
5acaf8228f61451aba6fcd6bfcec29e5b116f109 | Ruby | esrp/ruby | /lib/esrp/group.rb | UTF-8 | 10,213 | 3 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'esrp/value'
module ESRP
##
# Class: SRP Group Parameters
#
# Provides:
# N - A large safe prime (N = 2q+1, where q is prime)
# g - A generator modulo N
# prime_length - for debugging
#
# The predefined prime groups are taken from https://tools.ietf.org/html/rfc5... | true |
f3cadf5c69146b61e642fb7121b433b305418fa6 | Ruby | tobiaso88/dotfiles | /bin/wh | UTF-8 | 1,052 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby -w
# encoding: UTF-8
##!/usr/bin/env ruby -w
## encoding: UTF-8
require 'net/http'
require 'net/https'
require 'uri'
require 'json'
unless ARGV[0]
puts "Ingen sökning angiven"
exit
end
uri = URI('http://exaktahosting.am-tryck.lan/old_account/search?q=' + "#{ARGV[0]}")
Net::HTTP.start(uri... | true |
7ddf6ee5db229186f93d9f5d9db67e568d4734f8 | Ruby | ruby-processing/learning-processing-with-ruby | /chapter_14/16_simple_solar_system.rb | UTF-8 | 989 | 2.859375 | 3 | [] | no_license | attr_reader :theta
def setup
size 200, 200
smooth 4
@theta = 0 # Angle of rotation around sun and planets
end
def draw
background 15, 15, 25
stroke 0
# Translate to center of window to draw the sun.
translate width/2, height/2
fill 255, 200, 50
ellipse 0, 0, 20, 20
# The earth rotates around th... | true |
5d262b098945078e6bef745c78328883c0fa4f6c | Ruby | andrelugomes/data-structures-and-algorithms | /ruby/spec/data-structures/dynamic_array_spec.rb | UTF-8 | 1,065 | 3.28125 | 3 | [] | no_license | require 'rspec'
require 'data-structures/dynamic_array'
describe DynamicArray do
it 'should set new data into dynamic array' do
array = DynamicArray.new(1)
array.set(0,'Hello, world!')
expect(array.size).to eq 1
expect(array.get(0)).to eq 'Hello, world!'
end
it 'should insert into array' do
... | true |
69dba80f52d08ecb65161b26c200683cadc18935 | Ruby | jeff-hykin/SimpleStack | /Server/boilerplate/compile_files.rb | UTF-8 | 13,896 | 2.890625 | 3 | [
"MIT"
] | permissive | #
# helper tools
#
require 'pathname'
require 'FileUtils'
require 'filewatcher'
# create a bash process that receives std input from doing -"echo hello"
require 'open3'
$std_in, $std_out_and_error, $thread_ = Open3.popen2e('bash;')
class String
# make -"" strings be shell comma... | true |
f60716d8c3bff345f2c5da1d38bcf868ffbef648 | Ruby | ycm-core/lsp-examples | /ruby/test/test.rb | UTF-8 | 756 | 4.1875 | 4 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | class Badger
attr_accessor :name, :size # Creates getter and setter methods.
def initialize(name, size)
@name = name
@size = size
end
# Instance method
def name_backwards
@name.reverse
@name.
end
#
def self.
end
# Create the new instance.
badger = Badger.new('Charles', 12... | true |
be07b4d2c8a1ba2422aed4b37da59461e4bf7e6d | Ruby | Sid-ah/hk-bc | /ruby-drill-the-self-keyword-challenge/spec/area_calculator_spec.rb | UTF-8 | 862 | 3.0625 | 3 | [] | no_license | require_relative '../area_calculator'
describe AreaCalculator do
it 'calculates the area of a rectangle' do
width = 2
length = 3
expected_rectangle_area = 6 # width * length
calculated_rectangle_area = AreaCalculator.area_of_rectangle(width, length)
expect(calculated_rectangle_area).to eq expe... | true |
9890d6ded4371f1d9112ae1d2bea5c6c139296a8 | Ruby | Gembirdy/Ruby_exercises | /rubyRush/lesson11_classes/step45_Homeleon/homeleon.rb | UTF-8 | 331 | 3.546875 | 4 | [] | no_license | class Homeleon
def initialize
@color = 'green'
puts "i'm #{@color}"
end
def changeColor(color)
@color = color
puts "now i'm #{@color}"
end
end
homeleon = Homeleon.new
homeleon.changeColor('red')
homeleon.changeColor('blue')
homeleon.changeColor('gay')
homeleon.changeCol... | true |
348a8feb1da5f21c5b41c6b1011aa33445c3c11a | Ruby | Himuravidal/CP19C01 | /Ejercicio04.rb | UTF-8 | 508 | 3.484375 | 3 | [] | no_license | module Semana
@@primer_dia = 'Lunes'
def self.primer_dia
@@primer_dia
end
def self.en_un_meses
"Un mes tiene 4 semanas."
end
def self.en_un_año
"Un año tiene 52 semanas."
end
end
puts "La semana comienza el día #{Semana.primer_dia}"
puts Semana.en_un_meses
puts Semana.en_un_año
# puts "La semana comienza el d... | true |
b19c8667e2d2717958446f9e53f1cddcf61834b4 | Ruby | vtg/goodsv4_app | /spec/models/good_spec.rb | UTF-8 | 674 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe Good do
before do
@good = Good.new(name: "Example", price: "123")
end
subject { @good }
it { should respond_to(:name) }
it { should respond_to(:price) }
it { should be_valid }
describe "when name is not present" do
before do
@good = Good.new(name: " ", pric... | true |
e75f18769a0f10a0461ee4b36ec9cd95c959d9d9 | Ruby | rejmama1/SemestralProject | /SemestralProject/lib/dynamic/dynamic_algorithm.rb | UTF-8 | 1,896 | 3.359375 | 3 | [] | no_license | require 'lib/problem/writable_result'
# Solves knapsack problem using dynamic programming algorithm - precounting prices
class DynamicAlgorithm
include WritableResult
attr_reader :time,:best_fitness,:best_configuration
#Initializes algorithm
#1/ Creates table maxWeight+1 x amount of items
#2/ Initializes t... | true |
d094a5ca4c048317163494a38048ce75a14d7c38 | Ruby | mame/all-ruby-bot | /all-ruby-bot.rb | UTF-8 | 7,391 | 2.515625 | 3 | [] | no_license | require "sinatra/base"
require "shellwords"
require "tempfile"
require "timeout"
require "net/http"
require "logger"
SLACK_API_TOKEN = ENV["ALL_RUBY_BOT_SLACK_API_TOKEN"]
SLACK_APP_SECRET_KEY = ENV["ALL_RUBY_BOT_SLACK_APP_SECRET_KEY"]
EMOJI = ENV.fetch("ALL_RUBY_BOT_EMOJI", "thumbsup")
ENABLE_MASTER = ENV["ALL_RUBY_EN... | true |
23bd37d783e9261b1d32ff0ffebaabc289b2ea85 | Ruby | Elffers/advent_of_code | /2017/ruby/day02.rb | UTF-8 | 535 | 3.34375 | 3 | [] | no_license | def checksum rows
rows.map do |row|
yield row
end.reduce(:+)
end
def process input
input.map do |row|
row.split("\t").map { |x| x.strip.to_i }
end
end
max_diff = Proc.new do |row|
row.max - row.min
end
find_pair = Proc.new do |row|
res = row.combination(2).select do |combo|
combo.max % combo.... | true |
7a4eb1673008cf125ea355e3be502c32c75bbd49 | Ruby | cjmcd123/lab_01 | /ruby_functions_practice.rb | UTF-8 | 1,704 | 3.796875 | 4 | [] | no_license | def return_10
result = 10
end
def add (num1, num2)
return num1 + num2
end
def subtract (num1, num2)
return num1 - num2
end
def multiply(num1, num2)
return num1 * num2
end
def divide(num1, num2)
return num1 / num2
end
def length_of_string(test_string)
return test_string.length
end
def join_string(strin... | true |
f175ed4b2f461676ec5f63df6bc7a607279e7a17 | Ruby | KjarrigansGames/harvest-ruby | /lib/harvest-ruby/ui.rb | UTF-8 | 1,986 | 2.71875 | 3 | [
"MIT"
] | permissive | module HarvestRuby
class Cursor < Struct.new :img
def initialize(*args)
super
@current = img.first
end
def animate
@current = img.push(img.shift).first
end
def draw(x,y)
@current.draw_rot(x,y,100,0)
end
end
class HUD < Struct.new :x, :y, :width, :img, :mode, :coi... | true |
b6354355f50619b5de05dcc485adb2c35b8b554c | Ruby | DLadendorfer/RubyLeetCodeSolutions | /Problems/0003_Length_of_Longest_Substring.rb | UTF-8 | 809 | 4.125 | 4 | [] | no_license | =begin
Given a string, find the length of the longest substring without repeating characters.
Example 1:
Input: "abcabcbb"
Output: 3
Explanation: The answer is "abc", with the length of 3.
Example 2:
Input: "bbbbb"
Output: 1
Explanation: The answer is "b", with the length of 1.
Example 3:
Input: "pwwkew"
Output: ... | true |
2dd900f430027fb2391b9011b666c2802b5938cb | Ruby | azuaraj/automata | /lib/automata/algorithm.rb | UTF-8 | 2,016 | 3.03125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Automata
class Algorithm
attr_accessor :seed, :generations, :current_arrangement_state, :iteration_number
def initialize(seed, generations)
@seed = seed
@generations = generations
@current_arrangement_state = nil
@iteration_number = 0
end
... | true |
21de3b391fe5c3df5d527932d140aee248beb091 | Ruby | kathf/jukebox | /song.rb | UTF-8 | 1,071 | 3.109375 | 3 | [] | no_license | class Song < Database
attr_reader :id, :filename, :title, :artist, :played
def initialize(hash)
@id = hash['id']
@filename = hash['filename']
@title = hash['title']
@artist = hash['artist']
@played = hash['played']
end
def self.all
res = self.connection.exec("SELECT * FROM songs ORDER... | true |
68104d4d176abe0a8b55b4f8a5450abde44f5d31 | Ruby | atomanyih/tracker | /lib/tracker_git_hook/cli.rb | UTF-8 | 1,648 | 2.953125 | 3 | [] | no_license | module TrackerGitHook
class Cli
def initialize(repo:)
@repo = repo
end
attr_reader :repo
def process_arguments(*args)
argument = args[0]
if argument
process_argument(argument)
else
puts repo.current_story_id
end
end
private
def process_arg... | true |
d243384d74fffdc492f7744e46f312985d0ee0a0 | Ruby | rsudre/halog | /lib/halog/application.rb | UTF-8 | 6,056 | 2.609375 | 3 | [
"ISC"
] | permissive | require 'optparse'
require 'ostruct'
require 'halog'
require 'date'
require 'time'
require 'net/smtp'
module HALog
class Application
attr_reader :options
def initialize(argv = [])
argv ||= []
@options = default_options
@parsed_options = ::OpenStruct.new
@parser = opt... | true |
837046e5735882dc3d7822000540fa777b3a29c0 | Ruby | achhetr/default_ruby_project_configuration | /spec/order_spec.rb | UTF-8 | 1,279 | 3.046875 | 3 | [] | no_license | require "order"
describe Order do
let(:customer_order_input) { "10 Watermelons\n14 Pineapples\n13 Rockmelons" }
it "returns an empty list of line items for a nil order" do
order = described_class.new
expect(order.line_items).to be_empty
end
it "returns an empty list of line items for a blank order" d... | true |
be30d67463890cc2f319d4f6c6f3a39b9a65c92a | Ruby | dfloriani/ruby_exercises | /Section_2/Variables.rb | UTF-8 | 147 | 3.34375 | 3 | [] | no_license | name = "Dayane"
last_name = "Floriani"
alive = true
age = 28 + 1
puts name + " " + last_name
puts alive
puts age
age = "Twenty-nine"
puts age
| true |
b118fd39e46869fc92d3dc7248d9ddd42ae7c1b9 | Ruby | YingCGooi/big-o-algorithmic-problems | /stacks_queues/stack.rb | UTF-8 | 861 | 3.875 | 4 | [] | no_license | require_relative "node_module"
# []
# [A ->] push(A) - size 1
# [B -> A ->] push(B) - size 2
# [A ->] pop - size 1
# [] pop - size 0
class Stack
attr_reader :size
def initialize
@head = nil
@size = 0
end
def push(val)
@head = Node.new(val, @head)
@size += 1
val
end
def pop
poppe... | true |
3ba4879e9fda572a326f2df8f1cdf4f9bc08fdf5 | Ruby | jillmd501/Jungle-Beats | /lib/fileio.rb | UTF-8 | 262 | 2.828125 | 3 | [] | no_license | require_relative 'jungle_beat'
class File_io
attr_accessor :input
def initialize(input)
@input = File.open(ARGV[0]).read
end
def play_beats
player = LinkedList.new(@input)
player.play
end
end
file = File_io.new(ARGV[0])
file.play_beats
| true |
d95fe6da290879127378ee73f61671575586672f | Ruby | michaelatbreathehr/bank_tech_test | /spec/account_spec.rb | UTF-8 | 938 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require 'account'
describe Account do
it 'Has a balance of 0 on creation' do
expect(subject.balance).to eq(0.00)
end
it 'Has new balance after deposit' do
subject.deposit(50, DateTime.now)
expect(subject.balance).to eq(50.00)
end
it 'Has new balance after withdraw'... | true |
9fd7f88c9e64b369151996af01f9633506c4fb2b | Ruby | ooyala/termite | /termite_gem/lib/termite/syslog_logger.rb | UTF-8 | 1,822 | 2.53125 | 3 | [
"MIT"
] | permissive | require "syslog"
module Termite
class SyslogLogger
def initialize(socket, server_addr, server_port, transport)
@socket, @server_addr, @server_port, @transport = socket, server_addr, server_port, transport
end
def send_message(severity, full_message, app_data, time=Time.now, data='{}')
tid = ... | true |
694166ce277fa7726dc0378265806428735556f7 | Ruby | EricRicketts/LaunchSchool | /Ruby/ProgrammingFoundations/lesson_3_practice_problems/prior_work/lesson_3_exercises/hard_one/question_five.rb | UTF-8 | 905 | 2.90625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
class QuestionFive < Minitest::Test
def setup
def is_an_ip_number?(word)
(0..255).include?(word.to_i)
end
def dot_separated_ip_address?(input_string)
dot_separated_words = input_string.split(".")
dot_separated_words.size == 4 &&
... | true |
1f1e9dcd25365b0a3f216ddd5c8209bec5324c8f | Ruby | cernanb/game-reviews-cli | /lib/games_review/scraper.rb | UTF-8 | 597 | 2.59375 | 3 | [
"MIT"
] | permissive | class GamesReview::Scraper
BASE_URL = "http://www.ign.com/reviews/games"
def self.scrape_games
doc = Nokogiri::HTML(open(BASE_URL))
doc.css('.itemList-item')[0..9].each do |game_doc|
title = game_doc.css('.item-title a').text.strip
url = game_doc.css('.item-title a').attribute('href').... | true |
1c8ff594e3ffb9dedde76fa6022486114169f386 | Ruby | tomcoakes/rps-multiplayer | /app/controllers/multiplayer_controller.rb | UTF-8 | 1,739 | 2.78125 | 3 | [] | no_license | class RPS < Sinatra::Base
enable :sessions
post '/multiplayer_game' do
name = params[:name]
if name.empty?
erb :multiplayer_index
else
@player = Player.new(name)
GAME.players.empty? ? session[:player_one] = @player : session[:player_two] = @player
GAME.add_player(@player)
... | true |
d4bf454afee1700dc68946539329e4a79efbe750 | Ruby | tinoun/exercices | /traderdimanche.rb | UTF-8 | 428 | 3.28125 | 3 | [] | no_license | def trader_du_dimanche (array)
buy_day = 0
sell_day = 0
profit = 0
array.each_with_index do | price, place|
for place2 in (place+1)...(array.size) do
if (array[place2] - price) >= profit
profit = array[place2] - price
buy_day = place
sell_day = place2
else
next
... | true |
be2112725badd69ef36647f180c5ec6f87018087 | Ruby | 256hz/collections_practice_vol_2-seattle-web-career-031119 | /collections_practice.rb | UTF-8 | 1,626 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def begins_with_r(tools)
they_r_all_r = true
counter = 0
tools.each do |tool|
if tool.start_with?('r') == false
they_r_all_r = false
end
end
they_r_all_r
end
def contain_a(string)
a_list = []
string.each do |word|
a_list << word if word.downcase.include?('a') == true
end
a_list
end
... | true |
834d34f259dda74378768876e56ec6bff471990c | Ruby | Titusad/Ruby-Excercises | /elefantes.rb | UTF-8 | 419 | 3.359375 | 3 | [] | no_license | elefantes = 1
texto1 = ' elefante se balanceaba, sobre la tela de una arana,\n
como la tela no se movia, fueron a llamar otro elefante'
texto2 = ' elefantes se balanceaban, sobre la tela de una arana,\n
como la tela no se movia, fueron a llamar otro elefante'
while elefantes < 100
if elefantes == 1
puts... | true |
b833b7844af66520f602ccf8b0477d82be921368 | Ruby | gibs2014/rxngif_homework | /db/seeds.rb | UTF-8 | 641 | 2.8125 | 3 | [] | no_license |
Picture.destroy_all
pictures = [
{ source: "http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png", caption: "HTML5 Logo" },
{ source: "http://upload.wikimedia.org/wikipedia/commons/f/f1/Ruby_logo.png", caption: "Ruby logo" },
{ source: "http://upload.wikimedia.org/wikipedia/commons/1/16/Ruby_on_Rails-logo.p... | true |
4173ab2e15c48c62f055ad4fe92c41902dba0f6c | Ruby | eltercero/saru | /lib/saru/list/kanji_related.rb | UTF-8 | 651 | 2.609375 | 3 | [
"MIT"
] | permissive | module Saru
class List
module KanjiRelated
def important_reading_is reading
kunyomi = kunyomi_is(reading).items
onyomi = onyomi_is(reading).items
Saru::List.new kunyomi+onyomi
end
def onyomi_is onyomi
selected = items.select do |item|
item.is_a?(Saru... | true |
926224ddb95d52c3857139b0a9cdebe6547b577b | Ruby | EOSullivanBerlin/ruby-kickstart | /chap01/ex07.rb | UTF-8 | 517 | 4.125 | 4 | [
"MIT"
] | permissive | # given a string, return the character after every letter "r"
#
# pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya"
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string)
# split("r")
# print out 2 position of each string - the first wo... | true |
526909de2f08a4a7ce0ac109d53caba344fef8f6 | Ruby | mikesmall/programming-fundamentals-collections-iteration | /exercises.rb | UTF-8 | 6,851 | 3.828125 | 4 | [] | no_license | # EXERCISE 0
# Arrays
fave_colours_strings = ["red", "green", "blue"]
family_ages = [70, 61, 38, 36, 33]
coin_flips = ["heads", "heads", "tails", "tails", "tails"]
fave_artists = ["Spinal Tap", "Anvil", "Orion"]
fave_colours_symbols = [:red, :green, :blue]
# Hashes
words = {
:paper => "flattened skinny wood pulp",
... | true |
35020aa657fbde49c50bdf691f204e85aafbee23 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/a886566a60af4cfab788a7796ee1f379.rb | UTF-8 | 480 | 3.765625 | 4 | [] | no_license | class Anagram
def initialize(word_to_watch)
@word_to_match = word_to_watch
@anagram_score = word_score(@word_to_match)
end
def match(possible_matches)
possible_matches.select { |word| anagram_of?(word) }
end
private
def anagram_of?(word)
!same_as_anagram(word) && ( word_score(word) == @ana... | true |
ae73e422c6d4e3aa6fd5d56aa37c34e95999bdcd | Ruby | MRudolph/battlebays | /app/helpers/pages_helper.rb | UTF-8 | 2,054 | 2.75 | 3 | [
"MIT"
] | permissive | =begin
module TileTableProcessor
def self.fill tt,page,user=current_user
left,right,top,bottom=tt.left,tt.right,tt.top,tt.bottom
(left..right).each do |x|
(top..bottom).each do |y|
if tt[x,y].nil?
t=page.tiles.new({:x=>x,:y=>y})
tt[x,y]= t.can_be_created?(user)
t.destroy
end
end... | true |
3055b9cd0c9f30a88df5e0c92ab72075f0ebbba3 | Ruby | magiknono/longestword | /app/controllers/pages_controller.rb | UTF-8 | 1,563 | 2.796875 | 3 | [] | no_license | class PagesController < ApplicationController
require 'open-uri'
require 'json'
def game
@grid = generate_grid(9).join(" ")
end
def score
attempt = params[:attempt]
start_time = Time.parse(params[:start_time])
@grid = params[:grid]
end_time = Time.now
@result = run_game(attempt, @grid, s... | true |
aa9d418e0263f3516ce46112e95840210aee1036 | Ruby | nuclearsandwich/fancy | /boot/rbx-compiler/compiler/ast/assign.rb | UTF-8 | 1,383 | 3.03125 | 3 | [
"BSD-3-Clause"
] | permissive | class Fancy
class AST
class Assignment < Node
def initialize(line, ident, value)
super(line)
@ident = ident
@value = value
end
def bytecode(g)
if @ident.constant?
Rubinius::AST::ConstantAssignment.new(line, @ident.name, @value).bytecode(g)
elsi... | true |
6881db38ccf656839f9638e520f933d807229ac0 | Ruby | dagonyclark/reverse-each-word-prework | /reverse_each_word.rb | UTF-8 | 405 | 3.875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def reverse_each_word(string)
array = []
array = string.split(" ")
counter = 0
# array.each do |word|
# # binding.pry
# array[counter] = (word.reverse)
# counter += 1
# end
array.collect do |word|
array[counter] = (word.reverse)
counter += 1
... | true |
a65a058af9464624da7735a3d943d002c01fa442 | Ruby | ayushbhatt29/Mock_rspec | /instance_double_spec.rb | UTF-8 | 762 | 3.21875 | 3 | [] | no_license | class Person
def a
sleep(3)
'hello'
end
end
RSpec.describe Person do
describe 'regular double' do
it 'can implement any method' do
person=double(a:'hello',b: 20)
expect(person.a).to eq('hello')
expect(person.b).to eq(20)
end
end
describe "instance dou... | true |
e117c564263a9a4da53759ae37243e3efcf3bb4a | Ruby | richpeck/serifina-naturals | /app/models/shape.rb | UTF-8 | 1,780 | 2.625 | 3 | [] | no_license | ############################################
############################################
## _____ _ ##
## / ___| | ##
## \ `--.| |__ __ _ _ __ ___ ___ ##
## `--. \ '_ \ / _` | '_ \ / _ \/ __| ##
## /\__/ / | | | (_| | |_) | __/\__ \ ##
## ... | true |
2515313a79c011f64ed4778c9b4dcf10e75f13eb | Ruby | brettCole/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 515 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)# code an argument here
dwarves.each_with_index do |names, index|
puts "#{index + 1} #{names}"
end
end
def summon_captain_planet(planeteer_calls)# code an argument here
planeteer_calls.map { |calls| calls.capitalize + "!" }
end
def long_planeteer_calls(calls)
calls.count > 4 ... | true |
80faf4094486a140076362d2addea16618b06f19 | Ruby | CacheFactory/RailsCodingChallenge | /lib/vertex.rb | UTF-8 | 1,113 | 3.625 | 4 | [
"MIT"
] | permissive | require 'cuboid'
# G == ORIGIN
# e-------f
# /| /|
# / | / |
# a--|----b |
# | g----|--h
# | / | /
# c-------d
# y -
# z |
# x /
class Vertex
attr_accessor :x, :y, :z, :point_position
def initialize(x, y, z, point_position = nil)
@x = x
@y = y
@z = z
... | true |
5e9592d299fc1ba8063abeaa4e1f52c3c4ea8abb | Ruby | conwqi1/DailyCodeAppAcademy | /w1d1/w1d1.rb | UTF-8 | 6,269 | 3.953125 | 4 | [
"MIT"
] | permissive | class Array
def my_uniq
for i in 0...self.length
for j in (i + 1)...self.length
puts self.length
if self[i] == self[j]
self.delete_at(j)
end
end
end
self
end
def two_sum
good_pairs = []
for i in 0...self.length
for j in (i + 1)...self.length... | true |
a3a6e7d478ac9840e328ad87fce5dbfaa89944c1 | Ruby | hmesander/perilous_journey | /perilous_journey/lib/wagontrain.rb | UTF-8 | 265 | 2.828125 | 3 | [] | no_license | require_relative 'linkedlist'
require_relative 'node'
class WagonTrain
attr_reader :list
def initialize
@list = LinkedList.new
end
def append(data, supplies=nil)
@list.append(data, supplies=nil)
end
def count
@list.list_count
end
end
| true |
5555a35093c65c71a231b22a1307c1c4e8fd288e | Ruby | SCPR/kpcc-audio-aggregator | /app/importers/kpcc_program_importer.rb | UTF-8 | 2,353 | 2.625 | 3 | [] | no_license | module KpccProgramImporter
NPR_SOURCE = "NPR"
class << self
def sync_all_things_considered
program_hash = KpccApiHelper::Episodes.all_things_considered
added = []
program_hash['episodes'].each do |episode|
episode['segments'].reject { |s|
AudioStory.exists?(source: NPR_... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.