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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
975f233e66ba360081a54edf079c7945ea2c6de8 | Ruby | tbenbrahim/ojtemplate | /jtemplate/benchmarks/gcd.rb | UTF-8 | 132 | 2.96875 | 3 | [] | no_license | def gcd(a,b)
return a<b ? gcd(a,b-a) : a > b ? gcd(a-b,b) : a
end
a=0
for i in 1..10000 do
a=gcd(28388383,100101)
end
print(a)
| true |
f73c3ac0e1ba3afb8a1fe1b2dc0a411d66fc7a1e | Ruby | trendwithin/data_structures_algo | /lib/linked_list.rb | UTF-8 | 922 | 3.515625 | 4 | [] | no_license | class LinkedList
def initialize
@head = nil
@next = nil
end
def add(val)
node = Node.new(val, nil)
if @head.nil?
@head = node
else
node.next = @head
@head = node
end
@head.val
end
def search(val)
node = @head
while node != nil
return node.val if ... | true |
7b9b9afae5bdf5baeee03c1b4fe4b128bd7199e3 | Ruby | chip/fanfeedr | /lib/fanfeedr/client.rb | UTF-8 | 492 | 2.75 | 3 | [
"MIT"
] | permissive | require 'fanfeedr'
module Fanfeedr
class Client
attr_accessor :api_key
def initialize(api_key=nil)
raise ArgumentError if api_key.nil?
@api_key = api_key
end
def api_endpoint
'http://ffapi.fanfeedr.com/basic/api'
end
def get(url)
open(url).read
end
def f... | true |
c16ce63b11804aaf6793a3cb52f324d8271e4ea8 | Ruby | fwalch/imlab | /CodeGenerator/lib/schema/parser/index.rb | UTF-8 | 168 | 2.734375 | 3 | [
"MIT"
] | permissive | module Schema
class Index
attr_reader :name, :column_names
def initialize(name, column_names)
@name = name
@column_names = column_names.to_a
end
end
end
| true |
b4aee66efa6670708ffea7f69ebb90b4856c3745 | Ruby | itiut/sutra-copying | /metaprogramming-ruby/c03/scopes.rb | UTF-8 | 199 | 2.875 | 3 | [] | no_license | v1 = 1
class MyClass
v2 = 2
p local_variables
def my_method
v3 = 3
local_variables
end
p local_variables
end
obj = MyClass.new
p obj.my_method
p obj.my_method
p local_variables
| true |
702a18e02bc0c796cf99abe20d258f43e445c60c | Ruby | evizitei/lingq | /lib/lingq/client.rb | UTF-8 | 2,247 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'httparty'
module Lingq
class Client
include HTTParty
base_uri 'lingq.com/api_v2'
attr_reader :target_language
attr_reader :languages
def initialize(api_key)
@apikey = api_key
load_languages!
end
def learning_language?(language_code)
@languages.ind... | true |
9ef0aa862ff673bd8fc8854735cea28152fa411a | Ruby | osdakira/ruby_test | /practice/test04.rb | UTF-8 | 358 | 3.515625 | 4 | [] | no_license | # coding: utf-8
# 閏年判定
def is_leap_day(year)
if year % 4 == 0 and year % 100 != 0
puts "#{ year }は閏年です"
elsif year % 400 == 0
puts "#{ year }は閏年です"
else
puts "#{ year }は閏年ではありません"
end
end
is_leap_day 1992
is_leap_day 2000
is_leap_day 2001
(1900..2001).each{ | year | is_leap_day year }
| true |
cfe6519f1b1828b8558c45bb906dbd7b2099a671 | Ruby | V-Ron/Ruby-Task_list | /Task_list_rspec.rb | UTF-8 | 4,814 | 3.21875 | 3 | [] | no_license | require 'rspec'
require 'date'
require_relative 'Task'
# Story: As a developer, I can create a Task.
describe "Task" do
it "can create a Task" do
expect{Task.new}.to_not raise_error
end
# Story: As a developer, I can give a Task a title and retrieve it.
it "can name and retrieve a task" do
new_task = Tas... | true |
be2082c553d3a301bfe8a24d1463cc0cfd985407 | Ruby | zoodor/cosmic-hackathon | /lib/feelings_statements.rb | UTF-8 | 651 | 3.109375 | 3 | [] | no_license | class FeelingsStatement
attr_accessor :id
attr_accessor :title
def initialize(id, title)
@id = id
@title = title
end
def self.statements
[
FeelingsStatement.new(1, "Cleanliness"),
FeelingsStatement.new(2, "Video game selection"),
FeelingsStatement.new(3, "The doctors and nurses"),
Fee... | true |
3307f72630d9ffb70b58885871ef839e5269aa36 | Ruby | superherobtf1985/ruby-kadai | /level_1-7.rb | UTF-8 | 1,885 | 4.09375 | 4 | [] | no_license | # 7 以下の配列を操作し、適切な出力となるよう変換してください。破壊的メソッドも使用しています。
# また、この演習の出力はputsメソッドではなく、pメソッドを使用しています。
# メソッド○の部分を指定しましょう。
#
# array = [0, 9, 2, 7, 4, 5, 6, 3, 8, 1]
# p array.メソッド1
# 出力 -> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# p array.メソッド2
# 出力 -> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# array.メソッド3
# p array
# 出力 -> [0, 1, 2,... | true |
c72f7194cf732578e7955b93c5f256a83b51a44a | Ruby | azukibar81968/ButtonInput | /createJson.rb | UTF-8 | 634 | 2.90625 | 3 | [] | no_license | require "fileutils"
def trancerate(button)
answer_list = ['"expand"','"shrink"','"shift"']
answer = ''
if(button == 'a')
answer = answer_list[0]
end
if(button == 'b')
answer = answer_list[1]
end
if(button == 'c')
answer = answer_list[2]
end
return answer
end
def createBIJson(name,button_... | true |
9d8038a08e6d1b10fda5daf6f45b7cd238c0e6e2 | Ruby | EdmundLeex/others | /aa_course/assessment/a00/spec/a00_spec.rb | UTF-8 | 2,707 | 3.828125 | 4 | [] | no_license | require 'rspec'
require 'a00'
describe '#folding_cipher' do
it 'should use the folding cipher' do
expect(folding_cipher('a')).to eq('z')
expect(folding_cipher('d')).to eq('w')
end
it 'should encode words correctly' do
expect(folding_cipher('hello')).to eq('svool')
expect(folding_cipher('goodbye'... | true |
617ad14b5496c169ddf4e6690327ea817c89a3b8 | Ruby | marekpwk/phase_0_unit_2 | /week_4/2_creative/create_accountability_groups/my_solution.rb | UTF-8 | 1,797 | 4.125 | 4 | [] | no_license | # U2.W4: Create Accountability Groups
# I worked on this challenge [ with: Angela Kosek].
# 2. Pseudocode
# Input: method takes an arary of names
# Output: will return number of arrays with names in it for different groups
# Steps:
# DEF method create_group which takes an array as an argument
# Shuffle the array an... | true |
ce8b69e1103855dfaeffb2725e5bf752db1e43fd | Ruby | giorgimeladze/ruby_exercises | /January,10/my_csv.rb | UTF-8 | 511 | 3.40625 | 3 | [] | no_license | require 'csv'
require_relative 'animal'
class MyCSV
def MyCSV.add_info(pathname, animal)
CSV.open(pathname, "a+") do |csv|
csv << animal.to_s.split(",")
end
end
def MyCSV.read_info(pathname, animals)
CSV.foreach(pathname, headers: true) do |row|
animals << Animal.new(row["specie"],row["age"],row["c... | true |
6275e7537528830d005229977442e03aebd85b00 | Ruby | antrix1/The-Odin-Project | /Ruby Programming/Ruby on the Web/A Real Web Server and Client/server.rb | UTF-8 | 892 | 2.75 | 3 | [] | no_license | require 'socket'
require 'json'
server = TCPServer.open('localhost', 3000)
loop do
Thread.start(server.accept) do |session|
request = session.read_nonblock(256)
header, body = request.split("\r\n\r\n", 2)
header = header.split(' ')
method = header[0].chomp
path = header[1][1..-1].chomp
if F... | true |
5fc1f476988bfafd1cfa68f9e3a9ab28ce662418 | Ruby | ping4/cequel | /lib/cequel/record/lazy_record_collection.rb | UTF-8 | 2,398 | 2.671875 | 3 | [
"MIT"
] | permissive | module Cequel
module Record
#
# Encapsulates a collection of unloaded {Record} instances. In the case
# where a record set is scoped to fully specify the keys of multiple
# records, those records will be returned unloaded in a
# LazyRecordCollection. When an attribute is read from any of the recor... | true |
37e66255990b9f765d6dca8cd24655043b96c58c | Ruby | AlexanderCode/Launch_School | /foundations/circular_buffer.rb | UTF-8 | 1,235 | 4.3125 | 4 | [] | no_license | # this is an array where wer are using shift and push to remove or add things
# if teh buffer is full we need an argument to be raised
# if the buffer is empty we need a an argument raised
# a method read will pull out the oldest number in the buffer and
# delete it while outputing it to the user
# a method write ... | true |
70c47d6fa918a79068d0d5471a202336fd8a53c0 | Ruby | nsweeting/object_validator | /lib/object_validator/validator.rb | UTF-8 | 1,342 | 2.84375 | 3 | [
"MIT"
] | permissive | module ObjectValidator
module Validator
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
end
module InstanceMethods
attr_reader :object, :errors
def initialize(object)
@object = object
@errors = Errors.new
end
def... | true |
71468ad3ba1f67cefa9a424423a69317fd89b505 | Ruby | dentarg/gists | /gists/bunny-6f0c/amqp_helper.rb | UTF-8 | 1,267 | 3.078125 | 3 | [] | no_license | require "securerandom"
require "bunny"
class AmqpHelper
def self.publish(queue_name)
conn = Bunny.new
conn.start
ch = conn.create_channel
q = ch.queue(queue_name)
x = ch.default_exchange
x.publish("Hello!", :routing_key => q.name)
sleep 0.5
conn.close
end
def self.peak(queue... | true |
1b16d2c8094384af261b6b4f5671c1245c3af9dc | Ruby | mattetti/pomodori | /lib/pomodori/countdown.rb | UTF-8 | 464 | 3.84375 | 4 | [] | no_license | ##
# Counts from the given number of seconds down to zero. You can give
# an optional block to the countdown to call when zero is reached.
#
class Countdown
attr_accessor :secs, :callback
def initialize(secs, block = lambda {})
@secs = secs
@callback = block
end
def mins
@secs / 60
end
... | true |
55ff84547ea6f864f34d6d1d51db7109acf5f6c3 | Ruby | mrdziuban/App-Academy-Questions | /questions_database.rb | UTF-8 | 11,174 | 2.75 | 3 | [] | no_license | require 'singleton'
require 'sqlite3'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super("user_questions.db")
self.results_as_hash = true
self.type_translation = true
end
end
class User
attr_accessor :fname, :lname
attr_reader :user_id
def initialize(options ... | true |
3ef0e38925f053e1c35ce29fb286e9abb13d078d | Ruby | lreyeswebdev/ruby-day5 | /solid.rb | UTF-8 | 2,971 | 3.90625 | 4 | [] | no_license | #Single Responsibility Principle
#class is responsible for only one aspect of the program
class Age
def initialize(current_year, birth_year)
@current_year = current_year
@birth_year = birth_year
end
def current_age
@current_year - @birth_year
end
end
baby = Age.n... | true |
55e33fe58b72f8c7b0290330c4bc7dfcf5a104d2 | Ruby | alphagov/licence-finder | /spec/lib/data_importer_spec.rb | UTF-8 | 2,196 | 2.625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "data_importer"
RSpec.describe DataImporter do
describe "call" do
it "imports relevant file and then close it" do
fh = double
expect(fh).to receive(:close)
allow(DataImporter).to receive(:open_data_file).and_return(fh)
importer = double
expect(importer... | true |
bd428ca675fe8eab34175b7edbdc5812663aee0d | Ruby | updatus/algorithms | /sorting/merge_sort.rb | UTF-8 | 466 | 3.828125 | 4 | [] | no_license | def merge_sort array
return array if array.size <= 1
mid = array.size / 2
left = array[0, mid]
right = array[mid, array.size]
merge(merge_sort(left), merge_sort(right))
end
def merge(left, right)
sorted = []
until left.empty? || right.empty?
if left.first <= right.first
sorted << left.shift
... | true |
dffa83a874a501857736784883fc52e1138fd9dc | Ruby | Tezzagio/marvel_api | /heros.rb | UTF-8 | 149 | 2.75 | 3 | [] | no_license | #heros.rb
class Characters
attr_accessor :name
def initialize(name)
@name = name
end
end
require_relative 'superheros.rb'
| true |
d1c1241dce5fbc9d5b41584722450a44e9503dce | Ruby | crystax/android-crew | /library/formula.rb | UTF-8 | 4,788 | 2.53125 | 3 | [] | no_license | require 'json'
require 'digest'
require 'fileutils'
require_relative 'extend/module.rb'
require_relative 'release.rb'
require_relative 'utils.rb'
class Formula
PROPERTIES_FILE = 'properties.json'
def self.package_version(release)
release.to_s
end
def self.split_package_version(pkgver)
r = pkgver.sp... | true |
0a243ebb2f3af5eaf22ef5b1c2c3ee04e2c8adf8 | Ruby | foreverj/ruby | /loop.rb | UTF-8 | 749 | 3.9375 | 4 | [] | no_license | #1
number =0
loop do
break if number>15
puts "The number inside the loop is #{number}"
number += 1
end
#2
number = 0
until number>15 do
puts "The number inside the loop is #{number}"
number +=1
end
#3
number = 0
while number<16 do
puts "The number inside the loop is #{number}"
number +=1
end
#4
number = 0
16.... | true |
d770a6cf4cf4687b293788755165a2b7c540a774 | Ruby | animegrafmays/fedi_ebooks | /mispy/model.rb | UTF-8 | 11,970 | 3.015625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
# rubocop:disable Style/StringLiterals
require "digest/md5"
require "csv"
require "set"
require "uri"
require "yajl/json_gem"
require_relative "nlp"
require_relative "suffix"
class Model
# @return [Array<String>]
# An array of unique tokens. This is the main source of actual strings
# in the m... | true |
f363fef3a0f2268e636e5d63baf0a1d5c023b599 | Ruby | Tomonori-Sasaki/applied_phys_wiki | /app/models/history.rb | UTF-8 | 591 | 2.640625 | 3 | [] | no_license | class History < ApplicationRecord
validates :word, presence: true
validates :word, length: { maximum: 15 }
validates :name, presence: true
validates :examination, presence: true
def self.search(search) #self.でクラスメソッドとしている
if search # Controllerから渡されたパラメータが!= nilの場合は、titleカラムを部分一致検索
History.where(['n... | true |
fbc322b074fee1af92cfec0b2e445c55421395ff | Ruby | benrodenhaeuser/exercises | /small_problems/11_Medium_02/09_bubble_sort.rb | UTF-8 | 926 | 4.25 | 4 | [] | no_license | # bubble sort works by making multiple passes through the array
# we repeatedly go through the array from left to right comparing pairs of values
# if the left value is larger than the right value, we swap them
# if we do a passthrough without swaps, we are done: the array is sorted
def bubble_sort(array)
(array.siz... | true |
fe1106a2dde0d58695a28072d242e84761e981d5 | Ruby | andmitriy93/App_Academy_Homework | /W4/D1/GraphNode.rb | UTF-8 | 930 | 3.625 | 4 | [] | no_license | require 'set'
class GraphNode
attr_accessor :value, :neighbors
def initialize(value)
self.value = value
self.neighbors = []
end
def bfs(starting_node, target_value)
visited = Set.new()
queue = [starting_node]
until (queue == [])
if !queue.first.nei... | true |
b174400f2374d92be87d7b102655b5a64778f698 | Ruby | catarse/catarse | /lib/tasks/users.rake | UTF-8 | 1,971 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
####
# Task to manage the application users
##
namespace :users do
###
# Syncs users with newsletter
# usage: rake users:sync_with_mailee
##
desc 'This task will sync the users with newsletter = true with Mailee.'
task sync_with_mailee: :environment do
print 'Synchronizing... | true |
ef5da0f2408857f4096fcc0c2eb3d697052d401a | Ruby | taminhtien/demo-cancancan | /app/controllers/projects_controller.rb | UTF-8 | 1,449 | 2.578125 | 3 | [] | no_license | class ProjectsController < ApplicationController
before_action :load_projects, only: :index
load_and_authorize_resource
# It composed of two method: load_resource and authorize_resource
# load_resource is going to load the record
# authorize_resource is going to check if the user is authorized to perform a... | true |
7cf1703fd5c0ce17ae6ff9753d4a4a6de2a494bf | Ruby | wolovim/turing_mastermind | /lib/guess.rb | UTF-8 | 244 | 3.0625 | 3 | [] | no_license | class Guess
attr_reader :formatted_guess, :string_guess, :timestamp
def initialize(formatted_guess, timestamp)
@formatted_guess = formatted_guess
@string_guess = formatted_guess.join('').chomp
@timestamp = timestamp
end
end
| true |
cb84c9bcc851badb693487820a62357b419b873b | Ruby | l0v1s/student-directory | /directory.rb | UTF-8 | 1,785 | 4.03125 | 4 | [] | no_license |
def input_student
print "Please enter the names of the students\n"
print "To finish, enter exit\n"
students = []
loop do
name = gets.strip
break if name == "exit"
puts "Now enter their cohort"
cohort = gets.strip
break if cohort == "exit"
students << new_student(name, cohort)
print "Now we have... | true |
6b75db678fc6089c452e61308efd297f98539d3e | Ruby | ajivani/sample_app | /spec/models/user_spec.rb | UTF-8 | 7,353 | 2.6875 | 3 | [] | no_license | require 'spec_helper'
describe User do
#pending "add some examples to (or delete) #{__FILE__}"
before(:each) do
@attr = {
:name=> "Sammy Junior Example",
:email=>"example@email.com",
:password=>'foobar',
:password_confirmation=>'foobar'
}
@user ... | true |
6278f6cd6072ce7c7aa006ad454008fd285af6c0 | Ruby | rusilko/iqm | /app/models/quote.rb | UTF-8 | 1,869 | 2.734375 | 3 | [] | no_license | # == Schema Information
#
# Table name: quotes
#
# id :integer not null, primary key
# offer_id :integer
# name :string(255)
# number_of_days :integer
# created_at :datetime not null
# updated_at :datetime not null
# event_date :date
# vat ... | true |
8a51fa5b9d912da3ae8366c6048ec72e226f6990 | Ruby | KayCaesar/cs105b | /movies-2/movie_data.rb | UTF-8 | 7,569 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby
#Eden Zik
#MovieData processor program
#v2.0
#load_data - this will read in the data from the original ml-100k files and stores them in whichever way it needs to be stored
#popularity(movie_id) - this will return a number that indicates the popularity (higher numbers are more popular). You should b... | true |
8768ac718dc35675c09c9a53c4ae2a76fe9eeb12 | Ruby | sree300994/ruby | /ecom/assignments/location.rb | UTF-8 | 224 | 3.453125 | 3 | [] | no_license | class Location
attr_accessor :address
attr_reader :id
@@count = 1
def initialize(details)
@address = details[:address]
@id = @@count
@@count += 1
end
def details
"#{id} - #{address}"
end
end | true |
35868cdbf2d80e1fef0e783bf231c819055320cc | Ruby | bahayg/ruby-oo-relationships-practice-blood-oath-exercise-seattle-web-102819 | /tools/console.rb | UTF-8 | 802 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
Cult1 = Cult... | true |
6301d3ffe91f95ad6f9ce1fb0e1b7163f0b26ceb | Ruby | luislaugga/bonekit | /examples/devices/compass.rb | UTF-8 | 326 | 2.609375 | 3 | [
"MIT"
] | permissive | # Compass - Simple test of the functionality of the HMC5883L 3-Axis Digital Compass IC
#
# Connections:
# VCC to pin P9-4 (VDD_3V3)
# GND to pin P9-2 (DGND)
# SCL to P9_19 (I2C2_SCL)
# SDA to P9_20 (I2C2_SDA)
#
require 'bonekit'
compass = HMC5883L.new
loop do
puts "Heading: #{compass.heading} degrees"
sleep(0.1... | true |
c14a32446da5250e7e2ba8e203df7eeb610937b1 | Ruby | marcvinues/ironhack | /1st week/day one and two/person.rb | UTF-8 | 181 | 3.75 | 4 | [] | no_license | class Person
attr_reader :name
attr_accessor :age
def initialize name, age
@name = name
@age = age
end
end
p = Person.new "Pepe", 29
puts p.name
p.age = 30
puts p.age | true |
b30065d840602debda16d1434246597d86d84736 | Ruby | pawjer/purple-recruitment | /pixel_family_simulation.rb | UTF-8 | 1,191 | 3.359375 | 3 | [] | no_license | require_relative 'config/environment'
initial_family_size = 0
puts 'Welcome to Pixels Family Growth Simulation'
unless initial_family_size.to_i >= 2
puts 'How much Pixels should be Family founders? Must be at least 2 members. [default: 2]'
resp = gets.chomp
initial_family_size = resp.blank? ? 2 : resp.to_i
end
... | true |
da40aeb51d72af89da1da1d0b58d5fd009a27110 | Ruby | souzamp/TDD_with_rspec_ruby_rails | /exemplo_rspec_tdd/helpers/helper.rb | UTF-8 | 93 | 2.640625 | 3 | [] | no_license | module Helper
def fruta # helper method arbitrário
%w(banana laranja uva).sample
end
end | true |
564d286f94046a15e164040426369d6f1222e8b9 | Ruby | Mnargh/learn-to-program | /chap13/orangetree.rb | UTF-8 | 2,398 | 4.46875 | 4 | [] | no_license | #!/usr/local/rvm/rubies/ruby-2.3.4/bin/ruby
=begin
height method that returns its height and a one_year_passes method that,
when called, ages the tree one year. Each year the tree grows taller
(however much you think an orange tree should grow in a year),
and after some number of years (again, your call) the tr... | true |
39b13d9da30d687b968ee04d2532c2c2dd4123d7 | Ruby | spcwhls/intro-to-programming | /more_stuff/exercise2.rb | UTF-8 | 216 | 3.890625 | 4 | [] | no_license | #what will the following print to the screen? what will it return?
def execute(&block)
block
end
execute { puts "Hello from inside the execute method!" }
# prints - nothing, not called
# retruns a Proc Object | true |
6bcccc434dd53117a29ac5677961cdf1f5d52fd7 | Ruby | be9/strokedb | /strokedb-ruby/lib/data_structures/simple_skiplist.rb | UTF-8 | 11,430 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'thread'
require File.expand_path(File.dirname(__FILE__) + '/../util/class_optimization')
module StrokeDB
# Implements a thread-safe skiplist structure.
# Doesn't yield new skiplists
class SimpleSkiplist
include Enumerable
DEFAULT_MAXLEVEL = 32
DEFAULT_PROBABILITY = 1/Math::E
... | true |
0e4d4fa1d8292a9a72e3ca41f8b29bd0d27f8df5 | Ruby | itggot-Emanuel-Strom/standard-biblioteket | /lib/max_of_four.rb | UTF-8 | 208 | 2.875 | 3 | [] | no_license | def max_of_four(num1, num2, num3, num4)
max = num1
if num2 > max
max = num2
end
if num3 > max
max = num3
end
if num4 > max
max = num4
end
return max
end
| true |
9f4bdc2819d6388395fed04b17945872ed37c696 | Ruby | oluyoung/log-parser | /paths.rb | UTF-8 | 933 | 2.78125 | 3 | [] | no_license | require_relative 'path'
require_relative 'log_validator'
class Paths
include LogValidator
attr_accessor :paths
def initialize
@paths = {}
end
def add_path(path, ip)
if !(path_exists path) && !(is_invalid_line path, ip)
@paths[path] = Path.new
end
if path_exists path
@paths[path]... | true |
74998f41b24ac58d7f1fa1a8df9d373a388c53ec | Ruby | ShanegisKhan/learn_ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 475 | 3.875 | 4 | [] | no_license | #write your code here
def vowel? string
isVowel = false
vowels = ["a", "e", "i", "o", "u"]
wordList = string.split(' ')
wordList.each do |word|
vowels.each do |vowel|
if word[0] == vowel
isVowel = true
end
end
end
return isVowel
end
d... | true |
60a544579990b1dd5a2719c6d0833f44c7ddf28b | Ruby | fbrute/lovy | /retros/src/retrostat/main/ruby/lib/trajectory_classifier_for_one_backtraj.rb | UTF-8 | 1,692 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
# get a gate in (nwap, swap, neap, sa, north, ind ) for a particular backtraj (station, level, date)
# the above params are required and expected
# used with django lovysimulation to get the gate associated to a Backtraj model.
require_relative 'trajectory_stat_for_on... | true |
2bb17628da44c2a9b8f4cbe7060f3cfbee5e7b99 | Ruby | abbritt/parttimeruby | /99bot.rb | UTF-8 | 322 | 3.484375 | 3 | [] | no_license | bottles = 99
while bottles != 0
puts bottles.to_s + ' bottles of beer on the wall, ' + bottles.to_s + ' bottles of beer.'
bottles = bottles - 1
puts 'Take one down and pass it around, ' + bottles.to_s + ' bottles of beer on the wall.'
puts ''
end
## bottles need to be converted to a string or else this won't work fy... | true |
6d70a39c77b6a5caa50e71661fd589fed55fa1d3 | Ruby | czuger/meq-online | /lib/tasks/aasm_to_graphviz.rake | UTF-8 | 1,482 | 2.609375 | 3 | [
"MIT"
] | permissive | desc 'Print board graph'
task :print_board_graph => :environment do
def print_current_state_transitions_and_deep( _object, states, transitions, events )
states.each do |state|
_object.aasm_state = state
_object.aasm.events(:permitted => true).map(&:name).each do |event_name|
events << even... | true |
33d849a2fe66e4804a035b9828e405c64fa773cf | Ruby | garalo/pakmongo | /app/lib/people_controller.rb | UTF-8 | 1,841 | 2.640625 | 3 | [] | no_license | class PeopleController
include Pakyow::Helpers
def index
# person = Person.new(:first_name => "Ludwig", :last_name => "Beethoven")
# person.save
# puts "Hello, I am #{person.first_name} #{person.last_name}"
# puts "------------"
# Gets the full collection of stored messages
peo... | true |
ea3e6525c3639fe27851537a00b8b2176a6bd3f1 | Ruby | soulclimberchick/kele | /lib/kele.rb | UTF-8 | 882 | 2.71875 | 3 | [] | no_license | require 'httparty'
require 'json'
require './lib/roadmap'
require './lib/messaging'
class Kele
include HTTParty
include Roadmap
include Messaging
base_uri "https://www.bloc.io/api/v1/"
def initialize(email, password)
response = self.class.post(base_api_url("sessions"), body: { "email": email, "password":... | true |
02c84c088182739a78c595b4b92fe80002d541ba | Ruby | benlovell/ramaze | /lib/ramaze/snippets/ramaze/state.rb | UTF-8 | 2,001 | 3.046875 | 3 | [
"Ruby"
] | permissive | module Ramaze
class State
def initialize
@core = detect
end
def detect
require 'fiber'
@extract = :resume
Ramaze::Fiber
rescue LoadError
@extract = :value
::Thread
end
def [](key)
@core.current[key]
end
def []=(key, value)
@core.curren... | true |
d18c08aaba9ae10598e71a4a81897cfe27f4b929 | Ruby | trizen/sidef | /scripts/Tests/array_binsert.sf | UTF-8 | 723 | 3.484375 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
# Array.binsert()
var list = ["Jane", "Joe", "John", "Kate"]
var names = %w(Emmaline
Britteny
Shonna
Nicolasa
Marilu
Lizzette
Elinor
Tiffanie
Diego
Arturo
).shuffle
for name in names {
lis... | true |
8096a536fea1c670c7fdd56345131afcdf9fb060 | Ruby | shivhg/bootcamp | /spec/line_spec.rb | UTF-8 | 1,804 | 3.453125 | 3 | [] | no_license | require_relative '../point'
require_relative '../line'
describe Line do
describe "#length" do
it 'when points are equal is 0' do
p = Point.new(5, 5)
line = Line.new(p, p)
expect(line.length).to eq(0)
end
it 'when points differ retuns the distance between them' do
p1 = Point.new(5... | true |
88d61e63ae5191ccf83934aeda852dd5683d2462 | Ruby | arufino/skillcrush104-challenges | /13_love_loop.rb | UTF-8 | 164 | 3.5625 | 4 | [] | no_license | puts "I love you so much! Do you love me back?"
answer = gets.chomp
while answer != nil
puts "I love you so much! Do you love me back?"
answer = gets.chomp
end | true |
e2e6e0cab950a60afb9a2fd3f447e6316e3f0e51 | Ruby | threefoldtech/threefold-forums | /lib/socket_server.rb | UTF-8 | 1,673 | 2.984375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-other-copyleft",
"GPL-2.0-or-later"
] | permissive | # frozen_string_literal: true
require 'socket'
class SocketServer
def initialize(socket_path)
@socket_path = socket_path
@server = nil
end
def start(&blk)
@server = UNIXServer.new(@socket_path)
@accept_thread = new_accept_thread
if blk
@blk = blk
end
end
def stop
@server... | true |
760cf08e928d90f53b3a6b1c5a2f70765ee5044b | Ruby | esterOliveiraS/EstudosRuby | /oneBitCode/entradaEsaida.rb | UTF-8 | 334 | 3.59375 | 4 | [
"Apache-2.0"
] | permissive | # SAIDA DE DADO
print "Digite seu nome: "
# RECEBENDO UMA ENTRADA DO TECLADO
name = gets.chomp
# SAIDA DE DADO
print "Digite seu sobrenome: "
# RECEBENDO UMA ENTRADA
sobrenome = gets.chomp
# SAÍDA UTILIZANDO PUTS
# USE CÓDIGOS RUBY DENTRO DE UMA STRING COM #{CODE}
puts "Hello, #{name} #{sobrenome}!"... | true |
b4fc55244911dc109b8cecf52548e919c24a0b80 | Ruby | Max-Leopold/LeetCode | /src/main/other/advent_of_code_2021/day12/day12.rb | UTF-8 | 2,032 | 3.890625 | 4 | [] | no_license | require 'set'
input = File.open(File.join(File.dirname(__FILE__), "input.txt"), "r")
class Cave
attr_reader :start, :end, :big, :edges, :name
def initialize(name)
@name = name
@start = name == :start ? true : false
@end = name == :end ? true : false
@big = name == name.upcase... | true |
d4d30c0878b44f4dffbe0d6904938a09008467ef | Ruby | brandyaustinseattle/grocery-store | /lib/order.rb | UTF-8 | 1,652 | 3.1875 | 3 | [] | no_license | require 'csv'
require 'awesome_print'
require 'money'
I18n.enforce_available_locales = false
module Grocery
class Order
attr_reader :id, :products
def initialize(id, products)
@id = id
@products = products
end
def total
sum = 0
@products.values.each do |price|
sum +=... | true |
8369d78ef4f6f48a584d73b70930ef4bcfc52a9d | Ruby | boy-jer/cityslicking---daily-deal | /libraries/authentication.rb | UTF-8 | 1,836 | 2.640625 | 3 | [] | no_license | #
# Authentication helpers can be used anywhere in the site
# Usually they'll be at the beginning of a method, or used as a before filter
#
helpers do
# User must be signed in
def auth_slicker
unless session[:user]
session[:flash] = 'You must be signed in to see that page.'
... | true |
7bc365a29c6825dd7cd65d776a5aa0e2d76277e9 | Ruby | QPC-WORLDWIDE/rubinius | /benchmark/rubinius/bm_loop_comparison.rb | UTF-8 | 707 | 3.0625 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'benchmark'
total = (ENV['TOTAL'] || 1_000_000).to_i
Benchmark.bmbm do |x|
x.report("while") do
i = 0
while(i < total)
i
i += 1
end
end
x.report("until") do
i = 0
until(i == total)
i
i += 1
end
end
x.report("do while") do
i = 0
begin
... | true |
c277f5ba5de16a17165fdbcf3301ee415bce91a9 | Ruby | danielidr/cuentasbancarias_barajadecartas | /barajas.rb | UTF-8 | 665 | 3.40625 | 3 | [] | no_license | require_relative 'carta'
class Baraja
attr_accessor :cartas
def initialize()
@cartas = []
pintas = ['C', 'D', 'E', 'T']
carta = ''
pintas.each do |pinta|
numero = 0
until numero==13
numero = numero.succ
carta = Carta.ne... | true |
56f401bfb61bf62a2fd33f780bba61b9d150f8e1 | Ruby | MatthiasGi/Tapeinos | /test/models/plan_test.rb | UTF-8 | 2,799 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class PlanTest < ActiveSupport::TestCase
test "Title is mandatory" do
plan = Plan.new(remark: 'Blabla')
assert_not plan.valid?, "No title given"
plan = Plan.new(title: 'Title')
assert plan.valid?, "Title given, but still wrong?"
end
test "Linked to events" do
plan = P... | true |
9cdf72722e50ac2800d17fc4929b776086012e13 | Ruby | ollie789/hw | /hackers/rich_field/w1d4/rental_app/apartment.rb | UTF-8 | 409 | 3.5 | 4 | [] | no_license | class Apartment
attr_accessor :price, :sqft, :num_beds, :num_bathrooms, :occupants
def initialize(sqft, num_beds, num_bathrooms)
@price = price
@sqft = sqft
@num_beds = num_beds
@num_bathrooms = num_bathrooms
@occupants = []
end
# def to_s
# "The apartment is #{@sqft} square feet and h... | true |
ca8b8e95199ba16b372abf43edddc4c24c3b6ed6 | Ruby | fredmorcos/attic | /Projects/Intramarks/intramarks_ruby_2/errors.rb | UTF-8 | 510 | 2.8125 | 3 | [
"Unlicense"
] | permissive | class DBConnectionError < Exception; end
class StorageError < Exception; end
def die (msg, usage, quit)
$stderr.puts msg if msg.nil? == false
if usage
$stderr.puts ""
print_usage
end
abort if quit
end
def print_usage
$stderr.puts <<EOS
Usage: fumarks.rb COMMAND
Commands:
add URL TITLE TAGS [SHO... | true |
5b05e83454a5aad944cfa22e3ecf64547b5b71f4 | Ruby | AnnK89/medium-article | /01-Ruby/01-Programming-basics/Optional-04-Morse-Code/lib/decoder.rb | UTF-8 | 762 | 3.46875 | 3 | [] | no_license | def decode(morse_text)
# TODO: Decode the morse text you just got!
morse_text.downcase.split("|").map { |morse_word| decode_word(morse_word) }.join(" ")
end
def decode_word(morse_word)
morse_word.split(" ").map { |morse_letter| MORSE_CODE.key(morse_letter) }.join.upcase
end
MORSE_CODE = {
"a" => ".-",
"b" ... | true |
4944927c61bb891b4be23c3e9f79300f8cd73c28 | Ruby | sjreich/Exercises-for-Programmers_57-Challenges | /ch2/ex2/ex2.rb | UTF-8 | 488 | 4.15625 | 4 | [] | no_license | # how to write the test
class Greeter
def run!
name = get_name
puts greet(name)
end
def greet(name)
select_greeting.gsub('<name>', name)
end
private
GREETINGS = [ "Hi, <name>!",
"Hi diddly-ho, <name>!",
"So, <name>... We meet again.",
"What's ne... | true |
779bab14d1e0c7933bf837d0c8289156a9ae942d | Ruby | willmclellarn/Launch-School-All | /ls_lesson_3_copy/medium_one-q8.rb | UTF-8 | 353 | 2.796875 | 3 | [] | no_license | def rps(fist1, fist2)
if fist1 == "rock"
(fist2 == "paper") ? "paper" : "rock"
elsif fist1 == "paper"
(fist2 == "scissors") ? "scissors" : "paper"
else
(fist2 == "rock") ? "rock" : "scissors"
end
end
# rock x scissors = rock
# rock x paper = paper
# rock x paper = paper
# rock x paper = paper
# end... | true |
cbd2edd3e732d9f0cd9f0b4521d73f74903f7ff3 | Ruby | steveninouye/Ruby-Mastermind | /lib/mastermind.rb | UTF-8 | 1,945 | 3.65625 | 4 | [] | no_license | class Code
attr_reader :pegs
PEGS = {
"R" => "red",
"G" => "green",
"B" => "blue",
"Y" => "yellow",
"O" => "orange",
"P" => "purple"
}
def initialize (pegs)
@pegs = pegs
end
def self.parse (str)
pegs = str.split("").map do |ltr|
raise "Invalid Input" if !PEGS.ha... | true |
54e52b4adb7226d29997c178dfd18ac6ca0ee1f2 | Ruby | yulia-2008/ruby-enumerables-cartoon-collections-lab-part-1-nyc04-seng-ft-062220 | /cartoon_collections.rb | UTF-8 | 193 | 3.46875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def greet_characters(array)
array.each do |index|
puts "Hello #{index}!"
end
end
def list_dwarves(array)
array.each_with_index do |num, index|
puts "#{index+1}. #{num}"
end
end
| true |
2c9820037d0c13c5da21a86901a0d30e6afd38c2 | Ruby | urubatan/ruby101samples | /intro/01soma.rb | UTF-8 | 45 | 3.015625 | 3 | [
"MIT"
] | permissive | def soma a, b
a + b
end
puts soma 1, 2 | true |
c400e9c02c3dffd25bac00680fb81663a6561383 | Ruby | caruby/core | /test/lib/caruby/helpers/properties_test.rb | UTF-8 | 1,213 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../../helper'
require "test/unit"
require 'caruby/helpers/properties'
class PropertiesTest < Test::Unit::TestCase
FIXTURES = File.dirname(__FILE__) + '/../../../fixtures/caruby/util/properties'
INPUT_FILE = File.join(FIXTURES, 'properties.yaml')
MERGE_FILE = File.join(FIXTURES,... | true |
b8f269cc7618b47398d9f5720316485a592ce1d8 | Ruby | Alux77/Fund.-web-17 | /db/seeds.rb | UTF-8 | 821 | 2.578125 | 3 | [] | no_license | File.open('1_libros.csv').each do |line|
new_line = line.strip.split(",")
question = Question.create(deck: 1, question: new_line[0], answer: new_line[1], op_a: new_line[2], op_b: new_line[3], op_c: new_line[4])
end
File.open('2_peliculas.csv').each do |line|
new_line = line.strip.split(",")
question = Question... | true |
0127161371fa612fd32b1b2225f83bbe9a75e6cf | Ruby | sh19910711/codeforces-1000-problems | /script/find_contests.rb | UTF-8 | 187 | 2.578125 | 3 | [] | no_license | # gem install codeforces
require "codeforces"
Codeforces.contests.rounds.div2.slice(0, 346-200).reverse.each do |c|
puts "* [ ] [#{c.name}](http://codeforces.com/contest/#{c.id})"
end
| true |
4f204bbfeb521d8ad624c3e08cb71b690d31d3e5 | Ruby | gooddb67/oo-cash-register-web-082817 | /lib/cash_register.rb | UTF-8 | 734 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
require 'pry'
class CashRegister
attr_accessor :total, :discount, :last_transaction
ITEMS = []
def initialize(discount = nil)
@total = 0
@discount = discount
@items = []
end
def add_item(title, price, quantity = 1)
@total += (price * quantity)
quantity.times {@items << title}
... | true |
fe833d194738bc66551172bb5c756a04685d2bd5 | Ruby | pse4/system | /ICD_range_parser/code/adapter.rb | UTF-8 | 670 | 2.765625 | 3 | [] | no_license | require 'mongo'
include Mongo
class Adapter
attr_accessor :mongo_client, :db, :coll, :write
def initialize (db , collection ,host, port, write)
mongo_client = MongoClient.new(host, port)
self.write = write
if write
puts 'Enter your PW for the account pse4_write: '
mongo_client.db('admin').a... | true |
ae9d7b2df438e0a98bea9f5c5ad6daa54c224afd | Ruby | jamaga/temp_exercise | /kalkulator2_test.rb | UTF-8 | 867 | 2.78125 | 3 | [] | no_license | require 'test/unit'
require './kalkulator2.rb'
class KalkulatorDwaTest < Test::Unit::TestCase
def test_wykonaj_dzialanie
k = KalkulatorDwa.new
assert_equal 9, k.wykonaj_dzialanie('dodaj|2,3,4')
assert_equal 2, k.wykonaj_dzialanie('odejmij|5,2,1')
assert_equal 30, k.wykonaj_dzialanie('mnoz|5,2,3')
... | true |
cd1a2ce91a0cae09bbe52aab1dc7433fe1d8fce7 | Ruby | theforeman/chef-handler-foreman | /lib/chef_handler_foreman/foreman_uploader.rb | UTF-8 | 2,985 | 2.515625 | 3 | [
"MIT"
] | permissive | #This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITH... | true |
49e5d092cb41dc831c9d8f852cd74e5b19d391ab | Ruby | 0exp/evil_events | /lib/evil_events/shared/type_converter/converter.rb | UTF-8 | 951 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class EvilEvents::Shared::TypeConverter
# @api public
# @since 0.2.0
class Converter
# @return [Proc]
#
# @api public
# @since 0.2.0
attr_reader :coercer
# @param coercer [Proc]
#
# @api public
# @since 0.2.0
def initialize(coercer)
rai... | true |
851b1386140ab096b572599a432e265ae78a35f8 | Ruby | aaecheverria96/oo-counting-sentences-onl01-seng-pt-072720 | /lib/count_sentences.rb | UTF-8 | 434 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
if self.end_with?(".","?")
return true
else
return false
end
end
def question?
if self.end_with?("?")
return true
else
return false
end
end
def exclamation?
if self.end_with?("!")
return true
else
return false
end
end
def count_sentences
sp... | true |
20b4ab4e4658f2d2fa90dbec76527a541d09541b | Ruby | kiran-gurujada/pickaxe | /chapter9/comparison_operators.rb | UTF-8 | 1,066 | 4.5 | 4 | [] | no_license | # Ruby objects support comparison using the methods
# ==, ===, <=>, =~, eql? and equal?
#
# All but <=> are defined in class Object but may be overridden by
# descendants. E.g. Array redefines == so that arrays are equal if
# number and corresponding elements are the same.
# ==
# Test for equal value
# ===
# ?
# <=>... | true |
1c99b8a82f2d8e70b81acaa35c89ee6d0304b29a | Ruby | jameswalmsley/docthunder | /lib/docthunder/version.rb | UTF-8 | 1,118 | 2.515625 | 3 | [
"MIT"
] | permissive | class DocThunder
class Project
class Version
attr_reader :name
attr_accessor :files
def initialize(name, config)
@name = name
@config = config
@files = []
end
def parse(docthunder)
#puts " * Checking out #{@name} into #{@config.workdir}"
D... | true |
e9dbc47df53f3dfcbd046e28044e0962072d9111 | Ruby | noma4i/htmldiff-lcs | /spec/diffing_output/text_spec.rb | UTF-8 | 1,716 | 2.890625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
describe 'HTMLDiff' do
describe 'diff' do
describe 'text' do
it 'should diff text' do
diff = HTMLDiff.diff('a word is here', 'a nother word is there')
expect(diff).to eq("a <del class=\"diffmod\">word is here</del>"\
"<ins class=\"d... | true |
0a4400eb867d741499634d460f728f14257e1c88 | Ruby | jyschwrtz/leetCode-practice | /my_calendar_three.rb | UTF-8 | 722 | 3.65625 | 4 | [] | no_license | class MyCalendarThree
def initialize()
@bookings = Hash.new(0)
@overlap = 0
end
=begin
:type start: Integer
:type end: Integer
:rtype: Integer
=end
def book(start_time, end_time)
@bookings[start_time] += 1
@bookings[end_time] -= 1
temp = 0
@booki... | true |
2a35a4aef271774ceae6c365b3b9453f4114be70 | Ruby | paulba71/Template_Method_Strategy | /Day 4/State Exercise/State Exercise.rb | UTF-8 | 1,521 | 3.484375 | 3 | [] | no_license |
# Mel Ó Cinnéide
# with thanks to Vince Huston for the example
require_relative 'child_behaviour'
require_relative 'adult_behavior'
require_relative 'pensioner_behaviour'
require_relative 'teenager_behaviour'
require_relative 'state_manager'
class Person
def initialize
@age = 0
@state_manager=StateManager.... | true |
35bebdba0adf1354506369657718de0554fb9183 | Ruby | Valindo/JumpStartWithSinatra | /01Chapter/hello.rb | UTF-8 | 330 | 2.734375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader' if development?
get '/bet/:stake/on/:number' do
number = params[:number].to_i
stake = params[:stake].to_i
roll = rand(6) + 1
if number == roll
"It landed on #{roll}, Well done you won #{6*stake} Chips."
else
"It landed on #{roll}. You lose your stake of #{stake}.... | true |
580cf8aab46a963e250b5dbd3261b844f86cf10a | Ruby | bmbrina/Hephaestus | /Classes/Quadruple.rb | UTF-8 | 829 | 3.296875 | 3 | [] | no_license | #######################
# Description: Quadruple class, defines the structure of the intermediate code
# that Hephaestus generates for execution.
# Parameters: (operator, type:Char), (left_side, type:String),
# (right_side, type:String), (result, type:String)
# Return value: N/A
# Error handling: N/A
##################... | true |
86a8fdd40dbcd6fd60d811aa6156e523970fb608 | Ruby | xhb/vmopt | /lib/vmopt/notepad.rb | UTF-8 | 4,113 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
#$:.unshift File.join(__FILE__,"..","..")
require "vmopt/windows/win_winutils"
module Vmopt
class NotePad
# 功能:
# 1.初始化一个notepad程序,如果给定路径,则打开特定路径下的文件,同时激活该窗口
# 2.如果不给定路径,则打开notepad,同时激活该窗口。
# 参数:
# txt_path: 文件路径
# open_window: 表示需不需要创建该notepad窗口,默认创建,不设置表... | true |
d36f2ee054a226483505f8b182e2dc71525b8808 | Ruby | fup/martelo | /lib/martelo/cache.rb | UTF-8 | 518 | 2.65625 | 3 | [] | no_license | module Martelo
class Vmware::Cache
@@max_age = 3600
def initialize
@redis = ::Redis.new
end
def store(data)
s = Hash.new
s['vms'] = data
s['age'] = Time.now.to_i
@redis.set "vmcache", s.to_json
end
def expired?
return true if @redi... | true |
76a2316a9b8516b9428d121013551f0c5d7cfed6 | Ruby | gkpacker/sollis-test | /app/controllers/api/v1/fibonacci_controller/fibonacci_sequence.rb | UTF-8 | 423 | 2.8125 | 3 | [] | no_license | module Api::V1
class FibonacciController
class FibonacciSequence
def initialize(number)
@number = number
end
def calculate_sequence
sequence = []
@number.to_i.times do
sequence << 0 && next if sequence.empty?
sequence << 1 && next if sequence.size ==... | true |
e71092ce652ccaaf50abed022477aa0c33a694ad | Ruby | hausgold/billomat | /lib/billomat/actions/complete.rb | UTF-8 | 1,053 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Billomat
module Actions
# Completes an invoice by calling the /complete path on a resource.
class Complete
# Returns a Complete object.
#
# @param invoice_id [String] the ID of the invoice
# @param opts [Hash] the options for this request
# @... | true |
d07b0e0313c2167d3e886a7601707a240c1a489d | Ruby | abertolai/automated-batista | /features/pages/Udemy.rb | UTF-8 | 390 | 2.6875 | 3 | [] | no_license | class Udemy
include Capybara::DSL
attr_reader :title, :subtitle
def initialize
@title = find(:xpath, "//h1[@class='udlite-heading-xl clp-lead__title clp-lead__title--small']")
@subtitle = find("[class='udlite-text-md clp-lead__headline']")
end
def getTextTitle
@title.text... | true |
58074e5946ab3db24a7c9ef76c1f0054fe6c7977 | Ruby | DeclanFoody/Stores-Employees | /exercises/exercise_6.rb | UTF-8 | 838 | 2.984375 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Khurram", last_name: "Virani",... | true |
09cd44f392bc5e7769d4f2a0676aafadf864c1b8 | Ruby | rasensio1/sales_engine_sql | /lib/objects/item.rb | UTF-8 | 2,490 | 2.875 | 3 | [] | no_license | require_relative '../modules/record_like.rb'
require_relative './invoice_item'
require 'date'
class Item
include RecordLike
attr_accessor :name, :description, :unit_price, :merchant_id,
:created_at, :updated_at, :cached_invoices, :cached_paid_invoices,
:cached_unpaid_invoices, :cached_invoice_items, :cach... | true |
91d2159f8b3ec0c90c72a62254c9b614fe688eae | Ruby | MrMarvin/eveerp_market_finder | /evecentral.rb | UTF-8 | 3,292 | 2.828125 | 3 | [] | no_license | require 'digest/sha1'
module EveCentral
NUM_THREADS=10
CACHE_TIME=10*60 # 600 seconds = 10 mins
class <<self
def look_up(list_of_type_ids,regions,stations)
puts "#{Time.now} | EveCentral::look_up (#{list_of_type_ids.size} types)"
@lookups = []
list_of_type_ids = list_of_type_ids.uniq... | true |
59133ee05c4a6bf0bbc4fb60e6f371a9ce7b2ab6 | Ruby | bbc/testmine | /app/extras/ir_ingestor.rb | UTF-8 | 3,347 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'json'
class IrIngestor
def self.parse_ir( json )
ir = JSON.parse(json)
type = ir["type"] || "ruby cucumber"
started = ir["started"]
finished = ir["finished"]
target = ir["target"]
project = ir["project"] || ir["world"]["project"]
component= ir["component"] || ir["world... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.