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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8120d706b1eb52f17b9de0ee9ddec339f5746179 | Ruby | donnacamos/instance-methods-lab-ruby-online-web-sp-000 | /lib/dog.rb | UTF-8 | 190 | 3.6875 | 4 | [] | no_license | class Dog # class method defines an object Dog
def bark # instance method defines bark and puts out a "Woof!"
puts "Woof!"
end
def sit
puts "The Dog is sitting"
end
end
| true |
059d4f787ba240c4a49defbae652f4cf839c6424 | Ruby | JoshCheek/project-euler | /101.rb | UTF-8 | 559 | 3.0625 | 3 | [] | no_license | # https://projecteuler.net/problem=101
require 'matrix'
f = -> n { n**3 }
f = -> n { 1 - n + n**2 - n**3 + n**4 - n**5 + n**6 - n**7 + n**8 - n**9 + n**10 }
1.step.lazy.map do |k|
powers, values = [], []
1.upto k do |y|
powers << k.pred.downto(0).map { |x| y**x }
values << [f[y]]
end
coefficients = Mat... | true |
8777c397ebaae7408a91356fd7b3dbf2b36e783b | Ruby | masanorifunaki/ruby_study | /17_file_class/pathname.rb | UTF-8 | 99 | 2.53125 | 3 | [] | no_license | require "pathname"
path = Pathname.new("/tmp/foo/bar/baz")
p path.exist?
path.mkpath
p path.exist?
| true |
3ac646ff5f01bb281b203ec00bbe45a03faddcbc | Ruby | washu/Holosim | /lib/model/ability.rb | UTF-8 | 909 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Holosim
module Model
=begin
TODO needs fleshed out
=end
class Ability
def initialize(name)
@range = 10
@cooldown = 0
@effect = []
@duration = 1
@channeled = false
@interruptable = false
@phases = []
@name = name
end
def rang... | true |
85070b2c9df85cef312a6178b6d9a2cd6a05e9f6 | Ruby | thebravoman/software_engineering_2014 | /class004/Tihomir_Lidanski_Class4_2.rb | UTF-8 | 566 | 2.875 | 3 | [] | no_license | hash = Hash.new{|name, tasks| name[tasks] = Array.new}
Folder=ARGV[0]
Dir.glob("#{Folder}**/*.*") do |file|
firstName = file.split("/").last.split("_").first
lastName = file.split("/").last.split("_", 2).last.split("_").first
taskNumber = file.split("_").last.split(".").first
if taskNumber.to_i >= 2 and taskN... | true |
efec891cb2b3d1dc7af5c4541af7e768156d2c91 | Ruby | regismesquita/SyFyHome | /lib/face_recognition.rb | UTF-8 | 1,082 | 2.625 | 3 | [] | no_license | require 'face'
class FaceRecognition
include FaceConfig
def initialize
@client = Face.get_client(:api_key => KEY, :api_secret => SECRET)
end
def recognize_user_faces_in(file)
get_users_from(faces_in_file(file))
end
def add_face_images_for_user(params)
@tids = Array.new
params[:face_files]... | true |
474ba2c6e6bcb8c791c26fed1806d6b3f010e991 | Ruby | Alex223124/banking_application | /lib/messages/withdraw_success.rb | UTF-8 | 275 | 3.28125 | 3 | [] | no_license | # Definiton of Withdraw Success Message
# returned when withdrawal is successfully completed
class WithdrawSuccessMessage < Message
attr_reader :amount
def initialize(amount)
super
@amount = '£' + '%.2f' % amount
@main = ["#{@amount} withdrawn."]
end
end
| true |
2796185b2fe7b2a45f4525bbae1b159a7f5f5949 | Ruby | TheKaterTot/api_curious | /app/models/github_follower_commit.rb | UTF-8 | 362 | 2.703125 | 3 | [] | no_license | class GithubFollowerCommit
attr_reader :data, :repo
def initialize(data, repo)
@data = data
@repo = repo
end
def follower_name
data["commit"]["committer"]["name"]
end
def date
DateTime.parse(data["commit"]["committer"]["date"])
end
def message
data["commit"]["message"]
end
d... | true |
bda3675323a102de6c5f591141da054ad6c60ad7 | Ruby | ratsimisampy/THP-Semaine_3-Envoi_masse_emails | /lib/app/townhalls_mailer.rb | UTF-8 | 3,347 | 2.59375 | 3 | [] | no_license | =begin
GEM UTILISÉE :
require 'google/apis/gmail_v1'
require 'googleauth'
require 'googleauth/stores/file_token_store'
require 'base64'
require 'mime'
include MIME
=end
class TownhallsMailer
attr_accessor :file_db
def initialize(file_db)
# Valeurs de configuration de l'API
@oob_uri = 'urn:ietf:wg:oauth:2.0... | true |
71672581361f43fe346d549717e7fc8e38a15b60 | Ruby | raygao/dvdflex | /lib/iso/isolookup.rb | UTF-8 | 3,179 | 2.65625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | class Iso_Lookup
require 'json'
require 'json/ext'
require 'rubygems'
require 'httparty'
def logger
RAILS_DEFAULT_LOGGER
end
def generateit
# see http://json.rubyforge.org/
logger.info [ JSON.parser, JSON.generator ]
#json = JSON.generate ({"pi"=>3.141})
fruits = {:apple => "mansana"... | true |
8601e59e1088d4510abda0c8a9d0b2e0ffa2744f | Ruby | estebanbouza/WGS84toOSGB36 | /lib/osgb_convert.rb | UTF-8 | 3,224 | 2.765625 | 3 | [] | no_license | module OsgbConvert
def self.degrees_to_rads(degrees)
degrees * Math::PI / 180
end
def self.rads_to_degrees(rads)
rads * 180 / Math::PI
end
module Converter
#ellipse parameters
ELLIPSE = {
:wgs84 => { :a=> 6378137, :b=> 6356752.3142, :f=> 1 / 298.257223563 },
:airy1830 =>... | true |
77a9812fcda55c9fbbea498054d14599668c3199 | Ruby | calo81/lovelyromcoms | /webapp/spec/models/movie_spec.rb | UTF-8 | 4,785 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
describe Movie do
it "finds movie of the day" do
movie = Movie.find_movie_of_the_day
movie.should_not be_nil
movie['title'].should_not be_nil
end
it "finds movie by Rotten Tomatoes ID" do
movie = Movie.find_by_rotten_id(770680214)
movie.should_not be_nil
p movie
... | true |
eed437363089e06ee1559142120f56c360a46839 | Ruby | WhatOSS/Labber | /test/mht_test.rb | UTF-8 | 1,146 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require 'mocha/mini_test'
require 'mht'
class MhtTest < Minitest::Test
@@mht_content = "
------=_FELib_41728.651400463
Content-Type: text/html;
charset=\"iso-8859-1\"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://localhost/1.html
=09<html>
<p>Hello wo... | true |
2e5b9ad9804dc72e2d881639e0d1a1eeabadab9d | Ruby | ViolaCello/ruby-collaborating-objects-lab-onl01-seng-ft-072720 | /lib/artist.rb | UTF-8 | 1,359 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist
attr_accessor :name, :songs
@@all = []
def initialize(name)
@name = name
@songs = []
@@all.push(self)
end
def self.all
@@all
end
def songs
songs = Song.all.select {|song| song.artist == self}
#binding.pry
end
def add_song(song)
s... | true |
174df8fcdd80ab735e059f87f20b19a349f68a98 | Ruby | ajweitz/The_Odin_Project | /web_server_and_browser/server/request.rb | UTF-8 | 824 | 3.25 | 3 | [] | no_license |
class Request
attr_reader :http_method, :uri, :version, :headers, :body
def initialize http_method, uri, version, headers, body
@http_method = http_method.upcase
@uri = uri
@version = version
@headers = headers
@body = body
end
def self.parse_request(string)
request = string.split("\r\n")
request... | true |
1b4060d765ddb27eb7f22c1df9e18ce56d577f35 | Ruby | vahyno/instance-methods-lab-ruby-ruby-intro-000 | /lib/dog.rb | UTF-8 | 141 | 3.09375 | 3 | [] | no_license | class Dog
def bark
puts "Woof!"
end
def sit
puts "The Dog is sitting"
end
end
#fido = Dog.new
#snoopy = Dog.new
#lassie = Dog.new
| true |
60c19afcc83816da8442853f767cdf50144bc9a2 | Ruby | bleavitt92/RB-130-Ruby-Foundations | /ruby_challenges/medium2/diamond.1.rb | UTF-8 | 682 | 3.921875 | 4 | [] | no_license | require 'pry'
class Diamond
def self.make_diamond(letter)
@letter = letter
alphabet = ('A'..'Z').to_a
@index = alphabet.find_index(letter)
top_half
bottom_half
end
def self.top_half
('A'..@letter).to_a.each do |char|
self.form_row(char)
end
end
def self.bottom_half
('... | true |
fe70ef9cdfaaa36caca847a4702cf34be996befe | Ruby | paradolfino/experiments-sinatra | /alpha/app.rb | UTF-8 | 201 | 3.09375 | 3 | [] | no_license | require 'sinatra'
class HelloWorld < Sinatra::Base
get '/' do
"Hello my friend."
end
get '/bye' do "Bye bye" end
get '/:age' do "Hi, #{params[:age]}, is a good year." end
end | true |
3fdf2a424a0b9c05b5a1875f11e15f1d7c8eb254 | Ruby | martymclaugh/ifive-api | /app/models/phone_number.rb | UTF-8 | 909 | 2.515625 | 3 | [] | no_license | class PhoneNumber < ApplicationRecord
belongs_to :user
def create_pin
self.pin = rand(0000..9999).to_s.rjust(4, "0")
save
end
def verification
self.verified = true
save
end
def send_pin
twilio_cli = Twilio::REST::Client.new(ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN'])
twi... | true |
b57e497a1fe3ba58dc05950b74f1e1811ba95656 | Ruby | haydenlangelier/phase-0-tracks | /ruby/nested_data_structures.rb | UTF-8 | 1,395 | 2.84375 | 3 | [] | no_license |
travel = {
Americas: {
north_america: {
USA: ["Los Angeles","New York", "San Francisco", "Seattle", "Las Vegas"],
Canada: ["Vancouver","Quevec", "Toronto"],
Mexico: ["Mexico City","Cancun","Cozumel"]
},
south_america: {
Brazil: ["Sao Paulo","R... | true |
b9f17106b7f9774488024974473ba125f6b38a1c | Ruby | krislitman/order_up | /spec/models/chef_spec.rb | UTF-8 | 3,099 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Chef, type: :model do
describe "validations" do
it {should validate_presence_of :name}
end
describe "relationships" do
it {should have_many :dishes}
end
describe "instance methods" do
it "#find_unique_ingredients" do
@gordon = Chef.create!(
na... | true |
e0ea87ba9733e26e45006e9635711a1bd2c53de7 | Ruby | yorobot/workflow | /lint.rb | UTF-8 | 1,537 | 2.546875 | 3 | [] | no_license |
def build_errors( errors ) ## rename to format errors - why? why not?
buf = String.new( '' )
if errors.size > 0
buf << "#{errors.size} error(s) / warn(s):\n"
errors.each do |error|
buf << "!! ERROR: #{error}\n"
end
else
buf << "#{errors.size} errors / warns\n"
end
buf
end
def lin... | true |
d3e1f0b660da8e50fa83b472aef88ef4181f19c4 | Ruby | tdy/euler | /p025.rb | UTF-8 | 720 | 4.125 | 4 | [] | no_license | #!/usr/bin/env ruby
#
# 1000-digit Fibonacci number
# http://projecteuler.net/problem=25
#
# The Fibonacci sequence is defined by the recurrence relation:
#
# Fn = Fn−1 + Fn−2, where F1 = 1 and F2 = 1.
#
# Hence the first 12 terms will be:
#
# F1 = 1
# F2 = 1
# F3 = 2
# F4 = 3
# F5 = 5
# F6 = 8
# F7 = 1... | true |
f6a6b35fcc1d86adf34d97bf6cfd366504b4c816 | Ruby | ged/saltpack-ruby | /lib/saltpack/message.rb | UTF-8 | 3,132 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- ruby -*-
# frozen_string_literal: true
require 'loggability'
require 'msgpack'
require 'rbnacl'
require 'saltpack' unless defined?( Saltpack )
require 'saltpack/header'
require 'saltpack/payload'
# An encrypted message.
class Saltpack::Message
extend Loggability
# Loggability -- log to the Saltpack module... | true |
b05263bcd70454174688cc323195779dd8011fa6 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz49_sols/solutions/Dominik Bathon/lispgame_literal.rb | UTF-8 | 3,144 | 3.28125 | 3 | [
"MIT"
] | permissive |
$objects = [:whiskey_bottle, :bucket, :frog, :chain]
$map = {
:living_room => ["you are in the living-room of a wizard's house. there is a wizard snoring loudly on the couch.",
{:west => ["door", :garden], :upstairs => ["stairway", :attic]}],
:garden => ["you are in a beautiful garden. there is a well in front of... | true |
805598abdec9bfe24357c72e2438f045515622ed | Ruby | krebates/shapes_tdd | /spec/checkpoint_tdd/rectangle_tdd_spec.rb | UTF-8 | 333 | 2.71875 | 3 | [] | no_license | require 'rspec'
require_relative '../../lib/rectangle_tdd'
describe Rectangle do
it 'calculates the perimeter' do
rectangle = Rectangle.new(10.0, 20.0)
expect(rectangle.perimeter).to eq(60.0)
end
it 'calculates the area' do
rectangle = Rectangle.new(10.0, 20.0)
expect(rectangle.area).to eq(200.... | true |
18a61e5e4308f8bd9d809a974441d55f170b738d | Ruby | english/classique_kitchens | /features/step_definitions/home_page_steps.rb | UTF-8 | 1,446 | 2.640625 | 3 | [] | no_license | def sample_image
path = File.expand_path('../../spec/fixtures/sample_image.jpg', File.dirname(__FILE__))
File.new(path)
end
Given /^Some featured kitchens$/ do
@slides = 3.times.map {|i| Kitchen.create! name: "Kitchen #{i}",
image: sample_image, featured: true }
end
When /^I go to the home page$/ do
visit... | true |
7c1b41bfa60da59c2d586e2447340762a4c14481 | Ruby | katiejonesyo/Ruby | /MathAndNumbers/MandN.rb | UTF-8 | 437 | 4.25 | 4 | [] | no_license | puts 5.86543
puts -5.86543
puts 5 + 9
puts 5 - 9
puts 5 * 9
puts 5 / 9
puts 2**3
puts 10 % 3
num = 20
puts num
num = 20
puts ("this method will print a string and number in the same scentence. Example, my fave num is " + num.to_s)
num = 25
puts num.abs()
num = 22.678
puts num.round()
num = 20.1
puts num.ceil()
nu... | true |
90ba93cb280f8a75a51c8a4950b1003428655d46 | Ruby | jayehernandez/advent-of-code | /2020/day-3/3.rb | UTF-8 | 554 | 3.671875 | 4 | [
"MIT"
] | permissive | require "active_support/core_ext/object/blank"
@input = File.readlines("input.txt")
def traverse_slopes(slopes)
return slopes.map do |slope|
trees, x, y = 0, slope[1], slope[0]
@input.each do |path|
trees += 1 if @input[x].present? && @input[x][y % (path.length - 1)] == "#"
x += slope[1]
... | true |
54c15dd888289d44f68af890d531f0a950421a3c | Ruby | yuipuccho/Japanese_nursing_rails | /app/controllers/logic/users.rb | UTF-8 | 910 | 2.609375 | 3 | [] | no_license | module Logic
module Users
# ゲストユーザーを作成する
# @param user_name ユーザー名
# @return ゲストユーザーのインスタンス
def create_guest_user(user_name)
guest_user = User.new(user_name: user_name,
email: "guest_#{Time.now.to_i}#{rand(100)}@example.com")
guest_user.add_auth_token
gues... | true |
e1ef234364b2da6b0148ef3fedb16bf43f398ee6 | Ruby | arthur-littm/hospital-mvc | /patients_repository.rb | UTF-8 | 1,268 | 3.359375 | 3 | [] | no_license | require "csv"
require_relative "patient"
class PatientsRepository
def initialize(csv_file_path, rooms_repository)
@rooms_repository = rooms_repository
@csv_file_path = csv_file_path
@patients = []
@next_id = 1
load_csv
end
def add_patient(patient)
patient.id = @next_id
@patients << p... | true |
90e50dd0a7215b6f0052b9743bbafc31d7b010ed | Ruby | deoladed/AirBnDogs | /db/seeds.rb | UTF-8 | 613 | 2.703125 | 3 | [] | no_license | 5.times do
c = City.create(city_name: Faker::GameOfThrones.city)
end
puts '10 cities added'
10.times do
d = Dog.create(name: Faker::GameOfThrones.character, city: City.all.sample)
puts "Toutou #{d.name} added"
end
10.times do
ds = Dogsitter.create(name: Faker::HarryPotter.character, city: City.all.sample)
puts ... | true |
6de624f184047e742ba33f3f48e49336c276938d | Ruby | lizhixingios/LGSocket | /fastlane/actions/remove_tag.rb | UTF-8 | 3,446 | 2.65625 | 3 | [
"MIT"
] | permissive | module Fastlane
module Actions
module SharedValues
REMOVE_TAG_CUSTOM_VALUE = :REMOVE_TAG_CUSTOM_VALUE
end
class RemoveTagAction < Action
# action 真正的执行逻辑
def self.run(params)
# 1. action 名称
# 2. 功能: 可以删除,本地 & 远程标签
# 3. remove_tag(tagName:0.1.0, rL:true, rR:tru... | true |
a18df9f8af8678d85dedec630e9cdff98cb1147c | Ruby | Nickolai8/rb101 | /practice_problems/medium2/question3.rb | UTF-8 | 910 | 3.96875 | 4 | [] | no_license | # The program will output:
# "My string lookks like this now: pumpkins"
# "My array looks like this now: ['pumpkins', 'rutabaga']"
# The reason that the string didn't change but the array did was
# because << mutates the caller by adding in element(s) to an
# array, so the original array was modified. += is just reass... | true |
ab3b7d2002ede7b5018c74175e1095b5b1355abd | Ruby | Orelongz/code-challenges | /proto/index.rb | UTF-8 | 3,039 | 3.53125 | 4 | [] | no_license | FileHeader = Struct.new(
:magic_string,
:version,
:no_of_records,
)
Record = Struct.new(
:type,
:timestamp,
:user_id,
:amount,
)
class CustomProtocolFormat
attr_reader :records
TYPE_MAPPING = {
"\x00": 'Debit',
"\x01": 'Credit',
"\x02": 'StartAutopay',
"\x03": 'EndAutopay'
}
de... | true |
2e0ff2f689defee05dbed4f2f718c50056edc7a2 | Ruby | lnabrigo18/Ruby-Activities | /activity_oop.rb | UTF-8 | 411 | 4.1875 | 4 | [] | no_license | class Box
def initialize(width,length,height)
@width = width
@length = length
@height = height
end
def area
a = @width*@length
puts "The area is #{a} square units."
end
def volume
v = @width*@length*@height
puts "The volume is #... | true |
336602c633b036fc0268c0fcf93e36bd328620e7 | Ruby | thommay/dcob | /lib/dcob.rb | UTF-8 | 2,668 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-dco-1.1"
] | permissive | require "dcob/version"
require "sinatra"
require "octokit"
require "json"
require "pp"
require "openssl"
require "toml"
module Dcob
class Server < Sinatra::Base
post '/payload' do
payload_body = request.body.read
verify_signature(payload_body)
pr = JSON.parse(payload_body)
repo_id = pr["... | true |
da1c25aa6c33d037d633659537dffdc2ccaa02ff | Ruby | dalspok/intro_to_prog | /hashes/hashes_5.rb | UTF-8 | 167 | 3.4375 | 3 | [] | no_license | my_h = {one: 1, two: 2}
searched_val = 2
my_h.has_value?(searched_val) ? (puts "Value #{searched_val} is in hash") : (puts "Value #{searched_val} is not in hash")
| true |
1d64578b9a761eb54381b9e56782b66ba34a9861 | Ruby | allanizzo/project_euler_problems | /06_sum_square_difference.rb | UTF-8 | 1,145 | 4.21875 | 4 | [] | no_license |
# time taken - 8:34.9
# The sum of the squares of the
# first ten natural numbers is,
# 12 + 22 + ... + 102 = 385
# The square of the sum of
# the first ten natural numbers is,
# (1 + 2 + ... + 10)2 = 552 = 3025
# Hence the difference between the sum
# of the squares of the first ten natural
# numbers and the sq... | true |
8f80d4b24696978bfb0eb0c80625ab038dcef4b1 | Ruby | onetwopunch/figly | /lib/figly.rb | UTF-8 | 2,208 | 2.765625 | 3 | [
"MIT"
] | permissive | require "figly/version"
require "figly/settings"
module Figly
class ParserError < StandardError; end
class UnsupportedFormatError < StandardError; end
class ConfigNotFoundError < StandardError; end
class ConfigNotLoaded < StandardError; end
def self.load_file(path)
raise ConfigNotFoundError, "File does ... | true |
20ffa4405440fa135b0de0285f5019e5e17cbe0a | Ruby | YuukiMAEDA/AtCoder | /Ruby/ABC/B/Card_Game_for_Three.rb | UTF-8 | 264 | 3.453125 | 3 | [] | no_license | sa=gets.chomp.split("").push("A")
sb=gets.chomp.split("").push("B")
sc=gets.chomp.split("").push("C")
turn=sa
while turn.size>1
new_turn=turn.delete_at(0)
if new_turn=="a"
turn=sa
elsif new_turn=="b"
turn=sb
else
turn=sc
end
end
puts turn[0]
| true |
4a52fd87c678d71ec684a920d270e95356a275fd | Ruby | jamesarosen/xebec | /lib/xebec/html5.rb | UTF-8 | 1,782 | 2.859375 | 3 | [] | no_license | module Xebec
def self.html5_for_all_browsers!
Xebec::HTML5.force = true
end
# Xebec will help you transition your site to HTML 5
# by using the <tt><nav></tt> element like so:
#
# <nav class='my_navbar_name'>
# <ul>
# <li><a href='/home'>Home</a></li>
# ...
# </ul>
#... | true |
e64b2137143999879f4979d9bed9b59e52bb0fee | Ruby | pwnall/rails_pwnerer | /lib/rails_pwnerer/base/packages.rb | UTF-8 | 9,738 | 2.65625 | 3 | [
"MIT"
] | permissive | # extends Base with OS package-related functions
require 'English'
require 'fileutils'
require 'shellwords'
module RailsPwnerer::Base
# TODO: this works for debian-only
# Installs a package matching a pattern or list of patterns.
#
# Args:
# patterns:: same as for best_package_matching
# options:: sa... | true |
8ac9b2dbff255a88881a96f57a9d3cc0feb0fb56 | Ruby | Baron-burton/cykl | /lib/cykl/issues.rb | UTF-8 | 658 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'octokit'
module Cykl
class Issues
attr_reader :client
private :client
def initialize
@client = Octokit::Client.new(
netrc: true
)
end
def list_issues(repo = nil)
pr_free_issues = []
counter = 1
while pr_free_issues.count < 50
issues = get... | true |
51450d10cff31fb0f9a8ad9f08059b06c026b4df | Ruby | TonyCWeng/w2d1 | /chess/bishop.rb | UTF-8 | 218 | 2.609375 | 3 | [] | no_license | require_relative 'piece.rb'
class Bishop < Piece
include SlidingPiece
def initialize(pos, board, color)
super(pos, board, color)
@symbol = :b
end
protected
def moves_dirs
DIAGONALS
end
end
| true |
2232d8e66624099cf83390810173f1541c62d83b | Ruby | AndreOF/my-first-repository | /methods_exercises/Exercise05.rb | UTF-8 | 118 | 3.375 | 3 | [] | no_license | def scream(words)
words = words + "!!!!"
puts words
end
scream("Yippeee")
#Now prints Yippeee!!!! and returns nil | true |
ca1d72b7d822ef707e6450b5ddfe2228165ef4d3 | Ruby | Tronerta/ruby_problems | /stock_picker.rb | UTF-8 | 326 | 4.03125 | 4 | [] | no_license |
def stock_picker (array)
profit = 0
result = []
array.each do |int|
for i in (array.index(int)..array.length - 1)
if array[i] - int > profit
profit = array[i] - int
result = [array.index(int), i]
end
end
end
print result
end
stock_picker([3, 2, 5, 1])
# [1,4] # for a profit of $15 - $3 ... | true |
27b796ad338b789fd45a8cb34bfc85c09445ec0f | Ruby | kabe10/Code | /ruby/bmp/bmp_header_reader.rb | UTF-8 | 2,738 | 3.109375 | 3 | [] | no_license | #!ruby
require 'OrderedHash.rb'
# Bmp Header Reader
class Bmp
def initialize
end
def read(img_path)
f = open(img_path, 'rb')
#BMPFILEHEADER
@bf = OrderedHash.new
@bf[:Type] = f.read(2)
@bf[:Size] = f.read(4)
@bf[:Reserved1] = f.read(2)
@bf[:Reserved... | true |
fbff0608b3a2297fdbfaa741dda0ba086950aff3 | Ruby | hirakawa-takahiko/hira | /dband932.rb | UTF-8 | 9,445 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8 # このコメントの編集厳禁。必ず2行目に置くこと
# vim: ts=4 background=dark
#
# 指定されたスキーマの全テーブル定義を調べて、VARCHAR, TEXTのカラムを探す
# そのカラムのデータにCP932機種依存文字が入っていたら代替文字に変換する
#
# Usage: this.rb [--host=DBSERVER(default is localhost)] [--database=SCHEMA(default is aff)] [tablenames...]
#
require 'nkf'
require 'a... | true |
c5539912a23f9c87820bddf03846a42e78ce67f9 | Ruby | tkoar/green_grocer-web-042417 | /grocer.rb | UTF-8 | 1,434 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def consolidate_cart(cart)
consolidated_cart = {}
cart.each do |item, item_hash|
item_name = item.keys.first
if consolidated_cart[item_name]
consolidated_cart[item_name][:count] += 1
else
consolidated_cart[item_name] =
{ price: item[item_name][:price],
clearance: item[item_name... | true |
81662c2c6a57bbbfbc60978c058921f06b0aaec2 | Ruby | morefama/HojaDeVida | /Ruby/numeroPar.rb | UTF-8 | 154 | 3.859375 | 4 | [] | no_license | puts 'ingrese un numero: '
numero = gets.chomp.to_i
if numero % 2 == 0
puts "El numero #{numero} es par"
elsif
puts "El numero #{numero} es impar"
end
| true |
1cc905323bc8b8fec7bbb42e1afe91654a43239f | Ruby | vprokopchuk256/algorithms | /lib/data_structures/symbol_tables/linear_probing_hash.rb | UTF-8 | 709 | 3.015625 | 3 | [] | no_license | module DataStructures
module SymbolTables
class LinearProbingHash
M = 300001
private_constant :M
def put(key, value)
i = hash(key)
while keys[i]
break if keys[i] == key
i = (i + 1) % M
end
keys[i] = key
values[i] = value
end
... | true |
a5e94840c1e15c4b59434d20a816c1e4bb714e27 | Ruby | ohboyohboyohboy/jejune | /lib/jejune/macro.rb | UTF-8 | 1,578 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
# encoding: utf-8
#
# author: Kyle Yetter
#
module Jejune
class Macro
include Constants
attr_accessor :manager, :name, :parameters, :blueprint
def initialize( manager, tree )
@manager = manager
#@tree = tree
@name = tree[ 0 ].text
if node = tree[ 1 ] and node.type... | true |
797ad8fc57e8e5349d04e9a2f68aaef14e326f77 | Ruby | progpyftk/learn_to_code_with_ruby_udemy | /Section 18/self_keyword.rb | UTF-8 | 1,432 | 4.09375 | 4 | [] | no_license | # self keyword will refer to the current object, in each scope there will be a different self
class Wine
def initialize
@name = "wine name"
@maker = "wine maker"
@year = "wine year"
@price = 0.00
end
def change_price(new_price)
@price = new_price
p "the p... | true |
6363f0d4a0a6acc9619bb1baad1d654752d9a0f5 | Ruby | slaloggia/blood-oath-relations-chicago-web-100719 | /app/models/cult.rb | UTF-8 | 1,827 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cult
attr_reader :name, :location, :founding_year
attr_accessor :slogan, :minimum_age
@@all = []
def initialize(name, location, founding_year)
@name = name
@location = location
@founding_year = founding_year
@slogan = ""
@minimum_age = 0
@@all << self
end
... | true |
88a1900c72d0050b53713b7eef5f0d0a576fbe64 | Ruby | ahegyi/lunch-roulette | /lib/lunch_roulette.rb | UTF-8 | 3,385 | 2.953125 | 3 | [
"MIT"
] | permissive | $:.push "./lib"
require 'csv'
require 'optparse'
require 'yaml'
require 'set'
require 'digest'
require 'lunch_roulette/config'
require 'lunch_roulette/enumerable_extension'
require 'lunch_roulette/lunch_set'
require 'lunch_roulette/lunch_group'
require 'lunch_roulette/person'
require 'lunch_roulette/output'
class Lu... | true |
95b3b508aba4fd4803c64af84a37bdcac30c9940 | Ruby | subbat9710/winningnumbers | /raffleticket.rb | UTF-8 | 643 | 2.515625 | 3 | [] | no_license | require "minitest/autorun"
require_relative "testraffleticket.rb"
class TestNumber < Minitest::Test
def test_ticket_5423_returns_true
my_ticket = "5423"
winning_tickets = ["5423"]
assert_equal(true, winning_number_include?(my_ticket,winning_tickets))
end
def test_ticket_1393_returns_true
my_ticket = "1393"
winn... | true |
316a327be768dfd3b87a73288974ed7b805dca7a | Ruby | NREL/alfalfa | /tests/integration/models/schedule_model/modify_model.rb | UTF-8 | 2,342 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | require 'openstudio'
# puts OpenStudio::Model::Model.methods.filter { |m| m.to_s.upcase.include? "LOAD"}
# exit
model = OpenStudio::Model::Model.load("small_office.osm").get
# model.load("small_office.osm")
building = model.building.get
story = building.buildingStories()[0]
clg_value = 23
htg_value = 15
model.getTherm... | true |
78ecf174a972a8fe135ca2c76109d6e6a8c2eea7 | Ruby | leightkt/belay-chain-users-api | /app/models/administrator.rb | UTF-8 | 564 | 2.53125 | 3 | [] | no_license | class Administrator < ApplicationRecord
has_secure_password
validates :username, :email, :password, presence: true
validates :email, :username, uniqueness: { message: "should be unique and %{value} is taken."}
validates :password, length: { in: 6..20 }
validates :password, format: {with: /[\d]/, me... | true |
0faaf1a6df71e3e2a3423255b6b85ecfdb082b25 | Ruby | mathildathompson/StudentDirectory | /student.rb | UTF-8 | 1,727 | 3.484375 | 3 | [] | no_license | require 'rubygems'
require 'yaml'
class Person
attr_accessor :name
attr_accessor :email
attr_accessor :github_user
attr_accessor :twitter
attr_accessor :fun_fact
def initialize
self.get_person_info
end
def self.create_person(type)
case type
when "Student"
Student.new
when "Inst... | true |
2a3bd96fae249eb42a412cf5662b16abc4f74f1b | Ruby | nishinoryohei/task_5_6 | /db/fixtures/development/012_category.rb | UTF-8 | 196 | 2.546875 | 3 | [] | no_license | 200.times do |i|
Category.seed(:id) do |category|
category.id = i + 1
category.item_id = i + 1
category.color = rand(1..2)
category.area = [10,20,30,40,50,60,70,80].sample
end
end | true |
b198ae539881006fe8d30db4cf9d8f8d638581ce | Ruby | pereslop/rails-new | /app/helpers/admin/users_helper.rb | UTF-8 | 1,605 | 2.53125 | 3 | [] | no_license | require 'user_statistic'
require 'rubyvis'
module Admin::UsersHelper
include Statistic::UserStatistic
def comments_graph(comments)
comments_data = comment_statistic_graph_data(comments)
days = last_days
# Sizing and scales
w = 600
h = 250
x = pv.Scale.linear(0, comments_data.max).range(0, w)
... | true |
904631725db3dd653a2f97d9819a616f48e53652 | Ruby | wilkosz/squash_matrix | /lib/squash_matrix/nokogiri-parser.rb | UTF-8 | 5,895 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'nokogiri'
require_relative 'constants'
module SquashMatrix
class NokogiriParser
class << self
def get_player_results(body)
rtn = Nokogiri::HTML(body)&.xpath('//table[@id="results"]//tbody//tr')&.map do |r|
date = r.at_css('td[1]')&.content
... | true |
0e73cd0c65fab7967f9132e907423544a5196afe | Ruby | norman/nt54 | /lib/nt54/parser/machinery.rb | UTF-8 | 1,167 | 2.53125 | 3 | [
"MIT"
] | permissive | module NT54
class Parser
module Machinery
private
def self.included(base)
base.extend ClassMethods
end
def machine
@machine or begin
@machine = MicroMachine.new(:Dialtone).tap do |m|
m.instance_variable_set :@transitions_for, self.class.transitions
... | true |
e50c7a533b6b65754bbb50ad41d6b1a7156ef310 | Ruby | adrienemery/vanpy-2019 | /a_serial_read.rb | UTF-8 | 293 | 2.8125 | 3 | [] | no_license | require 'rubyserial'
serialport = Serial.new '/dev/tty.usbmodem141101'
buffer = ''
loop do
next_char = serialport.getbyte&.chr
buffer += next_char if next_char
match = buffer.match(/(\d+)\r\n/)
if match
data = match[1]
p data
buffer = ''
end
end
| true |
88a36dc1ba551251fe6cae410ffdd09398389796 | Ruby | MarchonMilwaukee/glue | /lib/response.rb | UTF-8 | 3,797 | 2.578125 | 3 | [] | no_license | require "erb"
require_relative "./gmail"
require_relative "./github"
SUPPORT_EMAIL_ADDRESS = "nick@rokkincat.com"
HOW_I_HELP_QUESTION = "list_42098940_choice_*"
NAME_QUESTION = "textfield_41889987"
EMAIL_QUESTION = "textfield_42591039"
PHONE_NUMBER_QUESTION = "textfield_... | true |
17fd48cc2e0b1cffb83caa907a8c28179f8fe634 | Ruby | rsnorman/weekly_album_anniversaries | /app/decorators/album_anniversaries_json_decorator.rb | UTF-8 | 1,419 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
class AlbumAnniversariesJsonDecorator
# Initialize decorator far an array of albums
# @param [Array<album>] albums array to decorator
def initialize(albums, week = Week.current)
@albums = albums
@week = week
end
# Returns json for a anniversary for a group of albums
... | true |
71258b7fda036542d0e65c8361391245a7783630 | Ruby | panand71/boutique_app | /test/models/owner_test.rb | UTF-8 | 2,126 | 2.6875 | 3 | [] | no_license | require 'test_helper'
class OwnerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
def setup
@owner = Owner.new(name: "Example Owner", email: "owner@example.com",
password: "foobars", password_confirmation: "foobars")
end
test "authenticated? should re... | true |
c790e216b317a53b0c0c409508f69d36cab9bbff | Ruby | exyzzy/ruby-bowl | /bowl.rb | UTF-8 | 5,527 | 3.375 | 3 | [] | no_license | # bowl.rb bowling scoring program in ruby
# Author: Eric Lang
# http://www.exyzzy.com
class States
def initialize
@curState = 0
@curFrame = 0
@pinsInFrame = 10
@scores = []
#[frame_inc, frame_inc, frame_inc, new_state, new_state, new_state, proc, proc, proc]
@stateMachine = [[0,1,0,1,2,8], #s... | true |
7540270e05d02458702cc38926af61911dbc5cb5 | Ruby | michelle54725/ICS-Course | /ch13/orangeTree.rb | UTF-8 | 986 | 4.25 | 4 | [] | no_license | class OrangeTree
def initialize
@age = 0
@height = 10
@fruit = 0
end
def height
"Height: #{@height}"
end
def age
"Age: #{@age}"
end
def orangeCount
"Oranges: #{@fruit}"
end
def pickOrange
if @fruit >= 1
@fruit = @fruit - 1
'You picked a fruit. It was delicious.'
else
'There are... | true |
9fd84649e6d647bf805e9eedb86394f1566ab053 | Ruby | netmask/video | /video_parser.rb | UTF-8 | 1,218 | 3.171875 | 3 | [] | no_license | require 'csv'
require 'date'
#just a pure simple ruby class as container
class Video
attr_accessor :number, :name, :celebrity, :date, :tags
def initialize(number, name, date, celebrity, tags)
self.number = number
self.name = name
self.celebrity = celebrity
self.date = date
self.tags = tags
... | true |
6fee4b7493e86770b311a026b07955a9eb14e925 | Ruby | AllAlgorithms/ruby | /algorithms/sorting/shell_sort.rb | UTF-8 | 521 | 4 | 4 | [
"MIT"
] | permissive | # Ruby implementation of shell sort
#
# See: http://www.codecodex.com/wiki/Shell_sort
def shellSort(array)
inc = array.size / 2
while inc > 0
inc.upto(array.size - 1) { |i|
j = i
temp = array[i]
while j >= inc and array[j - inc] > temp
array[j] = array[j - inc]
j -= inc
... | true |
b1bcc6c43c24e2d92856b99c7d826755b168d626 | Ruby | Babauskis/1a_homepage | /features/support/runner/optparser.rb | UTF-8 | 1,376 | 2.625 | 3 | [] | no_license | require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
class Optparse
CODES = %w(iso-2022-jp shift_jis euc-jp utf8 binary).freeze
CODE_ALIASES = { 'jis' => 'iso-2022-jp', 'sjis' => 'shift_jis' }.freeze
def self.parse(args)
options = OpenStruct.new
options.format = 'html'... | true |
0a99defb33f4b4f9f5fdc94c1f01d0832998e6de | Ruby | stefl/Caboodle | /lib/caboodle/kits/page/page.rb | UTF-8 | 594 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Caboodle
class Page < Caboodle::Kit
description "Create markdown pages in the config directory and they are displayed as menu items and pages"
configure do
pages = []
Dir[File.join(Caboodle::App.root,"pages","*.md")].map do |a|
pages << a.split("/").last.split(".").first
... | true |
3f7a495d0cc3c7a50ee7e13be97255364f8da571 | Ruby | nigelramsay/enalytics | /app/services/query_measurements.rb | UTF-8 | 1,297 | 2.71875 | 3 | [] | no_license | class QueryMeasurements
def initialize(period_in_seconds:)
@period_in_seconds = period_in_seconds
end
def putnam_current_temperatures
Measurement.putnam_current_temperatures.
where('recorded_at >= ?', start_date).
order('recorded_at desc').
pluck(:recorded... | true |
1d1bda5d5ac98426d6daea4db2ce9670e43a68d8 | Ruby | TataSher/Process_Reviews | /Process_review_4/lib/string_calculator.rb | UTF-8 | 310 | 3.65625 | 4 | [] | no_license | def string_calculator(string)
check_numbers(string)
integer_array = string.split(' ').map do |value|
value.to_f
end
[ string, integer_array.sum]
end
private
def check_numbers(string)
if string.count('0-9') == 0
raise "Input must be a valid mathematical string separated by spaces"
end
end | true |
bd39cba85f1fd8ae4c0442a069dfbc174c34fded | Ruby | kumquatexpress/clairvoyance-app | /app/models/game.rb | UTF-8 | 1,891 | 2.703125 | 3 | [] | no_license | class Game < ActiveRecord::Base
has_and_belongs_to_many :items
has_and_belongs_to_many :champions
has_and_belongs_to_many :team_comps
has_and_belongs_to_many :players
self.primary_key = 'id'
def process_game
if self.processed
return
end
tc1, tc2 = self.team_... | true |
5f58e2f3ef06d5e828d71a7082843587ba23fd65 | Ruby | pupca/lovecode_shop | /vendor/sequel/plugins/sequel_create_retry.rb | UTF-8 | 2,186 | 2.65625 | 3 | [] | no_license | module Sequel
module Plugins
# Retry a create/save n times. The optional block will be executed
# before retry.
#
# @example
#
# plugin :create_retry
# plugin :create_retry, num_retries: 2
#
# plugin :create_retry do |order|
# order.generate_random_external_id
# ... | true |
c4c91d419822670a29c66763a7a9053ed8f1f0a2 | Ruby | katlandreth/wheretolive | /app/models/country.rb | UTF-8 | 1,219 | 2.796875 | 3 | [] | no_license | class Country < ActiveRecord::Base
validates :name, presence: true
def self.non_data_columns
["id", "created_at", "updated_at", "name", "country_code"]
end
def education_score
NormalizeData.average_education_score([
self.reading_score,
self.math_score,
self.science_score
])
e... | true |
15e9275f926496d3e2c90aac05f4cf6ab19a9397 | Ruby | threeifbywhiskey/houston | /rb/27.rb | UTF-8 | 222 | 3.28125 | 3 | [] | no_license | require 'prime'
max, maxprod = 0, 0
(-999..999).each do |a|
(-999..999).each do |b|
n = 0
n += 1 while (n * n + a * n + b).prime?
if n > max
max = n
maxprod = a * b
end
end
end
p maxprod
| true |
aafed1bfe23d87e70a94f477b552f7c285f64c22 | Ruby | barrycarter/bcapps | /playground2.rb | UTF-8 | 604 | 2.953125 | 3 | [] | no_license | #!/usr/local/bin/ruby
# https://www.codewars.com/kumite/5807144337a4fd04cc000093?sel=584ff72d019ddf8672000126
require '/home/barrycarter/BCGIT/bclib.rb'
def divisors (n)
fact = []
for i in 1.. (Math.sqrt(n)).floor
if n % i == 0
fact << i
# more rubyish i think
fac... | true |
c34e79eee90a2725d4acaaafedc3092b051f8c60 | Ruby | kputnam/stupidedi | /lib/stupidedi/versions/common/syntax_notes.rb | UTF-8 | 4,422 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
module Stupidedi
using Refinements
module Versions
module Common
#
# @see X222.pdf A.1.3.4 Syntax Notes
# @see X222.pdf A.1.3.8 Condition Designator
#
module SyntaxNotes
#
# Paired or Multiple: if any element specified in the relationa... | true |
da4bc5eba405eb7466b26de3d1002532b9cd8722 | Ruby | id774/sandbox | /ruby/lambda/scope_of_block.rb | UTF-8 | 162 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
def my_method
yield
end
top_level_var = 1
my_method {
top_level_var += 1
local_to_block = 3
}
p top_level_var
p local_to_block
| true |
a93d74dac7d83f7cff168a0ee6b79d2c6110645b | Ruby | kfkkail/odin-project | /building_blocks/caesar_cipher.rb | UTF-8 | 886 | 4.15625 | 4 | [] | no_license | def caesar_cipher (string, shift_factor)
#puts string
#puts shift_factor
alphabet = "abcdefghijklmnopqrstuvwxyz"
ciphered_string = ""
string.each_char { |letter|
letter_index = alphabet.index(letter.downcase)
if letter_index == nil
ciphered_string += letter
else
... | true |
ed035bbd61c8364bfa1aa364f3ad35909c5a63e0 | Ruby | 0000marcell/shoes4 | /lib/shoes/slot_contents.rb | UTF-8 | 817 | 3.09375 | 3 | [
"MIT"
] | permissive | class Shoes
class SlotContents
extend Forwardable
def_delegators :@contents, :[], :size, :empty?, :first, :each, :clear,
:include?, :delete
def initialize
@contents = []
@prepending = false
@prepending_index = 0
end
def add_element(... | true |
5f330b07b365ca719bbcf777513e65bf94f2277d | Ruby | fejo-dk/fictional-spork | /pony.rb | UTF-8 | 291 | 3.078125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class Pony
attr_reader :name, :color
def initialize(name:, color:)
@name = name
@color = color
@state = :idle
end
def run
@state = :running
end
def idle?
@state == :idle
end
def running?
@state == :running
end
end
| true |
034addae8227eaaa99968aedf3691ce6b99ebc16 | Ruby | michelchenrich/mm-kata-ruby | /lib/money.rb | UTF-8 | 542 | 3.5625 | 4 | [] | no_license | class Money
def initialize(amount, currency)
@amount = amount
@currency = currency
end
def to_s
"%s %.2f" % [@currency.code, @amount]
end
def inspect
to_s
end
def ==(other)
self.to_s == other.to_s
end
def *(multiplier)
(@amount * multiplier).as(@currency)
end
def +(aug... | true |
7a28c3fb5dc325342b0cea6dd2726fa973c6b7db | Ruby | DarrelJames/Knox_Restaurants | /lib/Knox_Restaurants/restaurant.rb | UTF-8 | 1,013 | 3.484375 | 3 | [
"MIT"
] | permissive | class KnoxRestaurants::Restaurant
attr_accessor :name, :cuisine, :address, :phone_number
@@all = []
#a restaurant has a name, a list of cuisines, an address, and a phone number
def initialize(restaurant_hash)
@name = restaurant_hash[:name]
@phone_number = restaurant_hash[:phone_number... | true |
a104879e4503dd5800b1774c8aebb2a0d65e3bf8 | Ruby | PatrickCremin/programming-univbasics-4-square-array-chi01-seng-ft-062220 | /lib/square_array.rb | UTF-8 | 105 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
i = 0
arr = []
while (i < array.count) do
arr << array[i]** 2
i += 1
end
arr
end
| true |
73b80809c3dee48fc8229ebad2345cf9510d4d77 | Ruby | Viacheslav74/Goroda-game | /goroda.rb | UTF-8 | 29,917 | 2.765625 | 3 | [] | no_license | # encoding: UTF-8
=begin
Задача 15-2
Уверены, вы догадались, для чего было первое задание ;)
Теперь, когда вы умеете доставать из контакта города, ничто не остановит вас от написания собственной программы, которая играет с пользователем в игру «Города». И конечно выигрывает! Ведь городов столько (даже в России), что н... | true |
2235296f2d8e849a0c3eb0919e320d099bbcc0d4 | Ruby | ssaunier/examiner | /spec/support/2_tests_1_failure/Rakefile | UTF-8 | 358 | 2.734375 | 3 | [
"MIT"
] | permissive | def plus_one(i)
i + 1
end
def minus_one(i)
i # Boffus implementation!
end
task :default do
require "minitest/autorun"
describe "#plus_one" do
it "should return 2 when passed 1" do
plus_one(1).must_equal 2
end
end
describe "#minus_one" do
it "should return 2 when passed 3" do
minus... | true |
0664f77333acc7edda30181241fe8047d5c6ea2c | Ruby | wfischer42/veeo-waypoint | /app/models/result.rb | UTF-8 | 510 | 2.71875 | 3 | [] | no_license | class Result
attr_reader :url,
:title,
:snippet,
:display_url
def initialize(data, question_id)
@question_id = question_id
@url = data[:url]
@title = data[:name]
@snippet = data[:snippet]
@display_url ... | true |
e7ad25da07759c359f828d2bdaccd456ce16e551 | Ruby | shardeepratt/tts_projects | /madlib.rb | UTF-8 | 324 | 3.59375 | 4 | [] | no_license | puts "Give me a verb."
verb = gets.chomp
puts "Give me a plural noun"
pnoun = gets.chomp
puts "Give me a preposition"
prep = gets.chomp
puts " Give me an object"
object = gets.chomp
puts "Give me a adjective?"
adjective = gets.chomp
puts "As I #{verb} to the #{pnoun} I noticed that there was a #{adjective} car #{prep... | true |
e4739afb9d1627c6454cabca6d79fd7b90819e1f | Ruby | locnguyen/configgle | /lib/event.rb | UTF-8 | 1,107 | 2.734375 | 3 | [] | no_license | require 'data_mapper'
require 'registration_template'
class Event
include DataMapper::Resource
property :id, Serial
property :name, String
property :start_date, Date
property :end_date, Date
property :homepage, URI
property :description, String
property :capacity, Integer
belongs_to :organization
... | true |
21c751953659d7d70eb63c7112c504842d43ecdd | Ruby | psalaets/etroutes | /test/unit/route_test.rb | UTF-8 | 3,352 | 2.578125 | 3 | [] | no_license | require 'test_helper'
class RouteTest < ActiveSupport::TestCase
def setup
@valid_route = Route.new(
:grade => '5.10a',
:gym => 'Earth Treks',
:location => 'Rockville',
:name => 'The Climb',
:rid => '1234',
:set_by => 'Bob',
:url => 'http://route.c... | true |
19962af63f7de2d4ff199beaf1914d0d7f9d264a | Ruby | johanek/puppet-parse | /lib/vendor/puppet/provider/package/pkg.rb | UTF-8 | 2,694 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'puppet/provider/package'
Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package do
desc "OpenSolaris image packaging system. See pkg(5) for more information"
commands :pkg => "/usr/bin/pkg"
confine :operatingsystem => :solaris
#defaultfor [:operatingsystem => :solaris, :kern... | true |
0b9594510d2152db15f49b39cc7a6404a44899d2 | Ruby | daimyo-college/ruby-super-intro-lesson | /yazawa8/chapter2/2-1.rb | UTF-8 | 36 | 2.75 | 3 | [] | no_license | #puts 2+3
puts 2*3
puts 2*2*3.14
| true |
a0034bf8cdd0d9ba7088c852ba1c4f967655630f | Ruby | stefania11/chicken_Ser | /03_module_mixins.rb | UTF-8 | 2,176 | 2.921875 | 3 | [] | no_license | #===
module Drivable
def go!
"Vroom!"
end
end
class Car
include Drivable
end
honda = Car.new
honda.go! # => "Vroom!"
#===
Object.send(:remove_const, :Drivable)
Object.send(:remove_const, :Car)
module Drivable
def go!
"Vroom!"
end
end
class Car
include Drivable
def go!
"Screeeeetch!"
end
... | true |
221a7a27749d4e5775628d837cb0e038b59a97f0 | Ruby | necrio/cartoon-collections-online-web-sp-000 | /cartoon_collections.rb | UTF-8 | 635 | 3.5 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)
i = 0
while i < dwarves.length
puts "#{i + 1}. #{dwarves[i]}"
i += 1
end
end
def summon_captain_planet(sum)
sum_array = []
i = 0
while i < sum.length
sum_array << sum[i].capitalize + "!"
i += 1
end
sum_array
end
def long_planetee... | true |
8007ca17f6a73e37d1d248ddb7f038bb82fe1215 | Ruby | yifeih/blackjack | /hand.rb | UTF-8 | 3,336 | 3.921875 | 4 | [] | no_license | # Author: Yifei Huang
# Date: Nov 11, 2013
#
# This file specifies information about a Hand. A hand contains an array
# of cards.
# Both DealerHand and PlayerHand extend Hand.
require 'deck'
require 'card'
require 'set'
require 'utilities'
# A hand contains an array of Cards, which belong to the hand, and an
# in... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.