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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
07a316d63e778c9d78a128e4395b53dbdcc0972f | Ruby | Caldary/W02-D05-homework | /guests.rb | UTF-8 | 292 | 3.390625 | 3 | [] | no_license | class Guests
attr_reader(:name, :age, :wallet)
attr_writer(:wallet)
def initialize(name, age, wallet)
@name = name
@age = age
@wallet = wallet
end
def spend_money(money)
if @wallet >= 0
@wallet -= money
end
end
end | true |
2ebe8f429da42d087fca44c014d32f5f2662cf78 | Ruby | chadjemmett/Exercise-programs | /leap_year2.rb | UTF-8 | 609 | 4.0625 | 4 | [] | no_license | #completed Jan 14, 2012
#leap year program
#get the start year and end year. Convert to integer
puts "please type in the starting year"
start_year = gets.chomp.to_i
puts "please type in the end year."
end_year = gets.chomp.to_i
#this is just for clarity and show.
puts "*************************"
puts "Here are t... | true |
7965187840c0d01f7c154620249f040743c6df7d | Ruby | raghubetina/app_scaffold | /modeler/rails_model.rb | UTF-8 | 1,118 | 2.546875 | 3 | [] | no_license | require 'active_support/inflector'
require_relative 'rails_column'
class RailsModel
attr_reader :name
attr_reader :has_many
attr_reader :columns
def add_has_many(model)
@has_many << model.name.underscore.pluralize.to_sym
end
def belongs_to
@belongs_to ||= @foreign_keys.map { |fk| fk.to_s.sub(/... | true |
44ec399cdf629a3eeceba8e6141cad667e82a9e7 | Ruby | bigorbach/noble-houses-of-westeros | /app/models/house.rb | UTF-8 | 1,551 | 2.890625 | 3 | [] | no_license | class House
attr_reader :url, :name, :region, :coat_of_arms, :words, :titles, :seats, :current_lord, :heir, :overlord,
:founded, :founder, :died_out, :ancestral_weapons, :cadet_branches, :sworn_members
def initalize
@url = url
@name = name
@region = region
@coat_of_arms = coat_of_arms
@words = ... | true |
0624df37f4dea6fb18c4355e48a2b890449d04ad | Ruby | rubydoobydoo/meetings | /homeworks/ben/sinatra-shop-1/app.rb | UTF-8 | 2,918 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require 'sinatra'
require_relative './gemfile.rb'
require_relative './db/create_db.rb'
require_relative './db/config.rb'
require_relative './models/product.rb'
require_relative './models/cart.rb'
#require_relative "./models/crawl.rb"
require_relative "./models/email_provider.rb"
require_relative "./models/mail_account.... | true |
3bf43a864ca470270fed66fafd1a3122b86a5def | Ruby | avdgaag/redmine-api | /lib/redmine/accept_json.rb | UTF-8 | 1,386 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'delegate'
module Redmine
# A decorator object for RestClient that provides immediate JSON-parsing
# capabilities. Rather than dealing with raw response objects, this decorator
# helps us get at parsed JSON data immediately.
#
# This decorator works by intercepting outgoing requests an... | true |
f2cf6f1056632c866f2c15b8aa7db08aa225c2dc | Ruby | blackhatethicalhacking/whitewidow | /lib/modules/core/tools/site_info.rb | UTF-8 | 1,318 | 2.859375 | 3 | [] | no_license | require_relative '../../../../lib/imports/constants_and_requires'
#
# Pull the information of the site that is available. Pulls the server (apache, redhat, etc) and the IP address
# that the site resolves to
#
module SiteInfo
#
# Get the IP address that the site resolves to using Socket
#
def self.capture_ip(s... | true |
477767748439f1ea68cb02443dfaed1b139a91be | Ruby | kachel/anagram-detector-v-000 | /lib/anagram.rb | UTF-8 | 352 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
require "pry"
class Anagram
attr_accessor :word
def match(word_arr)
word_arr.find_all { |m| alphabetizer(m) === alphabetizer(@word) }
# word_arr.find_all { |w| w.tr(@word, "") == "" }
end
def initialize(word)
@word = word
end
private
def alphabetizer(string)
st... | true |
eae0a6d4ee58c8821390e0e941d62b07087a527d | Ruby | Bytom-Community/Bytom-Ruby-SDK | /lib/bytom/api/keys.rb | UTF-8 | 3,239 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | module Bytom
class Keys
attr_reader :client
private :client
def initialize(client)
@client = client
end
##
# It is to create private key essentially, returns the information of key. The private key is encrypted in the file and not visible to the user.
#
# @param [string] alia... | true |
423d638c69d31feab179d7e5385735e2ed6c6fe6 | Ruby | kputnam/piggly | /lib/piggly/dumper/index.rb | UTF-8 | 3,282 | 2.859375 | 3 | [
"BSD-2-Clause-Views"
] | permissive | module Piggly
module Dumper
#
# The index file stores metadata about every procedure, but the source
# code is stored in a separate file for each procedure.
#
class Index
def initialize(config)
@config = config
end
# @return [String]
def path
@config.mkpa... | true |
b4764688d5eb2381dd96d5a7c6a770a7716814f9 | Ruby | jamiepal/battle-thursday | /lib/bookmark.rb | UTF-8 | 219 | 2.765625 | 3 | [] | no_license | class Individualbookmark
@@bookmarkarray = []
def initialize(string)
@string = string
@@bookmarkarray << @string
end
def self.all
@@bookmarkarray
end
def showstrings
return @string
end
end
| true |
fedf1d9a5575e27caa20f9d557209946eead01bb | Ruby | SarahDrake01/ruby-enumerables-reverse-each-word-lab-london-web-080519 | /reverse_each_word.rb | UTF-8 | 461 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
string_array = string.split(" ")
return_array = []
string_array.each do|string|
return_array << string.reverse
end
return_array.join(" ")
end
def reverse_each_word(string)
array = string.split(" ") #turn string into an array
test_array = [] #empty array
array.collect d... | true |
53e383b3f536c701e02a2399ce8869df2c9d753d | Ruby | zegan/zillow_test | /solution1.rb | UTF-8 | 4,478 | 3.875 | 4 | [] | no_license | #####################################################
# Program : Solution1
# Author : Ian
# description :
#
# 1. Question: A solution consists of four balls from a set of four
# different colors. The user tries to guess the solution. If they
# guess the right color for the right spot, record it as being in... | true |
3a2cc56a6cc55045fe5fc52974f5eef9e382b55c | Ruby | ArwaMA/FinalProject | /CloneDetectionToolApproach/Files.rb | UTF-8 | 572 | 3.1875 | 3 | [] | no_license | #! /usr/bin/env ruby
## It represents the files that have added/changed in host commit and contain clone code of the predefined clone type.
## Each file has a name (name), list of clones in the file (clones),
## and list of donor files that have clone codes with the file.
class Files
def initialize(name, clones)... | true |
538360143478aa6c13a2c28ca647f8e49b9c1cc8 | Ruby | DohertyN/intro-to-programming | /Ruby_Basics/Return/ex3.rb | UTF-8 | 154 | 3.359375 | 3 | [] | no_license | def meal
return 'Breakfast'
'Dinner'
end
puts meal
#returns 'Breakfast' since the return exits the method on line 2, thus 'Dinner' is not processed. | true |
4c6cb425f4b8d644bc95cc338dcfd12f7b369343 | Ruby | J-cmlee/CodeWars | /roman_numerals.rb | UTF-8 | 289 | 3.203125 | 3 | [] | no_license | NUMERALS = { M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90,
L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1 }
def solution(number)
return '' if number <= 0
NUMERALS.each { |key, val| return key.to_s + solution(number - val) if number >= val }
end
p solution (13256) | true |
7a466aa1f31f0ddafad6723f8e7252f1c9c8a86a | Ruby | andy-aguilar/ruby-iteration-practice-badges-and-schedules-lab-wdc01-seng-ft-060120 | /conference_badges.rb | UTF-8 | 487 | 3.96875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(array)
array.map{|name| badge_maker(name)}
end
def assign_rooms(array)
rooms_array = []
array.each_with_index do |name, index|
rooms_array << "Hello, #{name}! You'll be assigned to room #{index + 1}!"
en... | true |
75e5e83d3776b547fc3bfab46be0d8243191839b | Ruby | steveh/synesthetic | /app/models/colour.rb | UTF-8 | 333 | 2.90625 | 3 | [] | no_license | class Colour
def self.random_set
options = []
segments = ["00", "33", "66", "99", "CC", "FF"]
segments.each do |a|
segments.each do |b|
segments.each do |c|
options << "#%s%s%s" % [a, b, c] unless (a == b && b == c)
end
end
end
options.sort_by{ rand }[1..2... | true |
2ec4b2c2c31129da27850511ba156eec67dc965f | Ruby | dtomasiewicz/gamz | /examples/lobby_server/game.rb | UTF-8 | 1,027 | 3.3125 | 3 | [
"MIT"
] | permissive | class Game
MIN_PLAYERS = 1
MAX_PLAYERS = nil
attr_accessor :players
def initialize(players)
@players = players
@on_inform = nil
end
def on_inform(&block)
@on_inform = block
end
def on_finished(&block)
@on_finished = block
end
def player_left(player)
@players.delete player
... | true |
44baa880116382e63042f54c8bbe04c75d8ec257 | Ruby | saikrishnagaddipati/coderbyte-ruby | /Medium/lib/prime_checker.rb | UTF-8 | 450 | 3.578125 | 4 | [] | no_license | def PrimeChecker(number)
length = number.to_s.length
potential_primes = []
all_digits = number.to_s.split("")
all_digits.permutation(length).each do |digits|
potential_primes << digits.join.to_i
end
potential_primes.each do |integer|
return 1 if is_prime?(integer)
end
0
end
private
def is_p... | true |
c73fa15108dec38433d166fb5c25f0a1d8e460b7 | Ruby | gruis/Yaram | /lib/yaram/generic-encoder.rb | UTF-8 | 2,182 | 2.515625 | 3 | [
"MIT"
] | permissive |
begin
require "ox"
rescue LoadError => e
# we'll use Marshal instead
end # begin
module Yaram
module GenericEncoder
class << self
include Encoder
if (((oxgem = Gem.loaded_specs["ox"]).is_a?(Gem::Specification)) && Gem::Requirement.new("~>1.2.7").satisfied_by?(oxgem.version))
include Ox... | true |
ab343267020eea2904d544f0bef26151141c87b7 | Ruby | rolandobrown/prework-ruby-assessment-web-0715-public | /lib/000_array.rb | UTF-8 | 287 | 2.8125 | 3 | [] | no_license | languages = ["Ruby", "JavaScript", "HTML"] # => ["Ruby", "JavaScript", "HTML"]
languages.push("CSS") # => ["Ruby", "JavaScript", "HTML", "CSS"]
languages.index([1]) # => nil
languages.index("HTML") # => 2
puts languages # => nil
# >> Ruby
# >> JavaScript
# >> HTML
# >> CSS
| true |
619c3ba5f8dc4add7455e58ba96b57f733433548 | Ruby | ben7th/pin-2010 | /lib/auto_loads/base/user_related/user_avatar_adpater.rb | UTF-8 | 1,830 | 2.578125 | 3 | [] | no_license | class UserAvatarAdpater
TEMP_FILE_BASE_DIR = "/web/2010/upload_user_avatar_tempfile"
def initialize(user, raw_file)
@raw_file = raw_file
user_id_str = user.id.to_s
@temp_file_dir = File.join(TEMP_FILE_BASE_DIR, user_id_str)
@temp_file_name = File.join(@temp_file_dir, 'avatar_tmp')
@temp_f... | true |
e787ee5411258176fca7971204c350ddee4c47c2 | Ruby | ovinix/rg_oop_task | /book.rb | UTF-8 | 261 | 2.984375 | 3 | [] | no_license | class Book
attr_accessor :title, :author
def initialize(title, author)
@title, @author = title, author
end
def to_s
"#{title} by #{author}"
end
def to_yaml
YAML.dump ({
title: @title,
author: @author
})
end
end | true |
14000cd2f5ffd4ec974e93ac46908c1774f275b9 | Ruby | maiyama18/AtCoder | /abc/083/c.rb | UTF-8 | 78 | 3.015625 | 3 | [] | no_license | x, y = gets.split.map(&:to_i)
c = 0
while x <= y
c += 1
x *= 2
end
puts c | true |
75e83b8ec017ec99a18414df220b1ee9d7e82300 | Ruby | charlie-galb/oyster3 | /spec/oystercard_spec.rb | UTF-8 | 2,234 | 3.078125 | 3 | [] | no_license | require 'oystercard.rb'
describe Oystercard do
#let(:journey){ {entry_station: entry_station, exit_station: exit_station} }
let(:mock_entry) { double :mock_entry}
let(:mock_exit) { double :mock_exit}
it 'checks that the oystercard has an initial value of 0' do
expect(subject.balance).to eq 0
end
desc... | true |
e7e440422b4cec10daf099f46ca0506970851cf6 | Ruby | alikisinyo/second-try | /ruby only/exponetMethod.rb | UTF-8 | 147 | 3.390625 | 3 | [] | no_license | def power(base , powerNum)
result = 1
powerNum.times do |index|
result = result * base
end
return result
end
puts power(2,3)
| true |
514027bb71711fbbba101cb301e86623802d73da | Ruby | cypher/rack-lolspeak | /test/spec_rack_icanhazlolcode.rb | UTF-8 | 1,908 | 2.59375 | 3 | [] | no_license | require 'test/spec'
require 'rack/mock'
require 'rack/contrib/icanhazlolcode'
context "Rack::Contrib::ICanHazLOLCode" do
context "text/plain" do
app = lambda {|env| [200, {'Content-Type' => 'text/plain'}, "Hello, kitty"] }
specify "should convert the body to lolspeak" do
status, headers, body = Rack::... | true |
8d631f1dd7c15e7ddc77087052373784effddaec | Ruby | davidbobeck/sudovue | /sudoku_cell.rb | UTF-8 | 1,316 | 3.03125 | 3 | [] | no_license | class SudokuCell
attr_accessor :color, :possible_colors
attr_reader :id, :h, :v, :b
#---------------------------------
def initialize(id, color = nil)
@id = id
@h = (id / 10.0).to_i
@v = id - (@h * 10)
@b = (((@v-1) / 3.0).to_i) + ((((@h-1) / 3.0).to_i) * 3) + 1
@color = color
@possibl... | true |
5743e4ee45aa6f99f7ea777d56cf292194ca5873 | Ruby | CarlEricLavoie/schedulr | /lib/schedulr/log_entry.rb | UTF-8 | 458 | 2.96875 | 3 | [] | no_license |
class LogEntry
attr_accessor :date
attr_accessor :cmd
attr_accessor :args
def to_log()
"{{#{@date.to_i}}}{{#{@cmd}}}{{#{@args}}}"
end
def initialize(date, cmd, args)
@date = date
@cmd = cmd
@args = args
end
end
def LogEntry.from(line)
data = line.scan(/\{\{(.*?)\}\}+/)
date = Time... | true |
2eee5f8307c97e487abee635f14438a17a184e2e | Ruby | CouchofTomato/chess-1 | /lib/piece.rb | UTF-8 | 1,602 | 3.546875 | 4 | [] | no_license | class Piece
# Note on piece colors: The Unicode representations of chess pieces assume
# black ink on white paper. This game is being developed with a dark background
# coding environment and terminal. So the actual color of the pieces is reversed
# from their Unicode names ─ the Unicode for "black pawn" repres... | true |
7fd4e9c6afe36bffef13e5631954b54fa45ef6f2 | Ruby | DouglasAllen/ruby-kickstart-4-rdoc | /session1/notes/11-stdin-and-stdout.rb | UTF-8 | 1,542 | 3.59375 | 4 | [] | no_license | class Session01Notes
=begin rdoc
=== STDIN STDOUT
# Programs that run in a terminal read text in, and write text out.
# This is the common interface that allows lots of different programs to
# interact with each other.
# When a program outputs text, we say it sends it to standard output
# (stdout).
# In ... | true |
406daa4c0fe623223368dfe4fadd4df7609b97b4 | Ruby | cmacaulay/intro-to-ar | /spec/features/user_can_view_all_horses_spec.rb | UTF-8 | 731 | 2.59375 | 3 | [] | no_license | require_relative '../spec_helper'
RSpec.describe "when user visits horses path" do
it "they view all horses" do
Jockey.create(name: "Joey")
Breed.create(name: "Palomino")
horse1 = Horse.create(name: "Penelope", age: 29, total_winnings: 34000, breed_id: 1, jockey_id: 1)
horse2 = Horse.create(name: ... | true |
5991d81779e7a963283e150ab4c543dbb5777b7d | Ruby | dwoznicki/phase-0 | /week-5/calculate-mode/my_solution.rb | UTF-8 | 3,131 | 4.125 | 4 | [
"MIT"
] | permissive | # Calculate the mode Pairing Challenge
# I worked on this challenge [by myself, with: ]
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented.
# 0. Pseudocode
# What is the inp... | true |
f6b1359877bb54826cf5d11fb3713f7ad6d1fdd8 | Ruby | bluepostit/696-mvc-basics | /router.rb | UTF-8 | 870 | 3.640625 | 4 | [] | no_license | class Router
# State
# - controller
# Behavior
# - run (loop: get user action choice)
def initialize(tasks_controller)
@tasks_controller = tasks_controller
end
def run
loop do
# display menu of actions
# ask user to choose
# dispatch the action
show_menu
action = u... | true |
0f8ca76a654c0dcab07105ee773de504cef3de22 | Ruby | felipemfp/racing | /src/states/game_states/oneway.rb | UTF-8 | 1,806 | 2.765625 | 3 | [
"MIT"
] | permissive | # This class is responsible to extend the on game behavior
# to a one way scenario.
class OneWayGameState < GameState
MODE_INDEX = 0
def initialize(options = {})
super({
player_margin_left: 175.0,
player_margin_right: 335.0,
cars_angle: [0.0],
cars_pos: [180.0, 255.0, 330.0],
cars... | true |
751c90b6f9c6994556f453b02b724313b752a05a | Ruby | minoriinoue/ruby_practice | /todai/w4/others/idou_gata_test.rb | UTF-8 | 949 | 3.046875 | 3 | [] | no_license | require('test/unit')
load('./next_field.rb')
load('./make_field.rb')
class IDOU_GATA_TEST < Test::Unit::TestCase
def test_glider
# Test the period is 4. Since in 1 period, the pattern
# goes to 1 column left and 1 down row. So the pattern
# at the 1 column left and 1 down row after 1 period... | true |
7638958aae2249d94ad5a82b5016a5949b95baf5 | Ruby | pleonar1/backend_mod_1_prework | /section1/ex2.rb | UTF-8 | 283 | 3.6875 | 4 | [] | no_license | # A comment, this is so you can read your code later.
# Anything after the # is ignored by ruby.
puts "I could have code that looks like this." #Anything after this is ignored.
#You can also use a comment to diasble a piece of code.
# puts "THis won't run"
puts "This will run."
| true |
c1aef3f4c92343fa0923adbe752b7c950f195da9 | Ruby | techtronics/kaburiasu_temp | /app/models/battle.rb | UTF-8 | 3,548 | 2.796875 | 3 | [] | no_license | class Battle < ActiveRecord::Base
has_many :parties
before_destroy :child_destroy
#############################################################
#SQL method
#############################################################
#指定した時間分さかのぼって、同じデータがあるかを返します。
def Battle.find_same_data(user_id, battle, h_count)
... | true |
5986c893658921998db1fcb5f60247c22477f1a2 | Ruby | lfeliperibeiro/Ruby_beginner | /Basic/conditionals.rb | UTF-8 | 1,109 | 4.09375 | 4 | [] | no_license | # frozen_string_literal: true
# Operadores relacionais e lógicos do Ruby são os mesmos das outras linguagens
value = 40
if value > 50
puts 'I am major of 50'
else
puts 'I am minor of 50'
end
puts 'i between with 40 and 100' if value >= 40 && value <= 100
if value > 50
puts 'I am major of 50'
elsif value == 5... | true |
1fbbab9d4982060d84aef9956cd2e408907698aa | Ruby | stadelmanma/sablon | /lib/sablon/html/visitor.rb | UTF-8 | 685 | 2.8125 | 3 | [
"MIT"
] | permissive | module Sablon
class HTMLConverter
class Visitor
def visit(node)
method_name = "visit_#{node.class.node_name}"
if respond_to? method_name
public_send method_name, node
end
end
end
class GrepVisitor
attr_reader :result
def initialize(pattern)
... | true |
d8c37f670190ce9a2f9d2f851b02739b9b15bb7b | Ruby | jamesarosen/xebec | /lib/xebec/has_nav_bars.rb | UTF-8 | 1,121 | 2.65625 | 3 | [] | no_license | require 'xebec/nav_bar'
module Xebec
# A supporting mixin for NavBarHelper and ControllerSupport.
# Looks up navigation bars by name.
module HasNavBars #:nodoc:
protected
# Looks up the named nav bar, creates it if it
# doesn't exist, and evaluates the the block, if
# given, in the scope of +s... | true |
db2056cc6a8698bd9e1048fc78289f4ae5da829d | Ruby | lbvf50mobile/til | /20191204_Wednesday/20191204.rb | UTF-8 | 1,608 | 3.65625 | 4 | [] | no_license | p "alias x='ruby 20191204_Wednesday/20191204.rb'"
# Leetcode: 760. Find anagram mappings.
=begin
https://leetcode.com/problems/find-anagram-mappings/
Leetcode: 760. Find anagram mappings.
Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements... | true |
97117463fed532e41c2e2cb5bc03cfe40a32b99e | Ruby | oscarmolivera/code_farm | /Ruby/CodeWars/Collection Ruby 8 Kyu/02-[8kyu]_Remove String Spaces.rb | UTF-8 | 1,332 | 3.140625 | 3 | [] | no_license | =begin
Remove String Spaces
Simple, remove the spaces from the string, then return the resultant string.
=end
def no_space(x)
x.split.join('')
end
p no_space('8 j 8 mBliB8g imjB8B8 jl B')
# =>'8j8mBliB8gimjB8B8jlB'
p no_space('8 8 Bi fk8h B 8 BB8B B B B888 c hl8 BhB fd')
# =>'88Bifk8hB8BB8BBBB888chl8BhBfd'... | true |
8665f77dbeb5db6fe062cecf2bca1a3ee05f2d96 | Ruby | regisbruggheman/gko_cms3 | /gko_core/db/default/sites.rb | UTF-8 | 2,445 | 2.71875 | 3 | [] | no_license | require 'highline/import'
# see last line where we create an master if there is none, asking for email and password
def prompt_for_site_title
title = ask('Title [My site]: ') do |q|
q.echo = false
q.validate = /^(|.{1,40})$/
q.responses[:not_valid] = 'Invalid site title. Must be at least 1 characters long... | true |
0ef5ef6322aeb5821f0a8761ed20d5ff0725950d | Ruby | yoichimichael/ruby-oo-relationships-practice-boating-school-exercise-nyc-web-033020 | /app/models/student.rb | UTF-8 | 730 | 3.171875 | 3 | [] | no_license | class Student
attr_reader :first_name
@@all = []
def initialize(first_name)
@first_name = first_name
Student.all << self
end
def self.all
@@all
end
def add_boating_test(test_name, test_status, instructor)
BoatingTest.new(self, test_name, test_status, instructor)
end
def self.find_... | true |
a579e5ac2d642f9f4efdfab4e3d936adb9de0a6d | Ruby | peteonrails/ruby-gpu-examples | /bin/tree_rings_yarv.rb | UTF-8 | 655 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
#
# A baseline CPU-based benchmark program CPU/GPU performance comparision.
# Approximates the cross-sectional area of every tree ring in a tree trunk in serial and in parallel
# by taking the total area at a given radius and subtracting the area of the closest inner ring.
# Copyright © 2011 Preston... | true |
5ddda730dfa3f5f54bb4ae6901b5a9315b76befd | Ruby | christianlarwood/ruby_small_problems | /live_coding_exercises/array_of_primes.rb | UTF-8 | 1,920 | 4.65625 | 5 | [] | no_license | # Write a method that takes two numbers. Return an array containing all primes between the two numbers (include the two given numbers in your answer if they are prime). Don't use Ruby's 'prime' class.
=begin
What's the expected input(s):
- 2 integers, start number and ending number in a range
What's the expected out... | true |
95bb7b46728660b588d44f4c67b090b2c509af1a | Ruby | jachabombazo/skillcrush1 | /git_test.rb | UTF-8 | 103 | 2.96875 | 3 | [] | no_license | puts "This file is for testing GIT only."
puts "Who are you?"
answer = gets.chomp
puts "#{answer}"
end
| true |
453707844767a4bd4a18596fda4649ebd1cd8ae4 | Ruby | thomas-kenny/udemy_rspec | /spec/double_spec.rb | UTF-8 | 930 | 3.140625 | 3 | [] | no_license | # method which returns a flexible object whose methods we can define and return values we can stipulate.
# forces pressure on us to make sure doubles match behaviour of objects they are designed to mock.
RSpec.describe 'a random double' do
it 'only allows defined methods to be invoked' do
stuntman = double("Mr. ... | true |
ea50f578d3c1b5f16a396ed35c9a4863120bdfc0 | Ruby | crhilditch20/week2homework_kareoke | /room.rb | UTF-8 | 1,010 | 3.484375 | 3 | [] | no_license | class Room
attr_reader :name, :guests, :capacity, :song_list, :available_space
def initialize(name, capacity, song_list)
@name = name
@capacity = capacity
@guests = []
@song_list = song_list
@available_space = nil
end
def count_guests()
@guests.length
end
def available_space
@available_space = (@cap... | true |
1b69b4d5bf0efeb3d3286133117c59f29a1f9d32 | Ruby | kelostrada/htmlformatter | /lib/htmlformatter/elixir_indenter.rb | UTF-8 | 472 | 2.5625 | 3 | [
"MIT"
] | permissive | module HtmlFormatter
class ElixirIndenter
INDENT_KEYWORDS = %w[ else ]
OUTDENT_KEYWORDS = %w[ else end ]
ELIXIR_INDENT = %r{
^ ( #{INDENT_KEYWORDS.join("|")} )\b
| ^ ( \w+\s*=\s*form\_for )
| ( -\> | do ) $
}xo
ELIXIR_OUTDENT = %r{ ^ ( #{OUTDENT_KEYWORDS.join("|")} | \} ) \b }xo... | true |
103cd346692643a090597b940a21acbf3e039003 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/cb8b7039af124bfeb801df1c111342bd.rb | UTF-8 | 334 | 3.625 | 4 | [] | no_license | class Anagram
def initialize(source)
@source = source.downcase
@source_chars = @source.chars.sort.join
end
def match(answers)
answers.map(&:downcase).uniq.select { |match| contains?(match) && match != @source }
end
private
def contains?(word)
@source_chars.start_with?(word.chars.sort.joi... | true |
5c6c9c0c9143813600ce914a01e7789de89bbd98 | Ruby | CodingDojo-Ruby-03-17/fredrik-yumo | /RubyTDD/bank_account/bank_account_spec.rb | UTF-8 | 1,214 | 3.09375 | 3 | [] | no_license | require_relative 'bank_account'
RSpec.describe BankAccount do
before(:each) do
@account = BankAccount.new
end
it 'has a getter for checkings attribute' do
expect(@account.checkings).to eq(0)
@account.deposit(15.50, "checkings")
expect(@account.checkings).to eq(15.50)
end
it 'has a getter for t... | true |
45cf4567ca36cba4f6d888ca8b75b1be13fdbec2 | Ruby | saasbook/courseware | /self-checks/module6/sc6-8.rb | UTF-8 | 637 | 3.015625 | 3 | [] | no_license | quiz "6.8: Testing JavaScript and AJAX" do
choice_answer do
text "Which are always true of Jasmine's it() method:
a. it can take a named function as its 2nd argument
b. it can take an anonymous function as its 2nd argument
c. it executes asynchronously"
answer "(a) and (b)"
distractor "(a) and (c)"
distractor ... | true |
b46221389da4fe6399a98b9d35de8e353050d691 | Ruby | mirrec/kata | /lib/codility/fibonacci/lesson.rb | UTF-8 | 373 | 3.421875 | 3 | [] | no_license | module Codility
module Fibonacci
module Lesson
def fib_slow(n)
return n if n <= 1
fib_slow(n - 1) + fib_slow(n - 2)
end
def fib_numbers(n)
results = [0] * (n + 1)
results[1] = 1
2.upto(n) do |i|
results[i] = results[i - 1] + results[i - 2]
... | true |
c8067900b9b1d82102ea03e0bbbe2ebd7fa0756a | Ruby | eibay/ruby-refresher | /2-Variables/ex5.rb | UTF-8 | 424 | 4.21875 | 4 | [] | no_license | # Comparing variable outputs
# Case 1
# x = 0
# 3.times do
# x += 1
# end
# puts x
# Case 2
y = 0
3.times do
y += 1
x = y
end
puts x
# What does x print to the screen in each case?
# Do they both give errors? Are the errors different?
# Why?
# Answer
# Case 1 output is 3. Case 2 only gives error.
# X in ... | true |
aabf6e327d408954dbc2204cb41343779841ccbe | Ruby | AnnAllan/assignment_rspec_viking | /spec/warmup_spec.rb | UTF-8 | 1,104 | 3.28125 | 3 | [] | no_license | require 'warmup'
describe Warmup do
let(:warm) {Warmup.new}
describe '#gets_shout' do
it 'upcases a string' do
allow(warm).to receive(:gets).and_return('hello')
expect(warm.gets_shout).to eq('HELLO')
end
it 'puts upcased string to console' do
allow(warm).to receive(:gets).and_return('h... | true |
70302a0d18144d443638134c4681f18044b4d23a | Ruby | viswanand95/juhomi | /ex 39 hashes.rb | UTF-8 | 669 | 3.625 | 4 | [] | no_license | things = ['a','b','c','d']
things[1] = 'z'
puts "the things is: #{things}"
info = {'name' => 'Anand' , 'age' => 24 , 'height' => 178}
info['city'] = "Chennai"
info[1] = "Wow"
info[2] = "Naeto"
info
states = {
'Tamil Nadu' => 'TN',
'Kerala' => 'KL',
'Maharastra' => 'MH',
'orissa' => 'OR'
}
city =... | true |
e01ed2689b7e26d788bf9be4e055729ba19bb2c3 | Ruby | giantoak/201605_xdata_qpr | /data/twitter/aggregate_by_hour.rb | UTF-8 | 859 | 3.0625 | 3 | [] | no_license | require 'date'
INDEX_ID = 0
INDEX_DATE = 1
INDEX_YEAR = 2
INDEX_MONTH = 3
INDEX_DAY = 4
INDEX_HOUR = 5
INDEX_MINUTE = 6
row = 0
totals = {}
open('yemen_tweets_5.22.2016_timeseries.csv').each do |line|
unless row == 0
data = line.split(";")
key = "#{data[INDEX_YEAR]}-#{data[INDEX_MONTH]}-#{data[INDEX_DAY]}-#{d... | true |
ced39286dd027802a098a964d93404282c2831ab | Ruby | marinaneumann/train_station_database | /trains.rb | UTF-8 | 3,287 | 3.6875 | 4 | [] | no_license | require './lib/stations'
require './lib/lines'
require 'pg'
DB = PG.connect({:dbname=>'train_world'})
def main_menu
system("clear")
loop do
puts "(= Main Menu =)"
puts "[1] Operator Menu"
puts "[2] Rider Menu"
puts "[x] Exit program\n\n"
print "Choose option: "
menu_choice = gets.chomp
... | true |
6c2240904913268868ef17ddc611c3d16a988bac | Ruby | skibox/Ruby-LearnEnough | /hello_app.rb | UTF-8 | 455 | 3.109375 | 3 | [] | no_license | require 'sinatra'
require './day.rb'
get '/' do
DAYNAMES = ["Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"]
dayname = DAYNAMES[Time.now.wday]
"Happy #{dayname}."
end
get '/date' do
dayname = Date::DAYNAMES[Time.now.wday]
"Hello, world! Happy #{dayname}."
end
... | true |
7f38d4caeedc9329bca4b55730ca51ef73a08b86 | Ruby | traviswalkerdev/launch-school-ruby-basics | /loops2/ex6_empty_the_array.rb | UTF-8 | 337 | 3.78125 | 4 | [] | no_license | names = ['Sally', 'Joe', 'Lisa', 'Henry']
loop do
puts names.shift
break if names.size == 0
end
# Our solution prints the names from first (Sally) to last (Henry).
# Can you change this to print the names from last to first?
puts
names = ['Sally', 'Joe', 'Lisa', 'Henry']
loop do
puts names.pop
break if nam... | true |
8b5fb82547e13daa574496e9fab5240c91ba108e | Ruby | zstearman3/prophet-ratings | /app/services/basketball_calculations/calculations.rb | UTF-8 | 719 | 2.6875 | 3 | [] | no_license | module BasketballCalculations
module Calculations
def calculated_two_pt_percentage
(two_pt_made.to_f / two_pt_attempted.to_f).round(5)
end
def calculated_three_pt_percentage
(three_pt_made.to_f / three_pt_attempted.to_f).round(5)
end
def calculated_free_throws_percentage
(free_... | true |
44650d5383dbc0448d0a3bfc33b67acbd9623dfe | Ruby | dantelove/109_general_programming | /review/small_problems_3/8_easy8/easy8_4.rb | UTF-8 | 1,061 | 4.53125 | 5 | [] | no_license | # easy8_4.rb
# Write a method that returns a list of all substrings of a string. The
# returned list should be ordered by where in the string the substring begins.
# This means that all substrings that start at position 0 should come first,
# then all substrings that start at position 1, and so on. Since multiple
... | true |
20953366bdef44b0c3e56b431a74c015ab84bff7 | Ruby | anhnguyenis/simple-checkout | /lib/item.rb | UTF-8 | 103 | 2.703125 | 3 | [] | no_license | class Item
attr_reader :price
def initialize
@price = 1
end
def scan
@price
end
end
| true |
4d95d7e408a5712453ef233fe0675c245e4dc096 | Ruby | changokun/project_euler_work | /089.rb | UTF-8 | 3,778 | 3.84375 | 4 | [] | no_license | require_relative 'functions.rb'
asset_file_name = '089_roman.txt'
class Integer
@@roman_numeral_values = {
M:1000,
D:500,
C:100,
L:50,
X:10,
V:5,
I:1
}
def self.parse_roman_numerals(roman_numerals)
roman_numerals.strip!
# puts @@roman_numeral_values.class
... | true |
875a53ceaf65aa73e8ec75b1be030f8c7c7d0366 | Ruby | bgwm/Project | /testingField/interview/test.rb~ | UTF-8 | 129 | 3.25 | 3 | [] | no_license | #!/usr/bin/ruby
class MyClass
def myMethod()
puts "TEST:MyClass.myMethod"
end
end
myClass = MyClass.new
myClass.myMethod()
| true |
835487e4f4631cec29c33269446ec361fed84296 | Ruby | paigewilliams/favorite-things-list | /spec/project_spec.rb | UTF-8 | 3,001 | 3.0625 | 3 | [] | no_license | require('pry')
require('rspec')
require('project')
describe("Item")do
before() do
Item.clear()
end
describe(".all")do
it("ensures that the list is empty in the beginning")do
expect(Item.all()).to(eq([]))
end
end
describe("#add")do
it("saves items to list")do
first_item = Item.new("... | true |
c95d9a3dac33e6901895e709acd0d555cf8f3101 | Ruby | jfiander/bps | /app/lib/bps/pdf/roster/detailed/helpers.rb | UTF-8 | 3,951 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
module BPS
module PDF
class Roster
class Detailed
CONFIG_TEXT = YAML.safe_load(
Rails.root.join('app/lib/bps/pdf/roster/detailed/text.yml').read
).deep_symbolize_keys!
module Helpers
def config_text
CONFIG_TEXT
... | true |
63be474bfd9d44cc691d196f3f9c15da069e6cca | Ruby | haozeng/exercises | /patterns/template_pattern.rb | UTF-8 | 580 | 2.6875 | 3 | [] | no_license | class HR
def hire
phone_interview
onsite_interview
follow_up
end
def phone_interview
end
def onsite_interview
end
def follow_up
end
end
class TechHR < HR
def phone_interview
puts 'do this'
end
def onsite_interview
puts 'do this'
end
def follow_up
puts 'do this'
... | true |
417a80cc1ee7f458d8ac8599300e6884ba48f8db | Ruby | myfreecomm/ecommerce-client-ruby | /lib/ecommerce/resources/adjustment_order.rb | UTF-8 | 2,764 | 2.734375 | 3 | [
"MIT"
] | permissive | module Ecommerce
module Resources
#
# A wrapper to Ecommerce adjusments orders API
#
# [API]
# Documentation: http://myfreecomm.github.io/passaporte-web/ecommerce/api/index.html
#
class AdjustmentOrder < Base
attr_reader :url, :amount, :description, :valid_until, :valid_from
... | true |
e2e57c472656a4dc2a9c1bdcaf807ce70e21d63c | Ruby | ecksma/wdi-darth-vader | /04_ruby/ruby_examples/ruby_method_args_with_splat.rb | UTF-8 | 281 | 3.40625 | 3 | [] | no_license | # the SPLAT *
# usage with args
# just like the JS function's arguments array
def headache(*args)
args.each do |argument|
puts "This argument: " + argument.to_s
end
end
def favourite_cities(*args)
args.each do |city|
puts 'I love the following city: ' + city
end
end
| true |
b8babf1d94a4a811f2e50c8ce847f37e237f8c4b | Ruby | amyequinn/looping-while-until-london-web-051319 | /lib/while.rb | UTF-8 | 113 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_while
levitation_force = 6
while levitation_force < 10
puts "Wingardium Leviosa"
levitation_force +=1
end
end
| true |
fc6093ecf929eeafc070772ed3aeab5ddf3ecfe9 | Ruby | abhishekgaire/Practice-Ruby-Beginner-noob | /22.rb | UTF-8 | 176 | 3.453125 | 3 | [] | no_license | def name()
names =[]
begin
puts "enter naam"
naam = gets
names << naam
puts "another naam?"
answer = gets.chomp
end while answer == "y"
puts names.sort
end
name()
| true |
29c998e143e99e5e87e91a304733cd13f9dc8d7b | Ruby | ConnorChristie/twit-stocks | /driver.rb | UTF-8 | 2,916 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative 'lib/twit-stocks/twitter_engine.rb'
require_relative 'lib/twit-stocks/predictor.rb'
require_relative 'lib/twit-stocks/market.rb'
require_relative 'lib/twit-stocks/boost.rb'
puts "Starting to predict stocks..."
start_day = "2014-05-30"
end_day = "2014-06-04" # during this split, a... | true |
98695ec33154a12df2460399f49e8f9c7dfd1fe5 | Ruby | edwardloveall/absalom-reckoning | /spec/models/calendar_spec.rb | UTF-8 | 1,404 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Calendar do
describe 'associations' do
it { should have_many(:events).dependent(:destroy) }
it { should have_many(:invitations).dependent(:destroy) }
it { should have_many(:permissions).dependent(:destroy) }
it { should have_many(:users).through(:permissions) }
... | true |
1bb69921356e05018616815766ee224a1ccf3c10 | Ruby | Alex808r/thinknetica | /ruby_basics_8/main.rb | UTF-8 | 9,393 | 3.484375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'railway_station'
require_relative 'route'
require_relative 'train'
require_relative 'cargo_wagon'
require_relative 'cargo_train'
require_relative 'passenger_wagon'
require_relative 'passenger_train'
require_relative 'wagon'
require_relative 'validation_error'
class Main... | true |
956aa415cd22b5897000df1a3497145fd9937911 | Ruby | afalone/test_gem | /lib/test_gem/num.rb | UTF-8 | 190 | 2.625 | 3 | [
"MIT"
] | permissive | class TestGem::Num
attr_reader :value, :key
def initialize(value)
@value = value
@key = format('%s%s', '0' * (1000 - value.length), value)
end
def to_s
value
end
end
| true |
3eb289cf295c26d41b9e2219b191593deeef1946 | Ruby | pr0d1r2/breach-mitigation-rails | /lib/breach_mitigation/masking_secrets.rb | UTF-8 | 2,417 | 2.765625 | 3 | [
"MIT"
] | permissive | module BreachMitigation
class MaskingSecrets
class << self
AUTHENTICITY_TOKEN_LENGTH = 32
# Sets the token value for the current session and returns it in
# a masked form that's safe to send to the client. See section
# 3.4 of "BREACH: Reviving the CRIME attack".
def masked_authenti... | true |
f912f4c73d2ae2840866e2cb6ec0507702c5a096 | Ruby | AlvaroTovarDev/sei40 | /week10/burning-airlines-immersive/ba-rails-backend/db/seeds.rb | UTF-8 | 2,219 | 3.0625 | 3 | [] | no_license |
User.destroy_all
print "Creating users... "
u1 = User.create! name: 'Test User 1', email: 'one@one.com', password: 'chicken'
u2 = User.create! name: 'Test User 2', email: 'two@two.com', password: 'chicken'
u3 = User.create! name: 'Test User 3', email: 'three@three.com', password: 'chicken'
puts "created #{User.count} ... | true |
cffc9199a625a255d94816fea4bfbe34822fe660 | Ruby | chlorox416/ruby-oo-relationships-practice-art-gallery-exercise | /tools/console.rb | UTF-8 | 865 | 2.953125 | 3 | [] | no_license | require_relative '../config/environment.rb'
art1 = Artist.new("monet", 10)
art2 = Artist.new("van goh", 20)
art3 = Artist.new("ai", 15)
gallery1 = Gallery.new("sunjet", "new york")
gallery2 = Gallery.new("moon gallery", "brooklyn")
# painting1 = Painting.new(title, price, artist, gallery)
art1.create_painting("sta... | true |
973e5d094f64e56bd0a02943211b65daf156628a | Ruby | feldpost/bitch_slap | /slap.rb | UTF-8 | 1,134 | 2.671875 | 3 | [] | no_license | class Slap
attr_accessor :sender, :message
ONE_HOUR = 3600 #seconds
def self.create( message )
sender = message.sender.screen_name
message = message.to_s
slap = Slap.new(sender,message)
slap.save
return slap
end
def initialize( sender, message )
@sender = sender
@message = mess... | true |
80156845d44f7250fc4e1594e0ef3e0f630835ed | Ruby | griffithchaffee/active_record_seek | /lib/active_record_seek/middleware.rb | UTF-8 | 521 | 2.734375 | 3 | [
"MIT"
] | permissive | module ActiveRecordSeek
class Middleware
attr_accessor(*%w[ name middleware_block ])
def initialize(name:, &middleware_block)
raise(ArgumentError, "#{self.class} expects a block") if !middleware_block
self.name = name.to_s
self.middleware_block = middleware_block
self.class.middlewar... | true |
2a24e85bb0f9907a51f84d4e2364fbd3c8f6538f | Ruby | rlishtaba/rb_scope | /lib/rb_scope/api/niScope_values.rb | UTF-8 | 1,149 | 2.578125 | 3 | [] | no_license | module RbScope
module API
# This module reads the file rb_scope/niScope_pairs
# and use the information inside to automatically generate constants
# with values equivalent to the niScope.h #define macro constants.
# The file rb_scope/niScope_pairs is automatically generated ... | true |
c83e6eb041a5c8f4bfd5371deb02d1a3574f65c0 | Ruby | maoueh/buildozer | /lib/buildozer/dsl/validator/package.rb | UTF-8 | 1,006 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'buildozer/dsl/core/package'
require 'buildozer/dsl/exceptions'
module Buildozer
module Dsl
module Validator
class Package
##
# Receive a dsl package and validates that it is
# well-formed.
#
# For now, exceptions are raised when something is wrong.
d... | true |
74112600e67655c414f227e993c013e6b714b39d | Ruby | martinliptak/codility | /13-AbsDistinct.rb | UTF-8 | 143 | 2.8125 | 3 | [
"MIT"
] | permissive | # you can use puts for debugging purposes, e.g.
# puts "this is a debug message"
def solution(a)
a.map! { |e| e.abs }
a.uniq.count
end | true |
944950ce132a298726f5c2336564dd015b5c7d29 | Ruby | bdraco/redlink | /lib/redlink/location.rb | UTF-8 | 662 | 2.671875 | 3 | [
"MIT"
] | permissive | module Redlink
class Location < Redthing
attr_accessor :location_id, :name, :type, :country, :zip_code, :current_weather, :thermostats, :time_zone
def thermostats=(val)
@thermostats = val[:thermostat_info].map do |therm|
Thermostat.new(therm)
end
end
def thermostats
@thermo... | true |
30742c5eb9b0821272d27b5ce0b3374354ffc5fb | Ruby | KeisukeMurata4210/EffectiveRuby | /chapter8/section_44.rb | UTF-8 | 3,001 | 3.21875 | 3 | [] | no_license | # Rubyのガベージコレクタは「マークアンドスウィープ」というプロセスを使っている
# ①オブジェクトグラフを辿って、コードから到達可能なオブジェクトにマークをつける(マークフェーズ)
# ②マークがつけられなかったオブジェクトを解放する(スウィープフェーズ)
# Ruby2.1では「世代別ガベージコレクタ」が導入された
# 1回のマークフェーズを生き延びたオブジェクトは「古いオブジェクト」
# 2回目以降で初めて出てきたオブジェクトは「新しいオブジェクト」
# ①マークフェーズが「メジャー」と「マイナー」の2種類に分かれる。メジャーは全てのオブジェクトにマークをつける、マイナーは新しいオブジェクトのみを対象とする
# ②スウィ... | true |
002b9d7c917a0c6aab575a2abf5a5787987ff08d | Ruby | Mimioj101/ruby-project-alt-guidelines-nyc01-seng-ft-071320 | /lib/app/models/movie.rb | UTF-8 | 299 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Movie < ActiveRecord::Base
has_many :reviews
has_many :users, through: :reviews
# def movies
# Movie.all.each do |movie|
# puts movie.title
# end
#end
# def movies
# Movie.map{|movie| movie.title}
# end
end | true |
24d397fbe9bfe344a76bec43ff2d49b794df57fe | Ruby | isaacfinnegan/cmdb-client | /cmdbclient.rb | UTF-8 | 6,223 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | #!ruby
require 'net/http'
require 'net/https'
require 'rubygems'
require 'json'
class CMDBclient
@@mocked = false
def self.mock!
@@mocked = true
end
def initialize(opt)
@delegate = (@@mocked ? CMDBclient::Mock.new(opt) :
CMDBclient::Real.new(opt))
end
def delega... | true |
601b0c44e9e69c51458736f634ee5250576a327d | Ruby | takata/hiitcal | /mail_post.rb | UTF-8 | 776 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'rubygems'
require 'dotenv'
require 'csv'
require 'mail'
require 'mail-iso-2022-jp'
Dotenv.load
sleeptime = ENV["SLEEPTIME"].to_i
def post(title , description)
mail_from = ARGV[0]
mail_to = ARGV[1]
mail = Mail.new(:charset => 'ISO-2022-JP')
mail.from ... | true |
f5edcf1910bec7676de9fa385d9aa1728080d97f | Ruby | Eden-Eltume/120 | /120_Exercises/4_Accessor_Methods/ex10.rb | UTF-8 | 361 | 3.796875 | 4 | [] | no_license | class Person
def name
@first_name + " " + @last_name
end
def name=(name)
full_name_array = splice_name(name)
@first_name = full_name_array.first
@last_name = full_name_array.last
end
private
def splice_name(full_name_string)
full_name_string.split(" ")
end
end
person1 = Person.new
p... | true |
9b2a57b094c36f2521cacf4770202e84e2f162ae | Ruby | VanDeGraf/Chess | /lib/user_interface/console_io.rb | UTF-8 | 223 | 2.71875 | 3 | [] | no_license | class ConsoleIO < UserInterfaceIO
def readline
gets.chomp
end
def write(string)
print(string)
end
def writeline(string)
puts(string)
end
def clear
system('clear') || system('cls')
end
end
| true |
4d6531a2fc2a34abe27a1532d9224fcb89e2e81f | Ruby | henare/linksys_am300_statistics | /dslmodem.rb | UTF-8 | 1,284 | 2.671875 | 3 | [] | no_license | require 'rubygems'
require 'mechanize'
class DSLModem
def initialize(url='http://192.168.1.1/index.stm?title=Status-Modem', username, password)
@url, @username, @password = url, username, password
get_stats_page
end
def get_stats_page
# Get the login page
agent = Mechanize.new
@page = agent.... | true |
714dee5114a1a5f600156af736cf2014b8b6c820 | Ruby | baloran/tilter | /spec/models/user_spec.rb | UTF-8 | 5,118 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe 'User', type: :model do
it 'can be created' do
User.create(
username: 'baloran',
display_name: 'bal0ran',
password: 'password',
email: 'baloranandco@gmail.com'
)
found = User.last
expect(found.username).to eq('baloran')
expect(found.di... | true |
6eb5b29c59bfe770ba409eb2092e8bcfa909b480 | Ruby | kstephens/cabar | /comp/derby/1.0/lib/ruby/derby.rb | UTF-8 | 1,395 | 2.5625 | 3 | [
"MIT"
] | permissive |
module Derby
EMPTY_ARRAY = [ ].freeze unless defined? EMPTY_ARRAY
EMPTY_HASH = { }.freeze unless defined? EMPTY_HASH
# Mixin to handle:
#
# class Foo
# attr_accessor :foo, :bar
# end
#
# obj = Foo.new(:foo => 'foo', :baz => 'baz')
# obj.foo => 'foo'
# obj.bar => 'nil'
# obj.o... | true |
539ec10c487b523bcff09e54f7582af9464b3cd8 | Ruby | knoxknox/dev-labs | /ractor/src/sidekiq.rb | UTF-8 | 737 | 3.03125 | 3 | [] | no_license | class WorkerPool
attr_reader :workers
def initialize(count)
@workers = create_pool(count)
end
def self.perform(opts)
opts[:klass].new.perform(*opts[:args])
end
def perform_async(klass, *args)
worker, _ = Ractor.select(*workers)
worker.send({ klass: klass, args: args })
end
private
... | true |
47cfa8b75489774e75b172df54a85c234ec527e4 | Ruby | Syncleus/Aethyr | /lib/aethyr/core/input_handlers/set.rb | UTF-8 | 2,600 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require "aethyr/core/actions/commands/setpassword"
require "aethyr/core/actions/commands/set"
require "aethyr/core/actions/commands/showcolors"
require "aethyr/core/actions/commands/setcolor"
require "aethyr/core/registry"
require "aethyr/core/input_handlers/command_handler"
module Aethyr
module Core
module Comm... | true |
9aba326263094faeac442f8a2d7a7e994b35dd21 | Ruby | xmacinka/capsulecrm | /examples.rb | UTF-8 | 2,294 | 2.96875 | 3 | [
"MIT"
] | permissive | # NOTE: CapsuleCRM::Person and CapsuleCRM::Organisation have virtually identically methods.
# find by id
person = CapsuleCRM::Person.find 123
# or if you don't know what you are searching for Party
something = CapsuleCRM::Party.find 123
something.is?(:person)
something.is?(:organisation)
# find by email
person = Ca... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.