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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fd73235f4a1fc7d34d877dd7ed01527f33a038f8 | Ruby | s2k/ATDD-demo | /src/user.rb | UTF-8 | 311 | 3.140625 | 3 | [] | no_license | class User
attr :name
attr :pwd
attr :status
def initialize(name, user_data)
@name = name
@pwd = user_data[:pwd]
@status = user_data[:status]
end
def logged_in?
return @status == :online
end
def password_equals(password)
return password == @pwd
end
end | true |
14804b66961b02883faa7d4d1e0a596275c54f1a | Ruby | feymartynov/task_mgr | /db/seeds.rb | UTF-8 | 1,336 | 2.578125 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
383237feff9a56f2949fd274913289786c62cca4 | Ruby | thehimalayanleo/thehimalayanleo.github.io | /vendor/bundle/ruby/3.1.0/gems/bibtex-ruby-4.0.16/test/bibtex/test_string.rb | UTF-8 | 3,863 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"GPL-3.0-only"
] | permissive | require 'helper.rb'
module BibTeX
class StringTest < Minitest::Spec
describe 'when parsing a simple string' do
before do
@bib = BibTeX.parse('@string{ foo = "bar" }')
end
it 'should should not be empty' do
assert_equal 1, @bib.length
end
it 'should have a sy... | true |
5486822643feadbdba1d688112132dbd3dcd5e99 | Ruby | jeffryang24/learning-star | /ruby/integer_class.rb | UTF-8 | 290 | 3.15625 | 3 | [
"MIT"
] | permissive | a = 123
puts a
puts a.class
a = 574654694576854796746495
puts a
puts a.class
a = 473574389579593457347539759375934759837593759759375395
puts a
puts a.class
=begin
as ruby >= 2.4,
the fixnum and bignum class is unified into integer class.
So, all of above command will print Integer
=end
| true |
10fcfd7cd43c95a382a2bb10910d037e0a8df4b3 | Ruby | anayib/work | /object_oriented_programing/twenty_one_solution.rb | UTF-8 | 5,453 | 3.890625 | 4 | [] | no_license | class Participant
attr_accessor :name, :cards
attr_writer :total
def initialize
@name = name
@cards = []
@total = 0
end
def hit(new_card)
cards << new_card
end
def stay
puts "#{name} stays!"
end
def busted?
total > 21
end
def total
total = 0
cards.each do |card... | true |
656f23c8ece3518f15b3f4afc174802514b9490a | Ruby | MASisserson/launch_school | /intro_programming_ruby/hashes/2.rb | UTF-8 | 277 | 3.3125 | 3 | [] | no_license | # Hashes Exercise 2
palau = { peter: 'uncle', rdiall: 'cousin' }
america = { abigail: 'girlfriend', mark: 'friend', steve: 'friend' }
england = { anna: 'friend' }
puts palau
puts america
puts england
puts palau.merge(america)
puts palau
puts palau.merge!(england)
puts palau | true |
90d0ca074c08d89acf35861c2553de7056e372c2 | Ruby | Joicyg/joicy1 | /AssignmentDay5/inheritance.rb | UTF-8 | 242 | 3.703125 | 4 | [] | no_license | class Animal
def display_msg
puts "Some animals gives birth"
end
end
class Dog < Animal
def display_msg
super()
puts "Dogs give birth to babydogs"
end
def barks
puts "Dogs barks"
end
end
d = Dog.new
d.display_msg
d.barks
| true |
b9ee071e176d8331901f420fa91e818ed654a71a | Ruby | dwhenry/co-engine | /spec/co-engine/loaders/json_loader_spec.rb | UTF-8 | 5,338 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'co_engine'
RSpec.describe CoEngine::Loaders::JsonLoader do
let(:game_type) { nil }
describe '#load' do
subject { described_class.new(game_data.merge(game_type: game_type)) }
context 'loading a game without players' do
it 'when no player data it raises an error' do
expect { describe... | true |
ffba8b7ddd4a25050ee66fe7f823970460f0ae84 | Ruby | codehaus/damagecontrol | /rscm/lib/rscm/command_line.rb | UTF-8 | 2,609 | 2.75 | 3 | [] | no_license | module RSCM
# Utility for running a +cmd+ in a +dir+ with a specified +env+.
# If a block is passed, the standard out stream is passed to that block (and returns)
# the result from the block. Otherwise, if a block is not passed, standard output
# is redirected to +stdout_file+. The standard error stream is alwa... | true |
941b3319488cd5c2bb0edf894d5dcb08c4977232 | Ruby | NeilVeira/asdfghjkretb5 | /app/helpers/people_helper.rb | UTF-8 | 2,206 | 2.734375 | 3 | [] | no_license | module PeopleHelper
private
def get_all_sponsors (person)
Sponsor.where(person_id: person.id)
end
def get_all_players (person)
Player.where(person_id: person.id)
end
def get_all_tournament_organizers (person)
TournamentOrganizer.where(person_id: person.id)
end
def get_all_golf_course_org... | true |
1c01b85bc3defe14ea0290bc83c66e06d1c1478d | Ruby | billiegoatin/LearnRubyWithCodecademy | /PlayinWithMethods.rb | UTF-8 | 237 | 3.828125 | 4 | [] | no_license | def greeter(name)
return "hello, " + name
end
#So there is a ? here, why? Billie, look this shit up
def by_three?(number)
if number % 3 == 0
return true
else
return false
end
end
puts greeter("Austin")
puts by_three(9)
| true |
f1c9306feeb9c51aee232086d0499821551a0ab3 | Ruby | yangsooyeon/code | /script.rb | UTF-8 | 1,303 | 2.703125 | 3 | [] | no_license | require 'httparty'
require 'nokogiri'
# 1. naver์ ์ํ๋ ์ ๋ณด๊ฐ ๋ด๊ธด ํ์ด์ง๋ฅผ ์์ฒญ
# 2. naver์๊ฒ ๋ฐ์ ๋ฌธ์ ์์ ์๋ ์ํ๋ ์ ๋ณด๋ฅผ ๋ถ๋ฌ ์จ๋ค.
# 3. ๋ถ๋ฌ์จ ์ ๋ณด๋ฅผ ์ถ๋ ฅ ํ๋ค.
# res = HTTParty.get("http://finance.naver.com/sise/")
# val = Nokogiri::HTML(res).css("#KOSPI_now")
# puts "ํ์ฌ ์ฝ์คํผ ์ง์๋ " + val.text + " ์
๋๋ค."
headers = {
'User-Agent': 'Mozilla/5.0 (Wi... | true |
cf325e23cab835e5bfd4a5f6f5b0a57c76637096 | Ruby | leticiarina/bandejao-bot | /bot/bot_papoco.rb | UTF-8 | 914 | 2.796875 | 3 | [
"MIT"
] | permissive | require './utils/constants'
class Bot
class Papoco
def initialize(bot)
@bandejao = bot.bandejao
@bot = bot
end
def start(chat, exists = false)
prng = Random.new( Time.now().to_i )
shots = 11
boom = "POOOW"
if prng.rand(100) >= 90
boom = "..."
end
... | true |
481f5c601247630063da576532781a3df7adac9c | Ruby | sassafracas/SmarterChild | /src/modules/events/mention.rb | UTF-8 | 305 | 2.609375 | 3 | [] | no_license | module Bot::DiscordEvents
# This pms a user when bot is mentioned (will replace with something more useful)
module Mention
extend Discordrb::EventContainer
mention do |event|
event.user.pm("Hey #{event.user.name}, don't tell anyone we talked.")
end
end
end | true |
4616beb9c42f587ed5b924257d154c3e7532dcd1 | Ruby | ViSual-BBS/identity-idp | /lib/tasks/reset_user_passwords.rake | UTF-8 | 736 | 2.515625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | namespace :adhoc do
USAGE_WARNING = <<~EMAIL.freeze
WARNING: Running this task without EMAILS argument is a noop
Usage: rake adhoc:reset_passwords_and_notify_users EMAILS=user1@asdf.com,user2@asdf.com
To include an additional message:
rake adhoc:reset_passwords_and_notify_users EMAILS=user1@asdf.com,... | true |
598d7b8bd86627b31245128f3bf251c62a54864d | Ruby | adudley78/ruby-intro-to-arrays-lab-online-web-prework | /lib/intro_to_arrays.rb | UTF-8 | 511 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
@my_new_array = [ ]
end
def array_with_two_elements
@my_new_array = ["Element_One", "Element_Two"]
end
def first_element(my_new_array)
my_new_array[0]
end
def third_element(my_new_array)
my_new_array[2]
end
def last_element(my_new_array)
my_new_array[-1]
end
def first_element_wi... | true |
a1234d2803e907d51d23901e60fec4ce63155b33 | Ruby | mageshkumarbe/ruby | /ex8.rb | UTF-8 | 949 | 4.0625 | 4 | [] | no_license | formatter = "%{first} %{second} %{third} %{fourth}" #Initialized multiple format string using %{} to formatter
puts formatter % {first: 1, second: 2, third: 3, fourth: 4} #Here format strings are took integer values by it's own name,also it prints the format string values
puts formatter % {first: "one", secon... | true |
cb08dea9bffe387f353edbba33687b37540299a9 | Ruby | MariaTerzieva/Tic-Tac-Toe | /app/controllers/players_controller.rb | UTF-8 | 1,113 | 3.5 | 4 | [] | no_license | ##
# This class represents the Players Controller which is responsible
# for saving or updating a player and their number of wins in the
# database, printing out the leaderboard and loading an appropriate
# page when there is no winner.
class PlayersController < ApplicationController
##
# Searches for the player ... | true |
35e799a75ea13eac1d58e81627d9aa1e0625adcf | Ruby | sethbass14/Gigster | /app/models/user.rb | UTF-8 | 925 | 2.640625 | 3 | [] | no_license | class User < ApplicationRecord
has_secure_password
belongs_to :city
has_many :musician_instruments, :foreign_key => "musician_id"
has_many :instruments, through: :musician_instruments
has_many :bookings, :class_name => "Gig", :foreign_key => "leader_id"
has_many :musician_gigs, :foreign_key => "musician_id"... | true |
d8214721ec56487371aa4eacd244f53755bec309 | Ruby | supersquashman/character-generator | /Resources/Books/PHB/Feats/two-weapon_fighting_feats.rb | UTF-8 | 2,554 | 2.953125 | 3 | [] | no_license | #require "FeatList"
# require 'pathname'
# require Pathname(__FILE__).ascend{|d| h=d+'FeatList.rb'; break h if h.file?}
class TwoWeaponFighting < FeatModel
@bonus_classes = ["Fighter", "Ranger(Melee)"]
def initialize
super
@title = "Two-Weapon Fighting"
@description = "You can fight with a weapon ... | true |
bff62e639ea493f5112c19cf5474387a8843183c | Ruby | KamalMicheal/flower_shop | /spec/app/flower_shop_spec.rb | UTF-8 | 2,137 | 2.84375 | 3 | [] | no_license | require 'spec_helper'
describe FlowerShop do
let(:flowers) do
[
{
name: 'Roses',
code: 'R12',
bundles: [
{ quantity: 5, price: 6.99 },
{ quantity: 10, price: 12.99 }
]
},
{
name: 'Lilies',
code: 'L09',
bundles: [
... | true |
8757765f6cd41ce7d2d19e45ea97760a8929e9ae | Ruby | alizawren/game | /main.rb | UTF-8 | 494 | 2.671875 | 3 | [] | no_license | require "gosu"
require_relative "./SceneManager.rb"
require_relative "./scenes/TitleScene.rb"
class Main < Gosu::Window
def initialize
super 1280, 720
self.caption = "Game?"
SceneManager.run
end
def update
SceneManager.update(mouse_x, mouse_y)
end
def draw
SceneManager.draw
end
de... | true |
6dd8d5fb49626179f024fb1e7dd03e2ce4222317 | Ruby | dombarnes/firelog | /config/initializers/time_formats.rb | UTF-8 | 245 | 2.515625 | 3 | [] | no_license | Time::DATE_FORMATS[:default] = "%H:%M"
Date::DATE_FORMATS[:default] = "%e %b %Y"
DateTime::DATE_FORMATS[:default] = "%e %b %Y"
DEFAULT_DATETIME_FORMAT = "%a %-d %b %H:%M"
class DateTime
def to_s
strftime DEFAULT_DATETIME_FORMAT
end
end
| true |
49297c2039b4281bdf3059ef9ce817447a7945bb | Ruby | klavinslab/nursery | /auto/rehearse/69.rb | UTF-8 | 399 | 2.640625 | 3 | [] | no_license |
class Protocol
def main
o = op input
o.input.all.take
# Todo: Figure out how many gels to pour based on the number of threads (o.threads.length)
show {
title "#{o.name} Inputs"
note "Detailed instructions for pouring a gel go here"
}
o.output.all.produce
o.inp... | true |
6b956c534fab88f0a4bd5066749952b301bb7caf | Ruby | synthresin/jfk | /app/models/user.rb | UTF-8 | 1,467 | 2.640625 | 3 | [] | no_license | # encoding: utf-8
require 'bcrypt'
class User < ActiveRecord::Base
attr_accessor :password, :password_confirmation
attr_accessible :email, :password, :password_confirmation
before_save :encrypt_password
include BCrypt
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :password, :presence... | true |
5c63c32a09a03b5b492a2652db2a79352d779d19 | Ruby | Jose-N/Launch-Academy-Week-1 | /blackjack/spec/lib/deck_spec.rb | UTF-8 | 1,897 | 3.21875 | 3 | [] | no_license | require "spec_helper"
require_relative "../../lib/deck.rb"
RSpec.describe Deck do
describe "#initialize" do
let (:test_deck) {Deck.new}
context "should create a new deck of cards" do
it "it should have 52 cards total" do
expect(test_deck.deck.size).to eq(52)
end
it "it should have... | true |
7a97bb235075fac3f4ee946adcaccdd8b5249a70 | Ruby | AgileVentures/shf-project | /app/services/memberships/renew_membership_actions.rb | UTF-8 | 909 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
#--------------------------
#
# @class Memberships::RenewMembershipActions
#
# @desc Responsibility: Do all the things that need to be done when a membership is renewed.
#
#
# @author Ashley Engelund (ashley.engelund@gmail.com weedySeaDragon @ github)
# @date 2022-05=21
#
# TODO: what ... | true |
d81a4dbc8b1e19a429ad49d2b410d9a2dd39ed52 | Ruby | patty-cc/Day-01_classes_homework | /cohort_student.rb | UTF-8 | 511 | 3.265625 | 3 | [] | no_license | class CohortStudent
def initialize ( student_name, cohort_number)
@cohort_number = cohort_number
@student_name = student_name
end
def student_name
return @student_name
end
def cohort_number
return @cohort_number
end
def student_speech
return "I can talk"
end
def prog_lang(lang... | true |
711c0f1032395039851dcbde58a3c2e2ffdfdbe5 | Ruby | hope-andrew/app-academy | /w2d5/poker/lib/hand.rb | UTF-8 | 2,011 | 3.4375 | 3 | [] | no_license | require 'card'
require 'byebug'
class Hand
attr_reader :cards
def categories
[ :straight_flush,
:four_of_a_kind,
:full_house,
:flush,
:straight,
:three_of_a_kind,
:two_pair,
:one_pair,
:high_card
]
end
def initialize(cards)
@cards = cards
end
d... | true |
7e1938cc85b5983537b2e7ad8411b214ad1388a4 | Ruby | trizen/sidef | /scripts/RosettaCode/multifactorial.sf | UTF-8 | 223 | 3.234375 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Multifactorial
#
func mfact(s, n) {
n > 0ย ? (n * mfact(s, n-s))ย : 1;
}
ย
for s in range(1, 10) {
say "step=#{s}: #{1..10 -> map {|n| mfact(s, n)}.join(' ')}";
}
| true |
24617a693a9ab0ae94076735a384904c997bbfe7 | Ruby | JevanWu/huali | /app/values/discount.rb | UTF-8 | 472 | 3.34375 | 3 | [] | no_license | class Discount
attr_reader :operator, :number
def initialize(adjustment)
unless adjustment =~ %r{\A[+-x*%/][\s\d.]+\z}
raise "Invalid adjustment string"
end
adjust = adjustment.to_s.squeeze(' ').sub('x', '*').sub('%', '/')
@operator = adjust.first.to_sym
@number = adjust[1..-1].to_f
e... | true |
cafd186c4021e8a5343ee0b550f2052da47290f2 | Ruby | Aymane11/30-Days-of-Code | /Solutions/Day6/solution.rb | UTF-8 | 303 | 3.640625 | 4 | [] | no_license | # Enter your code here. Read input from STDIN. Print output to STDOUT
t = gets.to_i
t.times{
txt = gets.chomp
ev = ""
od = ""
(0...txt.size).each{ |i|
if i%2==0
ev << txt[i]
else
od << txt[i]
end
}
puts "#{ev} #{od}"
} | true |
353a84d74e6c2eaaa12c7cc114cd75c802876ac2 | Ruby | patch0/feature_flag | /spec/feature_flag/lookup_spec.rb | UTF-8 | 1,159 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Lookup do
context '#check_flag' do
it 'should return true when ENV variable enabled' do
ENV["FEATURE"] = "true"
Lookup.check_flag('FEATURE').should be_true
end
it 'should return false when no ENV variable found' do
Lookup.check_flag('xxMISINGxx').should b... | true |
d503e9f5207f176f230124ec8d2e7ed5cc3a8338 | Ruby | masa-1013/100Questions | /28.rb | UTF-8 | 435 | 3.03125 | 3 | [] | no_license | n = gets.to_i
graph = Array.new(n)
n.times do |i|
input = gets.split().map(&:to_i)
tmp = []
input[1].times do |j|
tmp << input[j+2]-1
end
graph[i] = tmp
end
dist = Array.new(n, -1)
queue = []
dist[0] = 0
queue << 0
while !queue.empty?
v = queue.shift
graph[v].each do |i|
next if dist[i] != -1
... | true |
5df4d6b5fc0f9dbe8d55b064ee9274fe24738663 | Ruby | joan2kus/ChartDirector | /railsdemo/app/controllers/stepline_controller.rb | UTF-8 | 3,123 | 2.5625 | 3 | [
"IJG"
] | permissive | require("chartdirector")
class SteplineController < ApplicationController
def index()
@title = "Step Line Chart"
@ctrl_file = File.expand_path(__FILE__)
@noOfCharts = 1
render :template => "templates/chartview"
end
#
# Render and deliver the chart
#
def getchar... | true |
372c47cf7fc1ecbd16599dfc816daafcf7a86dc4 | Ruby | trollsk1n/test_ruby | /animal.rb | UTF-8 | 966 | 4.21875 | 4 | [] | no_license | # frozen_string_literal: true
# Animal superclass
class Animal
attr_reader :name, :age
def name=(value)
raise "Name can't be blank!" if value == ''
@name = value
end
def age=(value)
raise "An age of #{value} isn't valid" if value.negative?
@age = value
end
def talk
puts "#{@name} ... | true |
4382c0d35649e7fb807e94190e5876b94bbcabae | Ruby | AaronC81/quickspcr | /src/quickspcr/prompt.rb | UTF-8 | 526 | 2.515625 | 3 | [] | no_license | require_relative 'spcr'
require 'shellwords'
# Handles displaying a prompt and launching the browser if necessary.
class Prompt
def self.show(app_id, app_name)
message = %W[
Looks like you've been playing #{app_name}. Would you like to
compose a report for it on SPCR?
].join(' ')
system(%W[
... | true |
e558651e3e7367f8d4293c3363e21f5a54e37b93 | Ruby | Christof/SimpleGnuplot | /Gnuplot.rb | UTF-8 | 4,495 | 2.53125 | 3 | [] | no_license | require 'narray'
require './NArray_Extensions.rb'
class Gnuplot
attr_accessor :synchronize
attr_accessor :debug
attr_accessor :replot
def initialize(gnuplot_path = "pgnuplot", dump_file = nil)
@gnuplot_path = gnuplot_path
if dump_file
@stream = File.new(dump_file, "w")
@is_process = false
... | true |
7996b51513d88aa43ff7767b9acfee064edb84b0 | Ruby | malachaifrazier/Beatstream | /app/services/media_reader.rb | UTF-8 | 1,220 | 2.640625 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | require 'find'
class MediaReader
MUSIC_PATH = Rails.application.config.music_paths.to_s
SONGS_JSON_FILE = Rails.root.join('data', 'songs.json').to_s
def self.MUSIC_PATH
MUSIC_PATH
end
def self.SONGS_JSON_FILE
SONGS_JSON_FILE
end
def self.all
songs_file.read
end
def self.create_song(pa... | true |
da584252a1f9b4e0a0f676ed3f6ac9d6ee2891d4 | Ruby | RubyCamp/rc2018sp_g5 | /practice15/Scene/Lib/Enemy.rb | UTF-8 | 588 | 2.71875 | 3 | [] | no_license | #encoding :Shift_JIS
class Enemy < Sprite
def initialize(x,y)
super
self.x = x
self.y = y
self.image = Image.load('Scene/images/enemy.png')
@y_move = 5
end
def update
self.draw
self.x -= 10
self.y += @y_move
if self.x... | true |
1931bf3c3ed43f71833ada1070a98f836b208dab | Ruby | toddt67878/Build_a-File_Type_Hash_Mapper_in_Ruby | /Build_a File_Type_Hash_Mapper_in_Ruby.rb | UTF-8 | 898 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'rspec'
class Array
def file_type_mapper
each_with_object(Hash.new { |h, k| h[k] = [] }) do |file, hash|
file_ext = File.extname(file)[1..-1]
hash[file_ext] = hash[file_ext].push(file.chomp!('.' + file_ext))
end
end
end
describe 'File selector' do
it 'converts an array of file names ... | true |
ecc4af1261bae31bfb077f5a024d9f42e247c7e6 | Ruby | amaxwellblair/module_3_assessment | /spec/requests/api/v1/items_spec.rb | UTF-8 | 2,050 | 2.546875 | 3 | [] | no_license | require "rails_helper"
describe "item api" do
it "returns all of the items" do
Item.create(name: "bacon", description: "best kind of bacon", image_url: "www.whocares.com")
Item.create(name: "not bacon", description: "why eat it", image_url: "www.whocares.com")
get "/api/v1/items.json"
expect(respo... | true |
6bb4f697013f553fdb10cb943a2aca693fb3c844 | Ruby | isabella232/cutlass | /lib/cutlass/docker_diff.rb | UTF-8 | 1,090 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Cutlass
# Diffs docker images
#
# diff = DockerDiff.new
#
# diff.call.changed? # => false
#
# BashResult.run("docker build .")
#
# diff.call.changed? # => true
class DockerDiff
def initialize(before_ids: nil, get_image_ids_proc: -> { Docker::Image.al... | true |
27b9c3c2ef9623940d2ef71302d379c40d541084 | Ruby | ndrluis/mbank | /app/models/account.rb | UTF-8 | 1,736 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
class Account < ApplicationRecord
has_many :debit_transfers,
-> { Transaction.transfer },
foreign_key: 'source_account_id',
class_name: 'Transaction'
has_many :credit_transfers,
-> { Transaction.transfer },
foreign_key: 'destinat... | true |
a2ada17f8d3b90a3c5437576412d67488c8d0d68 | Ruby | chenyukang/rubytt | /tests/cases/gcd.rb | UTF-8 | 104 | 2.90625 | 3 | [
"MIT"
] | permissive |
def gcd x, y
return x if x == y
if x >= y && y > 0
gcd y, x % y
else
gcd y, x
end
end
| true |
a025210d806122c47b1ecb8e42767d00983f234a | Ruby | errm/scraping_ebay | /scraper.rb | UTF-8 | 1,155 | 3.21875 | 3 | [] | no_license | require 'wombat'
require 'monetize'
require 'pry'
Monetize.assume_from_symbol = true
class EbayPhone
def initialize(data)
self.name = data['name'].gsub("New listing\r\n\t\t",'')
self.price = Monetize.parse(data['price'])
end
def to_s
"#{name} - #{price.symbol}#{price}"
end
attr_reader :name, :... | true |
08f45e4670fd87af7ba03f6c9112435df46fa780 | Ruby | johnsonch/RubyQuizes | /fizzbuzz.rb | UTF-8 | 1,096 | 4 | 4 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license |
class Game
def self.fizzbuzz
Array(1..100).map{|x| output(x) }
end
def self.output(statement)
puts is_fizz_buzz?(statement) || is_fizz?(statement) || is_buzz?(statement) || statement
end
def self.is_fizz_buzz?(statement)
is_fizz?(statement) && is_buzz?(statement) ? "fizzbuzz" : false
end
... | true |
d913914c6f9648988546e9fb8dbdd443c82a34c0 | Ruby | kasumi8pon/atcoder_practice | /abc/072/d.rb | UTF-8 | 201 | 3.046875 | 3 | [] | no_license | n = gets.to_i
ps = gets.split.map(&:to_i)
answer = 0
(0...n).each do |i|
next if ps[i] != i + 1
answer += 1
ps[i], ps[i + 1] = ps[i + 1], ps[i]
end
answer += 1 if ps[n - 1] == n
puts answer
| true |
89201cb43656f844aeaff836d86030f168f4e51b | Ruby | EosLightmedia/whyte_avalanche | /lib/http_sender.rb | UTF-8 | 732 | 2.515625 | 3 | [] | no_license | class HTTPSender
attr_accessor :port, :domain, :log_http, :log_body
def initialize(params)
@port = params[:port] || 80
@domain = params[:domain]
@page = params[:page]
@url = "http://#{@domain}/"
mp @url
@client = AFMotion::Client.build(@url)
end
def get(param_key, param_value)
page... | true |
6a9506081d61896e7905234ff36402d376c451a9 | Ruby | vanegg/Rubylearning | /S2D5/examen_final_fase0.rb | UTF-8 | 6,727 | 4.09375 | 4 | [] | no_license | #Examen Final Fase 0
#Removiendo vocales
#Crea el mรฉtodo vowels que recibe una lista de palabras words y remueve las vocales de cada string. Haz pasar la prueba correspondiente.
def vowels(array)
array.map {|word| word.delete "aeiouAEIOU"}
end
p vowels(["banana", "carrot", "pineapple", "strawberry"]) == ["bnn", "cr... | true |
71d56380132b9f8cd488d859582a0446870c5b62 | Ruby | tchin8/W4D3 | /display.rb | UTF-8 | 1,670 | 3.40625 | 3 | [] | no_license | require 'colorize'
# require 'colorized_string'
require_relative "board.rb"
require_relative "cursor.rb"
class Display
attr_reader :cursor, :board
def initialize(board)
@board = board
@cursor = Cursor.new([0, 0], board)
end
def render
board.grid.each_with_index do |row, i... | true |
534c5f420834d20db25ca0be4747ef120802b7fa | Ruby | DavidMah/Euler-Code | /010 - 019/Fourteen.rb | UTF-8 | 405 | 3.125 | 3 | [] | no_license | $results = Hash.new
def sequence(n)
if n == 1
return 1
elsif $results[n] != nil
return $results[n]
elsif n % 2 == 0
res = 1 + sequence(n / 2)
$results[n] = res
else
res = 1 + sequence(3 * n + 1)
$results[n] = res
end
end
greatest = 0
best = 0
for i in 1..999999
res = sequence(i)
$results[i] = res
be... | true |
5581aa5fb5b4c81447e3ffd01a6ba20cb22908ee | Ruby | norelevance/ivr | /app/controllers/twilio_controller.rb | UTF-8 | 2,205 | 2.765625 | 3 | [] | no_license | require 'twilio-ruby'
require 'sanitize'
class TwilioController < ApplicationController
def initialize
@vr = Twilio::TwiML::VoiceResponse.new
end
def index
render text: "Dial Me."
end
def ivr_welcome
response = Twilio::TwiML::VoiceResponse.new
gather = Twilio::TwiML::Gather.new(input: 'dtmf... | true |
477f3a62b113906debb319571b813cf0afe001c6 | Ruby | mopuriiswaryalakshmi/Rspec | /matchers_spec.rb | UTF-8 | 1,185 | 3.640625 | 4 | [] | no_license | describe "Matchers"do
it "asserts on equality" do
number = 3
expect(number).to eq 3
end
it "asserts on mathematical operators" do
number = 5
expect(number)to be >= 2
end
it "asserts on matching a regular expression" do
email = "jose@tutsplus.com"
regular_expression = /^\w+@\w+\.[a-z]{2,4}$/
... | true |
761c57fa06af5388ab7e6d3fae21849054feca7c | Ruby | karthikeyan7585/adva_cms | /vendor/gems/rubyzip-0.9.1/lib/quiz1/t/solutions/Carlos/solitaire.rb | UTF-8 | 1,991 | 3.578125 | 4 | [
"Ruby",
"BSD-2-Clause",
"MIT"
] | permissive | class Numeric
def value
self
end
def to_letter
((self-1)%26 + ?A).chr
end
end
class String
# returns an array with the code of the letters,
# padded with the code of X
def to_numbers
res=upcase.unpack("C*").collect { |b|
if b.between? ?A, ?Z
b - ?A + 1
else
nil
end
... | true |
ce4cef0bdb7afdb89b3dc13b0de630d9077d9fd7 | Ruby | okke/jparsr | /spec/grammar/statements.rb | UTF-8 | 16,822 | 2.84375 | 3 | [
"MIT"
] | permissive | #
# Copyright (c) 2015, Okke van 't Verlaat
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, pu... | true |
ac3d400aba80511e957e287ed97ed1fe4b5dad25 | Ruby | tanaken0515/atcoder | /virtual-contests/pepabo/001/A.rb | UTF-8 | 92 | 2.796875 | 3 | [] | no_license | sorted_nums = gets.chomp.split(" ").map(&:to_i).sort
print sorted_nums[0] + sorted_nums[1]
| true |
1ed277814b8e71622dc44c324e764afdd06f9a56 | Ruby | andrewdwooten/enigma | /test/Key_test.rb | UTF-8 | 546 | 2.9375 | 3 | [] | no_license | require_relative 'test_helper.rb'
require './lib/Key.rb'
class KeyTest < MiniTest::Test
def test_is_the_key_a_key
house_key = Key.new
assert_equal Key, house_key.class
end
def test_is_the_key_five_digits
house_key = Key.new
assert_equal 5, house_key.key.count
end
def test_is_the_key_an_... | true |
b591242e8c419a0d4586528ce657269310d4a768 | Ruby | lpzraf/ruby-object-attributes-lab-v-000 | /lib/person.rb | UTF-8 | 287 | 3.25 | 3 | [] | no_license | class Person
def name= (name)
@name = name
end
def name
@name
end
def job= (job)
@job = job
end
def job
@job
end
end
beyonce = Person.new
beyonce.name = "Beyonce"
puts beyonce.name
singer = Person.new
singer.job = "Singer"
puts singer.job | true |
c0848163a60690546a3a38a59bc751c5436e937f | Ruby | JennicaStiehl/personal_site | /test/features/user_sees_a_homepage_test.rb | UTF-8 | 703 | 2.6875 | 3 | [] | no_license | require './test/test_helper'
class HomepageTest < CapybaraTestCase
def test_user_can_see_the_homepage
visit '/'
# save_and_open_page
assert page.has_content?("Welcome!")
assert_equal 200, page.status_code
end
def test_user_can_see_the_error_message
visit '/error'
assert page.has_content... | true |
7af5b2f21c72a24501e33182bdff4b0a76414bb1 | Ruby | hlindberg/tahu | /lib/puppet/functions/tahu/ppyaml_key.rb | UTF-8 | 4,862 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | # This hiera5 lookup_key kind of backend function reads a yaml file and performs Puppet Language evaluation.
#
# It requires a 'path' pointing to a data file, and it can optionally perform a hiera interpolation before evaluating
# the read data structure as Puppet Source code. The 'path' is provided by hiera 5 framewor... | true |
aa0414a808c0e6ac6dba9376b0c3c24e5096ff1b | Ruby | tm1819/Code--github- | /Development/NYU Classes Health/nyuClassesHealth0.1.rb | UTF-8 | 5,403 | 2.75 | 3 | [] | no_license | # ###########################################################################
# Title: NYU Classes Health Check
# Author: Tom Martin
# Date: 2/25/2013
#
# This script checks the status of an NYU Classes Server, and sends an email
# message in the event of a status change.
# ############################################... | true |
94cac24f69da21ca0bf4ffef983b89167b5b67bc | Ruby | Lafatra351/TicTacToe.THP | /TicTacToe2.rb | UTF-8 | 4,482 | 3.734375 | 4 | [
"MIT"
] | permissive |
# classe cases :
class BoardCase
#la classe a deux attr_accessor : sa valeur ("X", "_", ou vide), et son numรฉro de case.
attr_accessor :value, :case_number
def initialize(case_number)
@value = ""
@case_number = case_number
end
def to_s
# renvoie la valeur au format string
self.value = @... | true |
1a6d70e78daeddbe7921fca7ba458ce79bbd9a52 | Ruby | koshavaghela/platform-code-test | /award.rb | UTF-8 | 1,198 | 3.25 | 3 | [] | no_license | class Award
attr_accessor :name, :expires_in, :quality
def initialize(name, expires_in, quality)
@name = name
@expires_in = expires_in
@quality = quality
end
def update_award_quality
case name
when 'Blue Distinction Plus'
@quality = 80
when 'NORMAL ITEM'
self.normal_item
... | true |
208842244c03f758cd0acc25c865f242456c2b5e | Ruby | Cheltonne/THP-Jour-17-Chelton-Ajax | /lib/game.rb | UTF-8 | 3,328 | 3.453125 | 3 | [] | no_license | require 'pry'
require_relative 'player'
class Game
attr_accessor :human_player, :players_left, :ennemies_in_sight
def initialize(player_name)
@players_left = 10
@human_player = HumanPlayer.new(player_name)
self.ennemies_in_sight = []
4.times do |i|
@ennemies_in_sight << Player.new("cpu_#{i}")... | true |
5ec9529743e8fe62b3a71c87142962528718c779 | Ruby | miketierney/seacrest | /bin/csscrubber | UTF-8 | 1,981 | 2.828125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require "lib/seacrest"
# puts "Scrub scrub scrub scrub scrub scrub scrub"
output = Seacrest::CSScrubber.run(ARGV)
if output.dup_selectors.size >= 1
puts "\n#############################"
puts "### Duplicate Selectors ###"
puts "#############################\n\n"
... | true |
7e6058b07d842cfe407ab00a0028e525547880fe | Ruby | HJRandolph/learn_ruby | /ruby_challenges/attr_settersANDgetters.rb | UTF-8 | 771 | 3.671875 | 4 | [] | no_license | class Pet
# attr_writer:name, :owner_name
# attr_reader:name, :owner_name
attr_accessor:name, :owner_name
end
class Ferret < Pet
def squeal
return "squeeeeee"
end
end
class Chincilla < Pet
def squeek
return "eeeep"
end
end
class Parrot < Pet
def tweet
return "caw"
end
end
my_ferret = Ferret.new
my... | true |
b0534ec12fc99f2e3ddc44e32d276d0fcc6956b4 | Ruby | edgelaboratories/sensu-plugins-edgelab | /bin/check-apt-expired-keys.rb | UTF-8 | 2,366 | 2.609375 | 3 | [] | no_license | #! /usr/bin/env ruby
# frozen_string_literal: true
#
# check-apt-expired-keys
#
# DESCRIPTION:
# This plugin reports expired GPG key used for APT signing.
#
# OUTPUT:
# plain text
#
# PLATFORMS:
# Debian
#
# DEPENDENCIES:
# gem: sensu-plugin
#
# USAGE:
# example commands
#
# NOTES:
# Does it behave diffe... | true |
87637b9913fae92029792588ab258ba92f40babf | Ruby | Vandegrift/rex12 | /spec/rex12/segment_spec.rb | UTF-8 | 1,546 | 3.09375 | 3 | [
"MIT"
] | permissive | describe REX12::Segment do
subject { described_class.new elements, 1}
let (:elements) {
[REX12::Element.new("a", 1), REX12::Element.new("b", 2)]
}
describe "position" do
it "returns the position given in the constructor" do
expect(subject.position).to eq 1
end
it "freezes position" d... | true |
9559aedaa17a9f6de7871b2f75347b310be31843 | Ruby | joshua31101/ruby_practice | /searching_algorithms/binary_search.rb | UTF-8 | 442 | 3.5625 | 4 | [] | no_license | def binary_search(arr, target, first, last)
mid = (first+last) / 2
return true if arr[mid] == target
return false if first > last
if target < arr[mid]
binary_search(arr, target, first, mid-1)
else
binary_search(arr, target, mid+1, last)
end
end
arr = (1..10000000).to_a
t1 = Time.now
p binary_searc... | true |
8cb6f11138c7b8246ba1c0cedfbd74107faef3c5 | Ruby | nicooga/project-euler | /0009.rb | UTF-8 | 748 | 3.765625 | 4 | [] | no_license | # A Pythagorean triplet is a set of three natural numbers, a b c, for which,
# a2 + b2 = c2
# For example, 32 + 42 = 9 + 16 = 25 = 52.
# There exists exactly one Pythagorean triplet for which a + b + c = 1000.
# Find the product abc.
def pitagoric_triplet?(a,b,c)
(a**2 + b**2) == c**2
end
def solution
triplet =... | true |
b09f334e1f2473304791538d9e6774ca2af17840 | Ruby | sahidur-prosku/gs1 | /lib/gs1/validations.rb | UTF-8 | 1,014 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'gs1/validations/check_digit_validation'
require 'gs1/validations/date_validation'
require 'gs1/validations/length_validation'
module GS1
# Module for handling validations.
#
module Validations
def self.included(base)
base.extend ClassMethods
base.send :include, InstanceMethods
base... | true |
206eebd90c6e1b1b74f9cb168ac65aaf712ce601 | Ruby | tanmle/lf_testing | /lib/tasks/db_seed_dump.rake | UTF-8 | 4,276 | 2.703125 | 3 | [] | no_license | require 'active_support/core_ext/string/strip'
namespace :db do
namespace :seed do
task dump: [:environment, :load_config] do
desc 'LF - Create a db/seeds.rb file from the database'
# get information from config/database.yml file
erb = ERB.new(File.read('config/database.yml'))
config = Y... | true |
5c69f34d96c82e3fbd49619f483180cdd358f0f8 | Ruby | Ghuti/semaine14 | /ex.rb | UTF-8 | 143 | 3.59375 | 4 | [] | no_license |
1.upto(100) do |i|
if i % 5 == 0 and i % 3 == 0
puts "FizzBuzz"
elsif i % 5 == 0
puts "Buzz"
elsif i % 3 == 0
puts "Fizz"
else
puts i
end
end | true |
9bd6dcb5059e08b419d821c5f11c62825d106d4f | Ruby | niiicolai/P2-API | /app.rb | UTF-8 | 2,606 | 2.75 | 3 | [] | no_license | # Require the necessary libraries and models
require 'sinatra'
require 'sinatra/activerecord'
require './models/participant'
require './models/completed_activity'
require './models/failed_activity'
require './models/interaction'
require './models/rating'
require 'rack'
require 'rack/contrib'
# set the path to the data... | true |
a47b129145b4d91e87a784984f45d4ffc5050df2 | Ruby | dlains/rpl | /spec/rpl/parser_spec.rb | UTF-8 | 4,485 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'parslet/convenience'
module Rpl
describe Parser do
it 'can parse a sentence with parentheses' do
result = Parser.new.parse_with_debug('PA implies (PB or PC)')
expect(result[:implies][:left][:symbol]).to eq('PA')
expect(result[:implies][:right][:or][:left][:s... | true |
6fd28bcf9305affde2a0e9443028a0ba766c0b37 | Ruby | Niikwartey/ttt-with-ai-project-wdf-000 | /lib/players/computer.rb | UTF-8 | 1,211 | 3.40625 | 3 | [] | no_license | require 'pry'
module Players
class Computer < Player
attr_accessor :win_combinations, :board
WIN_COMBINATIONS = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [6,4,2]]
def initialize(token)
@token = token
@win_combinations = WIN_COMBINATIONS
end
def move(board)
... | true |
e391ae3db76e9c6cce714e559327c4418c997b09 | Ruby | matrharr/data_structures-algorithms | /binary_tree_prac.rb | UTF-8 | 999 | 3.8125 | 4 | [] | no_license | class Node
attr_accessor :value, :right_child, :left_child
def initialize(val)
@value = val
@right_child = nil
@left_child = nil
end
end
class BinaryTree
attr_accessor :root
def initialize
@root = nil
end
def bt_insert(val)
@new_node = Node.new(val)
if @root == nil
@r... | true |
11ad644add55d2bc50c3675d1a5931343b52adc0 | Ruby | christinebeaubrun/books | /ex16.rb | UTF-8 | 1,087 | 4.03125 | 4 | [] | no_license | filename = ARGV.first
# filename is a variable that test.txt is assigned to
script = $0
# this is the name of the program or test.txt
# the program worked fine even when I #ed it out
puts "For exercise #{script} We're going to erase #{filename}."
puts "If you dont want that, hit CTRL-C (^C)."
# CTRL-C will cancel the ... | true |
e2b25eea021cb1081730094767782310ac72e13c | Ruby | rwalters/emcee | /lib/emcee/library.rb | UTF-8 | 2,052 | 3.296875 | 3 | [] | no_license | module Emcee
class Library
attr_reader :library
def initialize(library = {})
@library = library
end
def add(title, artist)
raise Emcee::DuplicateTitleError.new(title) unless library[title].nil?
library[title] = { artist: artist, played: false }
message = %Q[Added "#{title}" ... | true |
7310f280201ca9175b059ffc001860867382407a | Ruby | stefannibrasil/algoritmosii | /number_generator.rb | UTF-8 | 601 | 3.640625 | 4 | [] | no_license | def generate_numbers(n)
(1..n).to_a
end
def write_file(filename, arr)
File.open(filename, 'w') do |file|
arr.each do |n|
file.write(n)
file.write(' ')
end
end
end
# cem mil
numbers_100k = generate_numbers(10 ** 5)
write_file('100k_ordered.txt', numbers_100k)
write_file('100k_reverse.txt', nu... | true |
46be8656709eee3c81b01928cf9e71fd381e4dc7 | Ruby | JeffWaltzer/tastydoc | /app/text_view.rb | UTF-8 | 1,540 | 3 | 3 | [] | no_license | require_relative "rendering_context"
require_relative "string_wrapper"
class TextView
def initialize(style_sheet)
@accumulator = ''
@last_level= nil
@display_indent= 0
@indented_sections= style_sheet[:indented_sections] || []
@bulleted_sections = style_sheet[:bulleted_sections] || []
@seperat... | true |
4e2ca3681b9817cb3cc1c9df4babc09681e45a6e | Ruby | zonika/jukebox-cli-web-0715-public | /lib/jukebox.rb | UTF-8 | 1,425 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | songs = [
"Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"Phoenix - Consolation Prizes",
"Harry Chapin - Cats in the Cradle",
"Amos Lee - Keep It Loose, Keep It Tight"
]
def say_... | true |
ad52691633e70770dcf870b7e93b61a32616f1e7 | Ruby | kjdchapman/aoc-1 | /run_find_repeat_frequency.rb | UTF-8 | 140 | 2.546875 | 3 | [] | no_license | require './lib/find_repeat_frequency'
calculator = FindRepeatFrequency.new
input = File.read("./input.txt")
puts calculator.execute(input)
| true |
dcb5b6d0a3b4305448c171ae1dc8ccdc614ffd5c | Ruby | itiswhatitisio/rb101 | /lesson_5/pp_15.rb | UTF-8 | 562 | 3.921875 | 4 | [] | no_license | =begin
# Problem:
return an array which contains only the hashes
where all the integers are even
Input: array with hashes
Output: array
# Requirements
- hashes should contain only even numbers
# Examples:
arr = [{e: [8], f: [6, 10]}]
# Data structure/Algorithm
- since the returned value should be array,
need ... | true |
fa5e82d1d598ce8360605457fef3261c76e05ba4 | Ruby | dubroe/twitter-doghouse | /app/models/request_from_twitter.rb | UTF-8 | 2,332 | 2.828125 | 3 | [] | no_license | # This table is for incoming requests from Twitter to add people to Doghouse
class RequestFromTwitter < ActiveRecord::Base
MINUTES_CHAR = 'm'
HOURS_CHAR = 'h'
DAYS_CHAR = 'd'
DURATION_TYPES = [MINUTES_CHAR, HOURS_CHAR, DAYS_CHAR]
DURATION_MINUTES_MULTIPLIER_MAP = {"#{MINUTES_CHAR}" => 1, "#{HOURS_CHAR}" => MI... | true |
366ba76eafe3d8b7f100e6d6fef4e67d5dd2fa78 | Ruby | MichaelXavier/hollaback_admin | /spec/hollaback_inbound/helpers_spec.rb | UTF-8 | 1,902 | 2.515625 | 3 | [] | no_license | require 'hollaback_inbound/helpers'
module HollabackInbound
describe Helpers do
class HelpersTest; include HollabackInbound::Helpers; end
subject { HelpersTest.new }
describe "#calculate_offset" do
it "returns 0 for GMT" do
subject.calculate_offset("Fri, 17 Feb 2012 20:19:46 -0000").
... | true |
1b77f16ef6337faacee3ed2cd5ac3fc489771a96 | Ruby | onosi/aoj | /Introduciton_to_programming/Finding_Missing_Cards.rb | UTF-8 | 624 | 3.40625 | 3 | [] | no_license | S = Array.new(13,false)
H = Array.new(13,false)
C = Array.new(13,false)
D = Array.new(13,false)
numbers = gets.to_i
numbers.times do | n |
a,b = gets.split(' ')
b = b.to_i
case a
when "S"
S[b-1] = true
when "D"
D[b-1] = true
when "C"
C[b-1] = true
when "H"
H[... | true |
7705b200ef3cfd21812aa387c022fffbaa23d951 | Ruby | katsuster/nqueens_ruby | /nqueens.rb | UTF-8 | 1,723 | 3.65625 | 4 | [
"Apache-2.0"
] | permissive | require_relative 'solver.rb'
def main(argv)
if argv.length < 2
puts 'usage: \n' +
'NQueens queens(1 ... 30) parallel(true or false)'
return -1
end
#get the arguments
n = argv[0].to_i
if n < 0 || 30 < n
n = 0
end
puts 'queens : ' + n.to_s()
parallel = false
if argv.length >... | true |
0c99768eae0136df557bc6ce01f00b9cdf2fb69c | Ruby | christophe48/bot_tw | /lib/bot_qui_like.rb | UTF-8 | 710 | 2.53125 | 3 | [] | no_license | # ligne trรจs importante qui appelle la gem.
require 'twitter'
require 'dotenv'# n'oublie pas les lignes pour Dotenv iciโฆ
Dotenv.load('.env')
# quelques lignes qui appellent les clรฉs d'API de ton fichier .env
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["TWITTER_CONSUMER_KEY"]
con... | true |
45dff0d404c6c60974e48d368bd5fc81301ee715 | Ruby | joshdales/08-11-Reinforcing-exercise-API-Calls | /exercise.rb | UTF-8 | 216 | 2.921875 | 3 | [] | no_license | require 'HTTParty'
response = HTTParty.get('http://setgetgo.com/randomword/get.php')
words = []
k = 1
10.times do |k, v|
words[k] = HTTParty.get('http://setgetgo.com/randomword/get.php')
k += 1
end
puts words
| true |
bda831bdb461806f715d4819b3218b451278246a | Ruby | John-Odom/bringing-it-all-together-atlanta-web-071519 | /lib/dog.rb | UTF-8 | 2,526 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_accessor :id, :name, :breed
def initialize (props = {})
@id = props[:id]
@name = props[:name]
@breed = props[:breed]
end
def self.create_table
sql = <<-SQL
CREATE TABLE dogs (
id INTEGER PRIMARY KEY,
... | true |
7f37fa31e4ff45071b403bd795c57f210452519e | Ruby | thinkwell/yolk-client | /lib/yolk-client/client/enrollments.rb | UTF-8 | 1,986 | 2.546875 | 3 | [] | no_license | require 'time'
module Yolk
class Client
# Defines all api calls related to enrollments
module Enrollments
def enrollments options = {}
format_search_options options
response = get('enrollments', options)
prepare_enrollments response
end
def enrollments_by_entity ent... | true |
61ad1d54cdc1bdf0c01cdea24e84dd725da823d5 | Ruby | tomykaira/dropnico | /lib/youtube/url.rb | UTF-8 | 1,884 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'cgi'
module Youtube
class Url
def self.parse_map(encoded_stream_map)
encoded_stream_map.split(',').map { |part| self.new(part) }
end
def initialize(encoded_stream)
@encoded_stream = encoded_stream
end
def download_url
url = param('url')
if sig = param('sig')
... | true |
ffaa4fbb204d32b330b2bd89c94589ecdfaa9e1d | Ruby | sleeperbus/Ordin | /beginning_ruby/unittest.rb | UTF-8 | 469 | 3.109375 | 3 | [] | no_license | class String
def titlelize
self.gsub(/(\A|\s)\w/) { |letter| letter.upcase }
end
end
require 'minitest/autorun'
#require 'test/unit'
#class TestTitlelize < Test::Unit::TestCase
class TestTitlelize < Minitest::Test
def test_basic
assert_equal("This Is A Test", "this is a test".titlelize)
... | true |
de9c3ad85284c0fc1a9fd1890a317830f1fa8ab6 | Ruby | donjar/counting-stream | /app/counter_systems/median_counter_system.rb | UTF-8 | 357 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'counter_system'
require_relative '../helpers/array_averages'
Array.include ArrayAverages
# The query method in this class finds the median of all corresponding boxes.
class MedianCounterSystem < CounterSystem
def query(num)
@hash_functions.map { |hf| @counters[hf.... | true |
d6265a4b43fd51b652c2813ebbaff864f5bf318a | Ruby | wildkain/BlackJack | /interface.rb | UTF-8 | 1,434 | 3.578125 | 4 | [] | no_license | class Interface
def welcome_message
line
p 'Welcome to BlackJack game!'
p 'We hope you are Lucky Guy!'
line
end
def ask_name
p 'What is your name? Please enter:'
gets.chomp.to_s
end
def get_action
p "What you to do? Enter |'1' - Hit!|, |'2' - Stand|, |'3' - show cards|"
gets.... | true |
865e163ac91cbbe639ddc643f0c9b998af4bbcab | Ruby | danielmachado/kermitpfc-core | /lib/business/converter/twitter_converter.rb | UTF-8 | 3,253 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'json'
require_relative './converter'
require_relative '../../model/USMF/USMF'
require_relative '../../model/USMF/link'
require_relative '../../model/USMF/to_user'
require_relative '../../model/USMF/user'
require_relative '../../logging'
# @author Daniel Machado Fernandez
# @version 1.0
#
# Twitter Specificat... | true |
3df09beef9fd6c37bf8e27c89e89d6894c2c9a3d | Ruby | chsweet/viewing_party | /app/poros/actor.rb | UTF-8 | 186 | 2.59375 | 3 | [] | no_license | class Actor
attr_reader :name,
:role
def initialize(data)
@name = data[:name]
@role = data[:character]
@department = data[:known_for_department]
end
end
| true |
dfac4db411c3d6e799efcae1eb4a4e55cb3aef4c | Ruby | lhoj4228/coderbyte | /simplesymbols.rb | UTF-8 | 366 | 3.109375 | 3 | [] | no_license | def SimpleSymbols(str)
i = 0
while i < str.length
if str[i].ord > 96 && str[i].ord < 123
if (i == 0 || (i == str.length-1))
return "false"
end
if (str[i-1].ord != 43) || (str[i+1].ord != 43)
return "false"
end
end
i+=1
end
return "true"
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.