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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5e34355e511fb263d8dfcd248275192c80dbba93 | Ruby | fcoury/gmail_sender | /lib/gmail_sender.rb | UTF-8 | 647 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "tls_smtp_patch"
module Gmail
class Emailer
def initialize(user, password, domain="gmail.com")
@domain = domain
@password = password
@user = "#{user}@#{domain}"
@net_smtp = Net::SMTP.new("smtp.gmail.com", 587)
@net_smtp.enable_starttls
end
def send(to, subjec... | true |
35031dd6e0fab0921bbed81804a84790a8bad706 | Ruby | davehenton/mushroom-observer | /app/classes/api/time_range.rb | UTF-8 | 2,159 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
class API
# Parses and returns ranges of dates
class TimeRange
PARSERS = [:second_range, :minute_range, :hour_range,
:seconds, :minutes, :hours]
def self.parse(str)
PARSERS.each do |parser|
match = send(parser, str)
return match if match
end
... | true |
da4aca1800bab5b63de06d6cefd399d5f2c79a71 | Ruby | G-Wizz/Introduction-to-Programming | /age.rb | UTF-8 | 479 | 4.09375 | 4 | [] | no_license | # Exercise 2
puts "How old are you?"
age = gets.chomp.to_i
puts "In 10 years you will be:"
puts age + 10
puts "In 20 years you will be:"
puts age + 20
puts "In 30 years you will be:"
puts age + 30
puts "In 40 years you will be:"
puts age + 40
# or......
puts "How old are you?"
age = gets.chomp.to_i
puts "In 10 ... | true |
6ce2efaa96cde90cf0352ce96231a069193ab57b | Ruby | nusmodifications/nusbot | /lib/db/vams.rb | UTF-8 | 1,090 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'redis'
require 'yaml'
module NUSBotgram
class VAMS
# Configuration
CONFIG = YAML.load_file("../config/config.yml")
location_codes = File.readlines("locations.txt").map(&:strip)
location_names = File.readlines("location_names.txt").map(&:strip)
lat = /\lat\=(\d.\d+)/
... | true |
ab1b7110822762b92e4487541d45ee3ce55df3d0 | Ruby | autosome-ru/motif_benchmarks | /motif_pseudo_roc/motif_preprocessing.rb | UTF-8 | 4,952 | 2.953125 | 3 | [
"MIT"
] | permissive | require_relative 'utils'
def read_matrix(fn, num_columns: 4)
lines = File.readlines(fn).map(&:chomp)
rows = lines.map{|l| l.split }
name = File.basename(fn, File.extname(fn))
unless (rows[0].size == num_columns) && rows[0].all?{|x| Float(x, exception: false) }
hdr = lines.first
rows.shift
name = hd... | true |
403613b5b1b269df90ae02049c3584dfa9c253f8 | Ruby | waxxio/waxx | /lib/waxx/irb_env.rb | UTF-8 | 661 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | # Waxx Copyright (c) 2016 ePark labs Inc. & Daniel J. Fitzpatrick <dan@eparklabs.com> All rights reserved.
# Released under the Apache Version 2 License. See LICENSE.txt.
extend Waxx::Console
puts "Welcome to Waxx"
puts "See waxx.io for more info"
puts ""
puts "HTTP Methods with URI: "
puts " get '/app/env'"
puts " ... | true |
0b5fbfa0ccf6c16b3fc7e575b751b7489aa4caed | Ruby | ball-hayden/uk_account_validator | /lib/uk_account_validator/exceptions/exception_12.rb | UTF-8 | 353 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | # These are for Nationwide Flex accounts. Where there is a 12 in the exception
# column for the first check for a sorting code and a 13 in the exception column
# for the second check for the same sorting code, if either check is successful
# the account number is deemed valid.
class Exception12 < BaseException
def se... | true |
1f2194632de7d10bdaa194daaec528f49e71116a | Ruby | thedanielhanke/char_test | /char_test.rb | UTF-8 | 3,127 | 2.953125 | 3 | [] | no_license | # Test various strategies for dealing with uploaded files of unknown encoding
# and transcoding to UTF-8
require 'rubygems'
require 'charlock_holmes' # https://github.com/brianmario/charlock_holmes
require 'rchardet19' # https://github.com/oleander/rchardet
require 'ensure/encoding' # https://github.com/Manfred/E... | true |
66b4f3420988f32e53f789ab98dd217aa4eb1dd1 | Ruby | lucasgomide/manager-stores | /app/models/validators/multi_polygon_validator.rb | UTF-8 | 591 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
module Validators
class MultiPolygonValidator
include Validator
def initialize(multipolygon, geometry_validator = Geometry::Validator)
@multipolygon = multipolygon
@geometry_validator = geometry_validator
end
def valid?
validate
errors.empty?
... | true |
ea981c9d32a79a505115db4ebfa7d1d9cdbd9693 | Ruby | casper22875/TDD_GreeneCounty_Kata | /GC_kata_test.rb | UTF-8 | 1,105 | 3.1875 | 3 | [] | no_license | require_relative "GC_kata.rb"
require "minitest/autorun"
class GC_kata_test < Minitest::Test
def test_create_array_with_100_elements
results = greene_county
assert_equal(100, results.length)
end
def test_first_element_in_array_is_1
results = greene_county
assert_equal(1, results[0])
end
def test_second_element_... | true |
a5b7e36493c7bfeca4a388436f6d1da4157fc699 | Ruby | valayvaidya28/WebScraping | /webscraping.rb | UTF-8 | 349 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = "http://teamtreehouse.com/library"
doc = Nokogiri::HTML(open(url))
#puts doc.at_css("title").text
title_ = nil
description = nil
doc.css(".title").each do |title|
title_ = title.at_css("h3").text
description = title.at_css(".description").text
puts "#{t... | true |
94037a79fe2e3595c621acc07c5b4687b7a2b0ee | Ruby | jmks/typespeed-ruby | /lib/word.rb | UTF-8 | 1,099 | 3.296875 | 3 | [
"MIT"
] | permissive | class Word
DEFAULT_SPEED = 0.06 # 600 px / 10 s
DEFAULT_X = 0
attr_reader :value, :speed, :game
def initialize(word, y, game, x: DEFAULT_X, speed: DEFAULT_SPEED)
@value = word
@x = x
@y = y
@game = game
@max_x = game.width
@speed = speed
@color = Gosu::Color::GREEN
@user_entere... | true |
1ae8d38143d961d6f7d4de99125ebad4269f7794 | Ruby | dsadaka/stats | /test/models/batting_test.rb | UTF-8 | 1,924 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class BattingTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test 'First playerID is aardsda01' do
m = Batting.first
assert_equal(m.playerID, 'aardsda01', 'ID didn\'t match')
end
test 'Last playerID is zumayjo01' do
m = Batting.last
assert_... | true |
dc5f3fe11f816b042869ddbb6a3ea66bcbce9598 | Ruby | letsbreelhere/asplode | /lib/asteroid_methods.rb | UTF-8 | 1,072 | 2.75 | 3 | [] | no_license | module AsteroidMethods
def setup_asteroids
@asteroids = []
NUM_ASTEROIDS.times do
add_rand_asteroid(ASTEROID_RADIUS)
end
end
def add_rand_asteroid(radius, pos = nil)
asteroid = Asteroid.generate(radius,
ASTEROID_VERTICES, ASTEROID_MASS)
add_asteroid(ast... | true |
1417aedb07d71e7ab062c60db8bd3c557f9f6d7b | Ruby | AlexFr28/biathlon | /app/models/event.rb | UTF-8 | 883 | 2.65625 | 3 | [] | no_license | class Event < ApplicationRecord
enum format: [:individual, :sprint, :pursuit, :mass_start, :relay, :mixed_relay, :single_mixed_relay]
enum gender: [:masculine, :female, :mixed]
belongs_to :stage
def humanize
case format.to_sym
when :individual
"individuel #{humanize_gender}"
when :sprint
... | true |
e20ce3e5a00f044501ce3acf58948866f53872dd | Ruby | AnkurGel/Backup | /Project_Euler/48.rb | UTF-8 | 130 | 3.015625 | 3 | [] | no_license | s=0
(1..1000).each { |value| s+=value**value }
puts s; puts "Last ten digits: #{s.to_s.reverse.split(//).first(10).reverse.join}"
| true |
99b907495d8c41c3859e07ade01995d0ca249954 | Ruby | alex-solo/ruby-problems | /weekly-challenges/greatest_common_dividor.rb | UTF-8 | 580 | 4.28125 | 4 | [] | no_license | # # build a method that will return a greatest common dividor given two numbers as input
# iterate though all numbers until the smaller of the two numbers
# -smallest num?
# => smaller = num1 < num2 ? num1 : num2
# add dividor to results array if num1 % i == 0 && num2 % i == 0
# return arr.last
def common_divid... | true |
392d148f735db6d277928b4603828664fdcfc5b6 | Ruby | ManageIQ/manageiq-performance | /lib/manageiq_performance/commands/help.rb | UTF-8 | 1,097 | 2.5625 | 3 | [] | no_license | module ManageIQPerformance
module Commands
class Help
def self.help
help_text = ["Usage: #{File.basename $0} [options] args...", ""]
command_files = Dir["#{File.dirname __FILE__}/*"].sort
ljust_length = command_files.map {|f| File.basename(f).length}.max
command_files.each ... | true |
d79db45f539feebc0ff3b12c11577d12507269d8 | Ruby | cklim83/launch_school | /03_rb120_oop/lesson_02_oop/04_inheritance_exercises/07_method_lookup_1.rb | UTF-8 | 1,459 | 4.0625 | 4 | [] | no_license | =begin
Using the following code, determine the lookup path used when
invoking cat1.color. Only list the classes that were checked
by Ruby when searching for the #color method.
class Animal
attr_reader :color
def initialize(color)
@color = color
end
end
class Cat < Animal
end
class Bird < Animal
end
cat1 ... | true |
5e8975a86ffc2346fcf1b0d49d887c4af9cf1d4e | Ruby | Zimmja/Makers-challenge-Oystercard | /lib/journey.rb | UTF-8 | 447 | 3.4375 | 3 | [] | no_license | class Journey
attr_reader :entry_station, :exit_station
MIN_FARE = 1
PENALTY_FARE = 6
def initialize(entry_station = nil, exit_station = nil)
@entry_station = entry_station
@exit_station = exit_station
end
def fare
journey_completed? ? MIN_FARE : PENALTY_FARE
end
def finish(exit_station)... | true |
fd976f01307d514bedbf2874b4dd6fd34823b473 | Ruby | m00zh33/sqli-hunter | /lib/hunter.rb | UTF-8 | 709 | 2.75 | 3 | [] | no_license | module Hunter
extend self
VERSION = '0.2'
REQUESTS = Queue.new
TASKS = []
MUTEX = Mutex.new
# Define colors
def self.colorize(text, color_code)
if $COLORSWITCH
"#{text}"
else
"\e[#{color_code}m#{text}\e[0m"
end
end
def self.bold(text)
colorize(text, 1)
end
def se... | true |
c02a1faa5fd9ba5b7c6d6193b29fc4de42f6b37e | Ruby | cbow27/lsrubybk | /Hashes/5.rb | UTF-8 | 134 | 2.671875 | 3 | [] | no_license | person = {name: 'Bob', occupation: 'web developer', hobbies: 'painting'}
puts person.include?(:hobbies)
puts person.include?(:height) | true |
d22818b9de9b2df788abfbd28d2c409f18b48a6e | Ruby | kennyfrc/webframework-lite | /lib/framework.rb | UTF-8 | 2,320 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
# Framework stuff
class App
# Defines the routes defined when you do App.new do...end
def initialize(&block)
@routes = RouteTable.new(block)
end
# env = a hash of various keys containing
# info about the incoming HTTP request
def call(env)
# Rack::Request provides con... | true |
bc63407c41f11ac141a0208b436164772088f999 | Ruby | DMBelisle1990/chess | /board.rb | UTF-8 | 10,008 | 3.515625 | 4 | [] | no_license | require_relative 'piece.rb'
class NilClass
def [](input)
nil
end
def disp
nil
end
def rank
nil
end
def team
nil
end
def to_sym
nil
end
end
#--------TO DO STILL--------
#2. en passant
#1. saving
#3. need to end game when stalemate occurs
#---------------------------
class Board
... | true |
7c22f45add561e7e8a91e559070902975d778b76 | Ruby | twp88/o_b | /lib/tasks/update_db.rake | UTF-8 | 1,933 | 2.921875 | 3 | [] | no_license | require 'yaml'
namespace :update_db do
desc 'Updates the db with all of the new articles written'
task add_articles: :environment do
path = File.join(Rails.root, 'articles.yml')
if File.exist?(path)
file = File.open(path)
data = YAML.safe_load(file)
add_articles(data)
else
puts... | true |
3a84868d3656d56b4b92e0aeab33868502b12768 | Ruby | remi-www/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 1,278 | 2.765625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
c1d439cb48b6126266e91ce7137bcbd32654aff2 | Ruby | Aerilius/SketchUp-Ruby-API-Doc | /lib/color.rb | UTF-8 | 4,024 | 3.5625 | 4 | [] | no_license | module Sketchup
class Color
# Creates a new color object.
# @overload initialize()
# Creates a color initialized with 0 (black, opaque).
# @overload initialize(red, green, blue, alpha=255)
# Creates a color from color components.
# If a given component is an integer, it will be interpre... | true |
738f3cb1aef931bfaf23716535f505d06c86d7ee | Ruby | kowalix-pl/programming-univbasics-3-build-a-calculator-lab-online-web-prework | /lib/math.rb | UTF-8 | 318 | 3 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
addition = num2+num1
end
def subtraction(num1, num2)
substraction = num1-num2
end
def division(num1, num2)
division = num1/num2
end
def multiplication(num1, num2)
multiplication=num1*num2
end
def modulo(num1, num2)
modulo = num1.modulo num2
end
def square_root(num)
Math.sqrt(num)
end
| true |
34173742f455982b1df51fc63ad8809b9b627841 | Ruby | jnanavibasavaraj/Ruby | /ruby/ruby/string.rb | UTF-8 | 72 | 2.984375 | 3 | [] | no_license |
def FirstReverse(string)
string.reverse
end
puts FirstReverse("meg") | true |
583b146effb909be48ddd9480910ed85fe483bca | Ruby | hookbil/ruby_learning | /lesson_8/menu.rb | UTF-8 | 9,660 | 3.546875 | 4 | [] | no_license | class Menu
attr_accessor :stations, :routes, :trains
def initialize
@stations = []
@routes = []
@trains = []
@wagons = []
end
def add_station
puts 'Введите название станции(больше двух символов): '
station_name = gets.chomp.capitalize
begin
station = Station.new(station_name)... | true |
1d6ddd68b42c7e98a164aa0b9cb39528937b2ddf | Ruby | nancylee713/mod_1_enigma | /test/offset_test.rb | UTF-8 | 716 | 2.65625 | 3 | [] | no_license | require './test/test_helper'
class OffsetTest < Minitest::Test
def test_it_exists
offset = Offset.new("260719")
assert_instance_of Offset, offset
end
def test_attributes
offset = Offset.new("260719")
assert_equal "260719", offset.date
assert_equal 6, offset.date.length
end
def test_de... | true |
c20b6e1daad3afd69c17b99640332f526e660738 | Ruby | rajul/ElJudge | /027-OddNumber/odd.rb | UTF-8 | 168 | 3.125 | 3 | [] | no_license | n = gets.chomp.to_i
t = gets.chomp.split(' ').map{|e| e.to_i}
t = t.sort
i = 0
while i < n do
if i == n-1 or t[i] != t[i+1]
break
end
i = i + 2
end
puts t[i]
| true |
d6ee685fcb29bd88cc0a19143ad344444c812779 | Ruby | SAMTHP/recipe_scraper | /lib/recipe_scraper.rb | UTF-8 | 5,956 | 3.234375 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'json'
require 'open-uri'
require 'nokogiri'
require "recipe_scraper/version"
module RecipeScraper
# represent a recipe fetched from an Url
class Recipe
attr_reader :title, :preptime, :cooktime , :ingredients, :steps, :image
MARMITON_HOST = {desktop: 'http://www.marmiton.org/... | true |
eb86f4a76cdb8ceb5bb388e0d8270fa994e2fb1c | Ruby | amjad-sahi/Aspose.Cells-for-Cloud | /Examples/Ruby/Workbook/convert_document_and_save_result_to_storage.rb | UTF-8 | 962 | 2.78125 | 3 | [
"MIT"
] | permissive | #ExStart:
require 'aspose_cells_cloud'
class Workbook
include AsposeCellsCloud
include AsposeStorageCloud
def initialize
#Get App key and App SID from https://cloud.aspose.com
AsposeApp.app_key_and_sid("APP_KEY", "APP_SID")
@cells_api = CellsApi.new
end
def upload_file(file_name)
@storag... | true |
029b68c0325b97d9701d6b1a6ff43f06a5718bf6 | Ruby | headexplodes/http-stub-server | /clients/ruby/http_support.rb | UTF-8 | 1,902 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | require 'uri'
require 'httpclient'
module HttpSupport
attr_accessor :response
def http_client
@http_client ||= HTTPClient.new
end
def within_base_uri(uri)
yield (@base_url && !(uri =~ /#{@base_url}/) ? File.join(@base_url, uri) : uri)
end
def with_oauth_access_token
@append_oauth2_access_t... | true |
2803f875f689a5f04ec1287e450925bbedafa1d1 | Ruby | brilatimer/hotel | /lib/reservation.rb | UTF-8 | 391 | 3.25 | 3 | [] | no_license | class Reservation
attr_reader :date_range, :room_number
RATE = 200 # this can be adjusted in the future
def initialize(date_range:, room_number:)
@date_range = date_range
@room_number = room_number
end
def total_cost
total_cost = (@date_range.nights_booked) * (RATE) # calculate number of nig... | true |
9a49b1a3ddd2ab5dfd82840d9412a6796153f617 | Ruby | meara/green_glass_door | /app/models/offering.rb | UTF-8 | 142 | 2.921875 | 3 | [] | no_license | class Offering
attr_reader :name
def initialize(name)
@name = name
end
def pleasing?
!!name.match(/([a-z])\1/)
end
end
| true |
35fd25a95c798bf78bf0370e18d292e0877a1e52 | Ruby | orrybaram/tag | /app/models/pe_class.rb | UTF-8 | 676 | 2.671875 | 3 | [] | no_license | class PeClass < ActiveRecord::Base
# attr_accessible
attr_accessible :datetime, :school_id, :teacher_id, :name
# dependencies
has_many :pe_classmembers
has_many :users
belongs_to :school
belongs_to :teacher
# functions
# find_news
# INPUT: user_id (value)
# OUTPUT: activities (Music.object... | true |
35ce5cde61c733e408ccd379eedcf9fe755e739e | Ruby | kbelezhkova/first_program | /first_program.rb | UTF-8 | 321 | 4.09375 | 4 | [] | no_license | puts "What is your name?"
name = gets.chomp.upcase
puts "How old are your?"
age = gets.chomp.to_i
if age <= 25
puts "You are very young!"
else
puts "You look younger!"
end
puts "Where do you go to school?"
school =gets.chomp.upcase
puts "So your name is #{name}, you are #{age} years old and you go to #{school}!"
... | true |
0a3c369f8a2e85c8928e7e92db4be3eb49f691b4 | Ruby | benkitzelman/whizz_kid | /lib/whizz_kid/team_score.rb | UTF-8 | 820 | 3.234375 | 3 | [] | no_license | module WhizzKid
class TeamScore
attr_reader :team, :player_scores
def initialize team
@team = team
@player_scores = []
end
def total
player_scores.reduce(0) {|total_score, player| total_score + player[:score] }
end
def total_score_for player
player_scores.se... | true |
7c147c59e9caf283b3e78ee8625c044366641260 | Ruby | maxwellbenton/youtube-caption-scrapper | /test.rb | UTF-8 | 4,049 | 2.671875 | 3 | [] | no_license | 00:00
hi let's talk about validating our HTML
00:03
code so let's say that I was kind of
00:07
writing this in a hurry and will say
00:09
that I forgot to put this greater than
00:12
symbol here after the P tag so I have a
00:15
malformed opening P tag here okay so no
00:21
sweat what i can do is i can always
00:23
che... | true |
9de1605a732a37220ca6f40da68724f017c678d9 | Ruby | chaimoosh/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 445 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist
def initialize(name)
@name = name
end
def self.new_by_filename(file)
#binding.pry
song = file.split(" - ")[1]
new_song = self.new(song)
new_artist = file.split(" - ")[0]
new_song.artist = Artist.find_or_create_by_name(new_artist)
new... | true |
915ed338a9f6506f5b4b92479ee1f6e56ec5b17a | Ruby | rud/amrita | /sample/tour/filelist.rb | UTF-8 | 1,178 | 2.796875 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive |
# amrita can use an existing class for model data.
# To show this ability, this sample uses Ruby's system class
# File::Stat.
require "amrita/template"
include Amrita
class File
class Stat
include Amrita::ExpandByMember
def entry(name)
a(:name=>name, :type=>ftype) { self }
end
def size_or_... | true |
b2034e4a6331ad2774a27739da736c4f3883073e | Ruby | rynehx/crypto-challenges | /bases/base_module.rb | UTF-8 | 946 | 3 | 3 | [] | no_license | module BaseConvertable
module ClassMethods
def char(num)
dict[num]
end
def num_from_char(char)
reverse_dict[char]
end
end
def self.included(klass)
klass.extend(ClassMethods)
end
def to_hex
to_i.to_hex
end
def to_b64
to_i.to_b64
end
def ==(other)
other.i... | true |
603c82eb27787140376c4145cbd749a4972de5fb | Ruby | marth00165/prime-ruby-seattle-web-060319 | /prime.rb | UTF-8 | 125 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(jawn)
if jawn >= 2
(2.. (jawn - 1)).all? do |x|
jawn % x != 0
end
else
return false
end
end
| true |
a0c983f8071211c1d10a0d349d0e51d2bef5474d | Ruby | baluku2000/bowlings | /app/controllers/bowlgames_controller.rb | UTF-8 | 8,935 | 2.78125 | 3 | [] | no_license | class BowlgamesController < ApplicationController
STRIKE = 10
def new
end
def create
begin
@input_frames = JSON.parse params[:frames]
rescue JSON::ParserError => e
# e.g. [2,]
log_error_and_render "Invalid Input Frames" and return
end
@errmsg = ""
unless va... | true |
cb02549ff0b52a3ac0247d7e4538bfbd41209f2e | Ruby | theCrab/mbj-mapper | /spike.rb | UTF-8 | 579 | 2.59375 | 3 | [] | no_license | #encoding: utf-8
$: << 'lib'
require 'mapper'
class Person
include Virtus
attribute :id, Integer
attribute :firstname, String
attribute :lastname, String
end
header = Veritas::Relation::Header.coerce([[:id, Integer], [:firstname, String], [:lastname, String]], :keys => [:id])
transformer = Mapper::Transfor... | true |
0fe65feffd206d2ccfd66a7b828dea59ffc3e0db | Ruby | flaggskeppet/ruby-labs | /code_that_writes_code/checked_attributes/v1/checked_attributes.rb | UTF-8 | 488 | 3.015625 | 3 | [] | no_license | # Create Mimic methods using Lines of code that are evaluated.
# Cons:
# Everything gets evaluated at once
# Hard to write
# Hard to test small parts
# Hard to find errors
# No support by IDE
def add_checked_attribute(clazz, attribute)
eval <<END
class #{clazz}
def #{attribute}=(value... | true |
de7aeddf42f5ed9b09d65e78de77a78205ad78a2 | Ruby | gellieb/workspace | /app_academy/prep-work1/coding-test-2/test_2/max_sum.rb | UTF-8 | 1,828 | 4 | 4 | [] | no_license | # corgi_golden_age
# Each year, the Census Bureau records the change in the population of Welsh corgis. In year zero, if 10 corgis are born and 5 die (sad!), there are 5 more corgis. In year one, if 10 corgis are born and 13 die, there are 3 fewer corgis. An array of changes in corgi populations would look like [5, -3,... | true |
75af764dea9c119b7ac64c027916826737642f44 | Ruby | twhitinger/sorting_suite | /test/merge_sort_test.rb | UTF-8 | 1,390 | 3.40625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry'
require_relative '../lib/merge_sort'
class MergeTest < Minitest::Test
def test_merge_sort_letters
sorter = MergeSort.new
sorted_array = sorter.merge_sort(["d", "b", "a", "c"])
assert_equal ["a", "b","c","d"], sorted_array
end
def tes... | true |
2b8045744d09053e269a83d3a62970684f86b129 | Ruby | rgolangh/trello-util | /src/trello_util.rb | UTF-8 | 972 | 2.859375 | 3 | [] | no_license | require 'trello'
class TrelloUtil
def initialize(board_id, api_key, member_token)
Trello.configure do |config|
config.developer_public_key = api_key # The "key" from step 1
config.member_token = member_token # The token from step 3.
end
@board = Trello::Board.find(board_id)
end
def list... | true |
5c4595bd9727c10d5cde316264ec722f659f9f20 | Ruby | kevincon/kevintechnology.com | /_plugins/video_tag.rb | UTF-8 | 2,709 | 2.578125 | 3 | [] | no_license | # Syntax {% video /path/to/video.mp4 %}
#
# Example:
# {% video /uploads/test.mp4 %}
#
# If a JPEG or PNG image with the same base name exists in the same folder,
# it will be used as the poster image. If not, and ImageMagick's convert command is
# available, a JPEG will be created from the first frame.
#
# To provide ... | true |
0c6a27903f12332cd37b1c7f4c501c5ebe7b56f6 | Ruby | uwcirg/tb-foundation | /app/lib/push_notification_sender.rb | UTF-8 | 1,571 | 2.59375 | 3 | [] | no_license | require "webpush"
class PushNotificationSender
# Allow calling the send method without creating a new object - more information https://www.toptal.com/ruby-on-rails/rails-service-objects-tutorial
def self.send(*args, &block)
new(*args, &block).send
end
def initialize(user, title, body, app_url, type, act... | true |
095722163be5b7dfb6a5f041ef1b097da29dd876 | Ruby | maroro0220/rails_crud | /app/controllers/post_controller.rb | UTF-8 | 733 | 2.640625 | 3 | [] | no_license | class PostController < ApplicationController
def index
@posts = Post.all
end
def new
# form에서 글쓰는 창이니까, 아무것도 없다.
end
def create
# params[:username] params[:title] params[:content]
# 1번 방법
Post.create(:username => params[:username],
:title => params[:title],
:... | true |
a4bced97037c5c8cb5f1422498d7826a1a209d54 | Ruby | qinjin-izettle/hotspots | /lib/bugspots/scanner.rb | UTF-8 | 1,962 | 2.78125 | 3 | [
"MIT"
] | permissive | require "rugged"
module Bugspots
Fix = Struct.new(:message, :date, :files, :hash)
Spot = Struct.new(:file, :score)
def self.scan(repo, branch = "master", depth = 5, regex = nil)
regex ||= /\b(fix(es|ed)?|close(s|d)?)\b/i
fixes = []
repo = Rugged::Repository.new(repo)
unless repo.branches.each_n... | true |
5e7d5269088383dbb46b6ca69cd6d704d69e2bde | Ruby | ellehallal/LRTHW | /ex16_1.rb | UTF-8 | 151 | 3.09375 | 3 | [] | no_license | filename = ARGV.first
openfile = open(filename, 'w')
puts "Add your new text: "
newtext = $stdin.gets.chomp
openfile.write(newtext)
openfile.close
| true |
a4602b93f3dc2817d6cf2ba042d6229ee40ac8b6 | Ruby | RootSeven/imdb_lab | /start_code/console.rb | UTF-8 | 1,508 | 2.671875 | 3 | [] | no_license | require('pg')
require('pry')
require_relative('models/star.rb')
require_relative('models/movie.rb')
require_relative('models/casting.rb')
require_relative('db/sql_runner.rb')
Casting.delete_all
Star.delete_all
Movie.delete_all
star1 = Star.new( {'first_name' => 'Will',
'last_name' => 'Powers'} )
sta... | true |
dd05b8f4403030c722bb149978e30901160ce4a3 | Ruby | Benoitlecorre/promo-2-challenges | /01-Ruby/06-Parsing/02-Numbers-and-Letters/lib/longest_word.rb | UTF-8 | 254 | 2.6875 | 3 | [] | no_license | require 'open-uri'
require 'json'
def generate_grid(grid_size)
#TODO: generate random grid of letters
('a'..'z').to_a[0..grid_size]
end
def run_game(attempt, grid, start_time, end_time)
#TODO: runs the game and return detailed hash of result
end
| true |
299e542c5ba6c84e01f8fc3902f5138f2b6174d5 | Ruby | wildfauve/oauth_test_client | /app/lib/cache_wrapper.rb | UTF-8 | 3,190 | 3.171875 | 3 | [] | no_license | class CacheWrapper
LOG_HITS = false
# Wraps any in-memory Cache class (typically a Singleton), providing cache operations
# such as expiry and refresh.
# Usage:
# > IC['util.cache'].init(IC['kms.key_cache'], "signature key")
#
#
class << self
# Initialises the cache
# @param cache [Class] ... | true |
e48eabaae48f6dbf8a55eae636a2f6b54b7cb7df | Ruby | jakebrady5/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 423 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
current_low = Float::INFINITY
name_hash.each{|a, b|
if b < current_low
current_low = b
end
}
#makes much more sense to use this function tha... | true |
8092d47b5c51ade0586cee9e6740264bebfdaad8 | Ruby | jaymuk/ruby-kickstart | /session2/3-challenge/3_array.rb | UTF-8 | 362 | 3.96875 | 4 | [
"MIT"
] | permissive | # Write a method named every_other_char for strings that,
# returns an array containing every other character
#
# example:
# "abcdefg".every_other_char # => "aceg"
# "".every_other_char # => ""
class String
def every_other_char
other_chars = ""
each_char.with_index {|char, index| other_chars << char ... | true |
bb6dd65dd2bb9a2b775f1730ac4114c8cfe620a0 | Ruby | zben/talent-search | /public/system/downloads/4fc3be829ef3400dac00008f/original/test.rb | UTF-8 | 147 | 2.796875 | 3 | [] | no_license | class Task
attr_accessor :name, :parent
def initialize(name)
@name = name @parent = nil
end
def get_time_required
0.0
end
end
| true |
4147928f689d8229f148e2f0e30092e3dbd130ea | Ruby | nirav99/Illumina-Pipeline-V2 | /cleaners/FindFCForCleaning.rb | UTF-8 | 3,086 | 2.890625 | 3 | [] | no_license | #!/usr/bin/ruby
$:.unshift File.join(File.dirname(__FILE__), ".", "..", "lib")
class FindFCForCleaning
def initialize(baseDir)
initializeMembers()
buildInstrumentList(baseDir)
@instrList.each do |instrName|
puts "Checking for new flowcells for sequencer : " + instrName.to_s
@instrDir = bas... | true |
22a6cbd603dd1251884812d2003f3b68a9ff3fe3 | Ruby | leotangram/Ruby | /Ruby_Prework/generation_method.rb | UTF-8 | 570 | 3.46875 | 3 | [] | no_license | def generation(year_of_birth)
if year_of_birth >= 1996
:centenial
elsif year_of_birth >= 1977
:millenial
elsif year_of_birth >= 1965
generación_x
elsif year_of_birth >= 1946
:baby_boomer
else
:tradicionalista
end
end
translations = { centenial: "centenial", millenial: "millenial", generation_x: "X", ba... | true |
c4b614bca5be1a2144ecc3c6112cf51fedbeb263 | Ruby | AlanQuatermain/dndxml-ruby | /test/test_spells.rb | UTF-8 | 3,759 | 3 | 3 | [
"BSD-3-Clause"
] | permissive | require File.join(File.dirname(__FILE__), 'helper')
class TestSpells < Test::Unit::TestCase
def read_simple_spell
read_xml_file fixture_path('simple-spell.dnd')
end
def read_double_spell
read_xml_file fixture_path('two-spells.dnd')
end
def read_ritual_spell
read_xml_file fixture_path('ritual-spell.dnd... | true |
f6cf7590a980f21101a3a43ad81538a0f03ce911 | Ruby | Catsquotl/code2rubylearning | /lib/code2rubylearning/reformat.rb | UTF-8 | 274 | 2.703125 | 3 | [
"MIT"
] | permissive | class Reformat
def initialize file_name
file = File.open(file_name,"r") do |txt|
@file_text = txt.read
end
@file_text.gsub!('<' ,'<')
@ref_file = "[code ruby]\n" << @file_text << '[/code]'
end
end
r = Reformat.new('./again.rb')
puts r.ref_file
| true |
b6e7d28d5d7c018b58134b1e6abf59a79742cb60 | Ruby | mendelcohen/practice-ruby | /hashes.rb | UTF-8 | 2,870 | 3.578125 | 4 | [] | no_license | # 1. Make a hash to store a person's first name, last name, and email address. Then print each attribute on separate lines.
info = {}
info["first_name"] = "Mendy"
info["last_name"] = "Cohen"
info["email"] = "mendy@gmail.com"
puts info
puts info["first_name"]
puts info["last_name"]
puts info["email"]
# 2. Make an array... | true |
5fb825200a4c3bb794fa53a666837ae03dd84a12 | Ruby | griffifam/adagrams | /lib/adagrams.rb | UTF-8 | 8,113 | 3.453125 | 3 | [] | no_license | # # THIS PROGRAM WE WROTE PASSES 16/16 OF THE TESTS BUT DOES NOT FUNCTION PROPERLY IN THE TERMINAL. IF YOU UNCOMMENT LINE 61, THIS GAME RUNS PROPERLY IN THE TERMINAL BUT ONLY PASSES 15/16 TESTS.
#
# @words_created = []
# @final_winner = []
#
# @all_points = []
# in_progress = true
#
#
# while in_progress
# in_progres... | true |
a24487397dd0fd5dc77bcfcddf81504359d5e892 | Ruby | cohitre/hanlon | /lib/hanlon/methods_finder.rb | UTF-8 | 339 | 2.796875 | 3 | [] | no_license | module Hanlon
class MethodsFinder
def self.find engine
Hanlon::MethodsFinder.new(engine).methods
end
def initialize engine
@methods = []
@engine = engine
end
def hanlon name, &block
@methods.push name.to_s
end
def methods
@engine.render(self)
@methods... | true |
777586be92819a2759c4299a45b8f80b8d44691b | Ruby | raystation/SANDBOX | /#Ruby/book-in-stock.rb | UTF-8 | 140 | 3.421875 | 3 | [] | no_license |
class BookInStock
attr_reader :isbn
attr_accessor :price
def initialize(isbn, price)
@isbn = isbn
@price = Float(price)
end
end | true |
cb2e77a7ccef3c203c15be72f340dcc79edc0b46 | Ruby | s4ichi/steep | /test/signature_parsing_test.rb | UTF-8 | 6,191 | 2.859375 | 3 | [] | no_license | require "test_helper"
class SignatureParsingTest < Minitest::Test
include TestHelper
def parse(src)
Steep::Parser.parse_signature(src)
end
def test_parsing_class
klass, _ = parse(<<-EOS)
class C<'a> <: Object
include M1
extend M2
def itself: () -> instance
def class: () -> class
def self.g... | true |
8cfcbcfe48a6a1a2bc1af18d09a50d66e8503dd4 | Ruby | ICanDoAllThingThroughChrist/apples-and-holidays-v-000 | /lib/supplies.rb | UTF-8 | 2,868 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def all_supplies_in_holidays(holiday_hash)
# iterate through holiday_hash and print items such that your readout resembles:
holiday_hash.collect do|season,holidays|
puts "#{season}:".capitalize
holidays.each do |holidays,supplies|
#puts "#{holidays}:".capitalize
#print "#{supplies}"
#holidays_ar... | true |
c138a8196726fe8334cf751275ce33084e78ee3c | Ruby | thughes24/myflix2 | /spec/models/video_spec.rb | UTF-8 | 1,707 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
describe Video do
it "saves itself" do
video = Video.new(title: "monk", description: "good vid")
video.save
expect(Video.first.title).to eq("monk")
end
it { should belong_to(:category)}
it { should validate_presence_of(:title)}
it { should validate_presence_of(:description)}
describe... | true |
bc9d3ee7f13194e648a4431fc5732e6ef4575f71 | Ruby | drstonebraker/daily-projects | /w7d5/bench_bnb/w2d1/chess/pieces/piece.rb | UTF-8 | 233 | 3.140625 | 3 | [] | no_license | class Piece
attr_reader :player
def initialize(board, player, pos)
@board = board
@player = player
@position = pos
end
def valid_move?(pos)
true
end
def update_pos(pos)
@position = pos
end
end
| true |
e47a20993fda15ecbed2989442be28742a7c4019 | Ruby | vertroa/IP-Parser | /pull_ip.rb | UTF-8 | 2,002 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'slop'
opts = Slop.parse do |o|
o.string '-f', '--file', 'input filename'
o.bool '-o', '--output', 'output results to terminal'
o.string '-w', '--write', 'write output to filename'
o.on '-h', '--help', 'display help' do
puts o
exit
end
end
def ip_parser... | true |
9df1fb1cb5e7c3d2e729fbb51c0c745db5aabf25 | Ruby | jsus/murdoc | /lib/murdoc/languages/base.rb | UTF-8 | 1,088 | 2.796875 | 3 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | module Murdoc
module Languages
# Base language module
#
# Any new language module should inherit from Base, redefine .extensions
# and .comment_symbols methods, if needed, and add itself to Languages.map
# map.
class Base
def self.applies_for?(filename)
if extensions.include?(Fil... | true |
eb5210d0c79a5c94f8e8e00cdd351bc899d8f14e | Ruby | joshkestenberg/test-first-ruby-ass | /04_pig_latin/pig-latin.rb | UTF-8 | 1,328 | 3.921875 | 4 | [] | no_license | require 'pry'
def translate(string)
letter_words = []
almost_final_word = ""
words = string.split
words.each do |word|
letters = word.split("")
letter_words << letters
end
letter_words.each do |word|
if start_with_vowel?(word)
almost_final_word = word.join("")
final_word = add_... | true |
8a9c4c8e14939a2e8333d366e14bd987a6985e95 | Ruby | sequra/nifval | /spec/nifval_spec.rb | UTF-8 | 1,877 | 2.90625 | 3 | [] | no_license | require 'nifval/nif'
describe Nifval::Nif do
def nif(string)
Nifval::Nif.new(string)
end
context "valid DNIs" do
it { nif("00000000T").should be_valid }
it { nif("00000000T").should be_valid_dni }
end
context "invalid DNIs" do
it { nif("12345678T").should_not be_valid }
it { nif("0xxxxx... | true |
a614617fe49185544d6156a3cff2c23e9ef7d68b | Ruby | ignat-z/diffy | /const_definition_finder.rb | UTF-8 | 1,323 | 2.828125 | 3 | [
"MIT"
] | permissive | require_relative './ruby_class'
class ConstDefinitionFinder
def initialize(full_const_name, scope)
@full_const_name = full_const_name
@scope = scope
end
def call
return if !full_const_name || !scope
result = full_const_name.split("::").inject([scope]) do |scopes, const_name|
constant = sco... | true |
26440150ee06f6518ea03ff849f5969c0c2c16ed | Ruby | learn-co-curriculum/books-with-nested-forms | /app/models/book.rb | UTF-8 | 273 | 2.53125 | 3 | [] | no_license | class Book < ApplicationRecord
has_many :book_genres
has_many :genres, through: :book_genres
def genre_attribute=(genre_attribute)
genre = Genre.find_or_create_by(title: genre_attribute[:title])
self.genres << genre if !self.genres.include?(genre)
end
end
| true |
367f2c97063dd1b71ef6bc4ab0303a43f163d79c | Ruby | thk12205/-Users-theodore-actualize-mini_capstone | /front-end-test.rb | UTF-8 | 527 | 2.640625 | 3 | [] | no_license | require 'http'
puts "Front End Test:"
puts "Urls test:"
=begin
Xget "/products" => "products#index"
X get "/products/:id" => "products#show"
post "/products" => "products#create"
patch "/products/:id" => "products#update"
=end
puts "Gets Products"
pp response = HTTP.get("http://localhost:3000/api/products").parse... | true |
39ca31fa6711b807a6142f453cdd055c44860a81 | Ruby | locphan2207/AA-AlphaCourse | /appacademy-online-rspec-1-7db389dec276/lib/02_calculator.rb | UTF-8 | 376 | 3.6875 | 4 | [] | no_license | def add(num1, num2)
num1 + num2
end
def subtract(num1, num2)
num1 - num2
end
def sum(array)
sum = 0
array.each {|num| sum += num}
sum
end
def multiply(array)
result = 1
array.each {|num| result *= num}
result
end
def power(num, pow)
num ** pow
end
def factorial(num)
return 1 if num < 2
result... | true |
318c79845ec1ee0c90224a233f0dc645ccc5e823 | Ruby | samsoir/jenkins-pullover | /lib/jenkins/model.rb | UTF-8 | 2,290 | 2.546875 | 3 | [] | no_license | # Jenkins Pullover Jenkins Model
# Author:: Sam de Freyssinet (sam@def.reyssi.net)
# Copyright:: Copyright (c) 2012 Sittercity, Inc. All Rights Reserved.
# License:: MIT License
#
# Copyright (c) 2012 Sittercity, Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this sof... | true |
c9d90e3e2e2e12d8d200fc5e217f579d5bd2832f | Ruby | steakunderscore/cheap-thrills | /spec/models/event_spec.rb | UTF-8 | 1,037 | 2.53125 | 3 | [] | no_license | require "rails_helper"
RSpec.describe Event, type: :model do
let(:event_tomorrow) { create(:event, starts_at: Time.zone.now + 1.day) }
let(:event_next_week) { create(:event, starts_at: Time.zone.now + 7.days) }
it { should belong_to(:venue) }
it { should have_many(:artist_events) }
it { should have_many(:ar... | true |
7189727b0105c1f8223fc37ef55c9227087eb621 | Ruby | erukiti/ruby-csv2mona | /spacer.rb | SHIFT_JIS | 2,538 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'jcode'
$KCODE = "SJIS"
def getwidth(str)
width = 0
str.each_char { |chr|
if chr.length == 1
a = $width[chr[0]]
elsif chr.length == 2
a = $width[(chr[0] << 8) + chr[1]]
else
error
end
width += a if a != nil
}
width
end
$width = {}
File... | true |
2c966cd456c0a252f9b661395b67faf30ca808d7 | Ruby | Murphydbuffalo/Learn_To_Program | /Ch9/survey.rb | UTF-8 | 355 | 3.453125 | 3 | [] | no_license | def ask topic
puts topic
while true
answer = gets.chomp.upcase
if answer == 'YES'
return true
elsif answer == 'NO'
return false
elsif answer != 'YES' || answer != 'NO'
puts 'Please answer using "Yes" or "No" only.'
end
end
result
end
puts ask 'Do you eat mushrooms?'
... | true |
ed1f8e8bdf4178a76ee3296fe78b691af77d9a45 | Ruby | shadabahmed/leetcode-problems | /partition-list.rb | UTF-8 | 820 | 3.484375 | 3 | [] | no_license | def swap_adjacent_nodes(first, mid, last)
first.next = last
mid.next = last.next
last.next = mid
end
def swap_nodes(left, right)
return if left == right
if left.next == right
swap_adjacent_nodes(left, right, right.next)
else
left.next, right.next = right.next, left.next
left.next.next, right.ne... | true |
d61745a19c68a01b23d2ae9be4b61494f13715a3 | Ruby | maximkoo/ruby-repo | /Tk/landscape/landscape2.rb | UTF-8 | 1,773 | 3.171875 | 3 | [] | no_license | require 'tk'
class Landscape
def initialize
@root1 = TkRoot.new {title "reDraw"; padx 10; pady 10;}
@cnv1=TkCanvas.new(@root1){background 'white'}.grid :sticky => 'nwes', :column => 0, :row => 0
@lbl1=TkLabel.new(@root1).grid :column => 0, :row => 1
@cnv1['height']=500;
@cnv1['width']=500;
@point... | true |
5aed6c7db603d80a465110da63dae730d0e877cc | Ruby | singhsankalp/Roman | /spec/roman_spec.rb | UTF-8 | 799 | 2.84375 | 3 | [] | no_license | require File.expand_path(File.join(File.dirname(__FILE__),'../src/roman.rb'))
describe Roman do
[
[ 1, 'I'],
[ 2, 'II'],
[ 3, 'III'],
[ 4, 'IV'],
[ 5, 'V'],
[ 6, 'VI'],
[ 7, 'VII'],
[ 8, 'VIII'],
[ 9, 'IX'],
[ 10, 'X'],
[ 11, 'XI'],
[ 12, 'XII'],
[ 13, 'XIII'],
... | true |
f3859c6520445e2bb1183f59c0f6b2b844d18a0a | Ruby | lukesherwood/oo-cash-register-online-web-sp-000 | /lib/cash_register.rb | UTF-8 | 607 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :discount, :total, :last_item
@@items = []
def initialize(discount = nil)
@total = 0
@discount = discount
@@items.clear
end
def add_item(title, price, quantity = 1)
@total += (price*quantity)
quantity.times{@@items << title}
@last_item = price*quantity
end
def apply_disc... | true |
2542f40c1b0382e8886c91a4690a772c521ab74b | Ruby | elauqsap/selt | /HW1/skeletons/part1.rb | UTF-8 | 821 | 4.40625 | 4 | [] | no_license | # Checks if the string passed to it is a palindrome
# by taking out everything but the characters of the
# string to compare it's reverse (case insensitive)
#
# @str String contains the palindrome in question
def palindrome?(str)
!!(str.gsub(/[^a-z]/i, "").casecmp(str.gsub(/[^a-z]/i, "").reverse) == 0)
end
# Converts... | true |
8ab0012068699028f1209dc3c37bf62d0a04d942 | Ruby | slim1979/tn2 | /lesson9/van/van.rb | UTF-8 | 307 | 2.515625 | 3 | [] | no_license | class Van
extend Accessors
include Manufacturer
include Validation
attr_accessor :number
attr_reader :type, :kind, :status
attr_writer :status
def initialize(number, kind, *, manufacturer)
@number = number
@kind = kind
@manufacturer = manufacturer
@status = 'free'
end
end
| true |
c9fbd49ba631bd23fc696624a1451fab002598ae | Ruby | jgrazulis/backend_mod_1_prework | /section2/exercises/ex19.rb | UTF-8 | 1,417 | 4.40625 | 4 | [] | no_license | #define the variable cheese_and_crackers by including the cheese_count and boxes_of_crackers variables
def cheese_and_crackers(cheese_count, boxes_of_crackers)
#print the string interpolations
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers} boxes of crackers!"
#print strings
puts ... | true |
3a4b87f5ecf178f39ec7ed8a62e99a979f921f8c | Ruby | 1Maria/currency | /currency.rb | UTF-8 | 834 | 3.734375 | 4 | [] | no_license | class Currency
attr_reader :amount, :currency_code
def initialize(amount, currency_code)
@amount = amount.to_f.round(2)
@currency_code = currency_code
end
def compare_currency_codes(other)
currency_code == other.currency_code
end
def ==(other)
@amount == other.amount && compare_currency_c... | true |
40abde9a2d5e98b4c10bccacde55a439c274318c | Ruby | lijiahao008/W4D1 | /routes_controllers_intro/bin/my_script.rb | UTF-8 | 843 | 2.875 | 3 | [] | no_license | require 'addressable/uri'
require 'rest-client'
# def index_users
# url = Addressable::URI.new(
# scheme: 'http',
# host: 'localhost',
# port: 3000,
# path: '/users'
# ).to_s
#
# puts RestClient.get(url)
# end
#
# index_users
#
# def create_user(name, email)
# url = Addressable:... | true |
f463f67c1bde40ba843b58583a1dfc3df8c8da55 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w02/d03/Mary/vending_machine/lib/sku.rb | UTF-8 | 411 | 3.421875 | 3 | [] | no_license | class Sku
#attr_reader builds getters for symbols that map to instance variables; attr_writer does the same for setters; attr_accessor builds both getters & setters
attr_accessor :code, :product, :price, :quantity
def initialize(code, product='', price=0, quantity=0)
@code = code
@product = product
@... | true |
440b484b1cbb45c8299f0f07e5c6a2ef62820a71 | Ruby | davidmann4/cloudxls-ruby | /examples/inline.rb | UTF-8 | 554 | 2.796875 | 3 | [
"MIT"
] | permissive | # ruby examples/inline.rb
#
# Use to directly download file.
require_relative '../lib/cloudxls'
unless ENV["CLOUDXLS_API_KEY"]
puts "--- WARNING ---"
puts "Please add environment variable CLOUDXLS_API_KEY"
puts "export CLOUDXLS_API_KEY=YOUR_API_KEY"
puts "---------------"
exit
end
CloudXLS.api_key = ENV["C... | true |
426c4f1779a0af8bbe97ad6f6d6d148ee5e0bbc7 | Ruby | mikebannister/importable | /spec/models/spreadsheet_spec.rb | UTF-8 | 5,402 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Importable
describe Spreadsheet do
let(:single_worksheet_spreadsheet) do
spreadsheet_file = File.open support_file('foo_single_worksheet.xlsx')
Spreadsheet.new(mapper_name: 'foo', file: spreadsheet_file)
end
let(:invalid_spreadsheet) do
spreadsheet_file = F... | true |
b4d6c1dfb042e196bedd87cc7b5848a97e170eb7 | Ruby | reedlaw/ruby-mmo | /players/snuderl.rb | UTF-8 | 739 | 3.09375 | 3 | [] | no_license | module Snuderl
def move
if ranking < 3 and health < 70
[:rest]
end
if health<65
return [:rest]
end
if dying.first
[:attack, dying.first]
end
opponent = weak.first
if opponent.alive
[:attack, opponent]
elsif health==100
[:attack, enemies[rand(player_count-1)]]
else
[:rest]
end
... | true |
8892b8d18217000ad5d37bd25b6f656c586b8e1d | Ruby | sis-berkeley-edu/calcentral | /app/models/campus_oracle/course_sections.rb | UTF-8 | 3,281 | 2.609375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"ECL-2.0"
] | permissive | module CampusOracle
class CourseSections < BaseProxy
def initialize(options = {})
super(Settings.campusdb, options)
@term_yr = options[:term_yr]
@term_cd = options[:term_cd]
@ccn = options[:ccn]
@section_id = "#{@term_yr}:#{@term_cd}:#{@ccn}"
end
def get_section_data
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.