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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e7d3c9a7dad00e7a28f92acac4d3d437dcd45e21 | Ruby | michael-mm/launch_school_back_end | /intro_to_programming/loops_iterators/3.rb | UTF-8 | 284 | 3.65625 | 4 | [] | no_license | #use each_with_index to iterate array
#Option 1:
orange_types = ['Common','Navel','Acid-less','Tangerine']
i = 0
orange_types.each_with_index do |orange|
i += 1
puts "#{i}. #{orange}"
end
#Option 2:
orange_types.each_with_index do |orange, i|
puts "#{i + 1}. #{orange}"
end
| true |
dfd524eeec032b46373ac617e394d3edb6177b67 | Ruby | sivanpatel/takeaway-challenge | /lib/twilio_sender.rb | UTF-8 | 476 | 2.828125 | 3 | [] | no_license | require 'twilio-ruby'
class TwilioSender
attr_reader :from, :client, :account_sid, :auth_token
def initialize
@from = "____"
@account_sid = '____'
@auth_token = '____'
@client = Twilio::REST::Client.new @account_sid, @auth_token
end
def send_text to, message
message = @client.account.mes... | true |
3e4382e1d0f8aa4109f2c0e9484d32beccd2056d | Ruby | AudTheCodeWitch/crystal_correspondences | /lib/crystal_correspondences/scraper.rb | UTF-8 | 1,948 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'open-uri'
require 'nokogiri'
require 'pry'
class Scraper
def open_index
Nokogiri::HTML(open('https://beadage.net/gemstones/'))
end
def scrape_list
open_index.css('.card.flex-card.horizontal.per-row-1-2')
end
def scrape_crystals
crystal_hash = {}
scrape_list.each do |card|
cry... | true |
e1378b605d21bd4eff2470384a8574ecced95dc1 | Ruby | cmarx2/casino_dpl | /roulette.rb | UTF-8 | 2,274 | 3.9375 | 4 | [] | no_license | require_relative 'player'
require 'artii'
require 'colorize'
class Roulette
attr_accessor :player
def initialize(player)
@player = player
art = Artii::Base.new
puts art.asciify('Roulette Time').colorize(:red)
puts "Welcome #{@player.name} to Roulette - Lets Play!\n"
user_choice
end
def roulett... | true |
af6d0e9fe19eff10f071c1e49c61d5089af810a2 | Ruby | DavidMah/Rymdskepp | /server/entity.rb | UTF-8 | 2,188 | 3.296875 | 3 | [] | no_license | class Entity
# Entity maintains a table of all current entities on the game board
# Each Entity is given a unique global id for each game
# In the @@entities table, this global id is also the key for
# retrieving data for that entity
@@entities = {}
@@entity_count = 0
def self.entities
@@entities
... | true |
21d1b37e64e2863ef301338a5771d09cd3afcece | Ruby | martinsmf/testeQA | /ruby/avancado/poo.rb | UTF-8 | 641 | 3.9375 | 4 | [] | no_license | class Conta
attr_accessor :nome, :saldo
#construtor
def initialize(nome)
self.saldo = 0.0
self.nome = nome
end
def deposita(valor)
self.saldo += valor
puts "Deposita a quantia de R$ #{valor} "
end
def exibiSaldo
puts "#{self.nome}, seu saldo é de R$ #{self.saldo} "
end
end
puts "... | true |
51093974d49f28e815b499fea0dd97be4ad32acd | Ruby | Scott-Borecki/whether-sweater-api | /spec/poros/book_collection_spec.rb | UTF-8 | 2,742 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
describe BookCollection, type: :poro do
describe 'object creation' do
subject(:book_collection) { BookCollection.new(books, forecast) }
# See spec/support/books_response_body.rb for #books_response_body
let(:books) { books_response_body }
# See spec/support/forecast_response_b... | true |
978b5842ea9ac71c21d340ae422ba597f768938c | Ruby | Albertino2020/tic-tac-toe-project | /lib/player.rb | UTF-8 | 1,134 | 3.21875 | 3 | [] | no_license | # rubocop: disable Style/ClassVars
class Player
attr_reader :name, :symbol, :turn, :choice, :game_over, :wrong_move
attr_writer :name, :symbol, :turn, :choice, :game_over, :wrong_move
def initialize(name, symbol, turn)
@name = name
@symbol = symbol
@turn = turn
@@count = 0
end
def check_inpu... | true |
6b29d9c85021a23c5c87fc9d1155f7d182c0f538 | Ruby | sudhu26/semmul2014 | /dbpedia_mapper/bin/dbpedia_mapper_runner.rb | UTF-8 | 603 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative '../lib/dbpedia_mapper'
require_relative '../lib/dbpedia_mapper/virtuoso'
mapper = DBpediaMapper::Mapper.new
mapper.register_receiver
# for each ID:
# 1. get (read) triple from Virtuoso
# 2. if mapping exists: map triple to own ontology
# 3. write triple to Virtuoso
# v = DBpediaMapper::Virtuoso.new... | true |
4c00c347969b865b0231338a9b082071846c4038 | Ruby | Jonesyd/ls_101_programming_foundations | /04_lessons/08_07_block.rb | UTF-8 | 427 | 3.84375 | 4 | [] | no_license | t = [1, 2, 3].any? do |num|
puts num
num.odd?
end
puts "The return value is: #{t}"
# Blocks return value?
# true is returned (because there is at least one truthy return)
# in block, num.odd? returns true on 1 and 3
# Return value of #any? is true
# Output
# 1
# 2
# 3
# short circuit evaluation means that one ... | true |
3827909f0524b311c552f6ef138aca04b9b3b730 | Ruby | gnappo1/badges-and-schedules-v-000 | /conference_badges.rb | UTF-8 | 1,055 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def badge_maker (name)
"Hello, my name is #{name}."
end
def batch_badge_creator (attendees)
attendees.map do |name|
badge_maker(name)
end
end
def assign_rooms(attendees)
room_assignments = []
attendees.each_with_index do |name, index|
room_assignments.push("Hello, #{name}! Yo... | true |
147c34b4eae2153d755e8574f3ecae29d520d8df | Ruby | jphager2/pages_to_epub | /lib/pages_to_epub.rb | UTF-8 | 1,791 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'erb'
require 'rpub'
require 'fileutils'
class PagesToEpub
attr_reader :pages
def initialize(pages)
@pages = pages
.select { |page| page[:body].to_s.length.nonzero?}
.sort_by { |page| page[:title] }
end
def to_html
in_dir do
layout = File.read('t... | true |
6051f495d398d2539fa55a00ba904701cef637f0 | Ruby | kaiheiongaku/adopt_dont_shop | /spec/features/applications/new_spec.rb | UTF-8 | 2,801 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "Applications creation" do
before :each do
@shelter1 = Shelter.create!(name: "Shady Shelter", address: "123 Shady Ave", city: "Denver", state: "CO", zip: 80011)
@shelter2 = Shelter.create!(name: "Silly Shelter", address: "123 Silly Ave", city: "Longmont", state: "CO", zi... | true |
aef36ed167563ca4e71c8acc1634f445a3c5c77a | Ruby | chris-schwartz/ruby_design_patterns | /proxy-pattern/refactored/BankAccountProtectionProxy_spec.rb | UTF-8 | 1,581 | 2.703125 | 3 | [] | no_license | require 'rspec'
require './BankAccountProtectionProxy'
require 'etc'
describe BankAccountProtectionProxy do
describe "for owner name matching current user" do
before do
@fake_account = double()
@owner = Etc.getlogin
@proxy = BankAccountProtectionProxy.new(@fake_account, @owner)
... | true |
12ab5b6610099a571a4c9426d8b677a4563e560c | Ruby | Ashgrim23/algorithms | /Product of Array Except Self/solution.rb | UTF-8 | 399 | 2.875 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[]}
def product_except_self(nums)
n=nums.length()
return [0] if n==1
i,temp=1,1
out=Array.new(n, 1)
for i in 0..n-1 do
out[i]=temp
temp*=nums[i]
end;
temp=1
for i in (n-1).downto(0) do
ou... | true |
2b3fe7e068b7c829874301a72d44d714f3036968 | Ruby | sionc/filmedhere | /app/services/filming_location_service.rb | UTF-8 | 7,642 | 3.171875 | 3 | [] | no_license | # This service is used for creating records in the database based on the latest filming location info.
class FilmingLocationService
# lat long around which location resolution needs to happen
# since we are just looking for locations around SF for now, use a constant for reference lat long
SF_LAT_LONG = "37.7... | true |
fea77dfb2dce22bc20ceb6ac7ac4bb5b820d9080 | Ruby | glv/smithereen | /spec/smithereen/grammar_spec.rb | UTF-8 | 10,955 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
require 'smithereen/parser'
describe Smithereen::Grammar do
Grammar = Smithereen::Grammar
before do
Grammar.symbol_table.clear
end
describe "instance methods" do
subject{Grammar.new}
describe "#initialize" do
it "sets its symbol tab... | true |
26393339fffeb22dbcaad2e5e4395bb19253e2ae | Ruby | pandeiro245/combzhackpostal | /app/models/pref.rb | UTF-8 | 292 | 2.703125 | 3 | [] | no_license | class Pref < ActiveRecord::Base
has_many :cities
has_many :postals
store :info, accessors: [:population2005, :population2010, :size]
def pop(type=2010)
if type.to_i == 2005
(population2005.to_i/10000).to_i
else
(population2010.to_i/10000).to_i
end
end
end
| true |
2238eedbea647dbbd67effe88e72cc4fde9feece | Ruby | sspinc/glass-octopus | /lib/glass_octopus/connection/ruby_kafka_adapter.rb | UTF-8 | 3,238 | 2.875 | 3 | [
"MIT"
] | permissive | require "kafka"
require "ostruct"
require "glass_octopus/message"
require "glass_octopus/connection/options_invalid"
module GlassOctopus
# Connection adapter that uses the {https://github.com/zendesk/ruby-kafka ruby-kafka} gem
# to talk to Kafka 0.9+.
#
# @example
# adapter = GlassOctopus::RubyKafkaAdapter... | true |
01d5f01874ccb8de06a9922b4661f6ce4de59402 | Ruby | JustJace/ProjectEuler | /p033.rb | UTF-8 | 722 | 3.9375 | 4 | [] | no_license | # Problem 33 : There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.
# If the product of these four fractions is given in its lowest common terms, find the value of the denominator.
nums = Array.new
dens = Array.new
fo... | true |
e689cd073a1853776ceda2bfbf1b2799d39f16c7 | Ruby | japgolly/text_to_diagram | /lib/text_to_diagram/gec/dsl.rb | UTF-8 | 3,633 | 2.515625 | 3 | [] | no_license | require 'active_support/core_ext'
require 'active_support/inflector'
module TextToDiagram
module Gec
class Dsl
attr_reader :clusters, :externals
attr_accessor :style
def initialize(style)
@clusters= []
@externals= []
@style= style
end
def gec3(name,options=... | true |
50fe39718a90f9dc957743e3fe6deec455c95ebd | Ruby | Dujota/Ruby-comprehensive-examples-for-students | /ArrayHash/quantifier.rb | UTF-8 | 142 | 3.609375 | 4 | [] | no_license | nums = [1,3,5,8,9]
# Are any of these numbers even?
flag1 = nums.any? {|x| x%2 == 0}
puts flag1
flag2 = nums.all? {|x| x % 2 == 0}
puts flag2
| true |
a5de307bcef31fa4dd7ee4137c1919467b2af415 | Ruby | stone-lang/stone | /src/stone/builtin/pair.rb | UTF-8 | 1,145 | 2.96875 | 3 | [
"MIT"
] | permissive | require "extensions/enumerable"
module Stone
module Builtin
class Pair < Value
attr_reader :first
attr_reader :second
def initialize(first, second, type_specifier: [Any, Any])
@first = first
@second = second
@type_specifier = type_specifier
super([first, sec... | true |
a87bedb392b897da56a90cc9825dafa224284d67 | Ruby | KarGop/Learning-Ruby | /arrays_merge_Arrofint_convertion.rb | UTF-8 | 357 | 3.59375 | 4 | [] | no_license | arr_1 = ['1', '5', '9']
arr_2 = ['10', '2', '7', '10']
arr_3 = ['3', '4', '0']
output = arr_1 + arr_2 +arr_3
#output = arr_1 << arr_2 << arr_3
#p output.flatten
p output
#To convert an array of strings we need to go through the array items and apply to_i on them
p output.map { |str| str.to_i }
puts " "
#Shorthand
p (ar... | true |
47e7e5017716225b145d718fee57d0d350cf32c4 | Ruby | jessicafrank204/Flatiron_dev | /first_app.rb | UTF-8 | 337 | 3.6875 | 4 | [] | no_license | pineapple = 123.to_f #number stored is 123.0
susan = 13.3.to_i #number stored is 13
puts pineapple + susan #outputs 136.0
puts 7 / 3 #if divide two integers, you get an integer
puts 7.0 / 3 #if divide a float and an integers
puts 8/7.0
name = "Jessicaaaaaa"
puts "Hello I'm #{name}"
puts "yo all I want to do is sa... | true |
de6da0bfea95548494baeec521ebfe4af98f2151 | Ruby | ryuchan00/ruby_for_beginners | /sample/no_nest_namespace.rb | UTF-8 | 318 | 2.921875 | 3 | [] | no_license | # すでにBaseballモジュールが定義されている
module Baseball
end
# モジュール名::クラス名の形でクラスを定義できる
class Baseball::Second
def initialize(player,uniform_number)
@player = player
@uniform_number = uniform_number
end
end
p Baseball::Second.new('Alice', 13) | true |
8b7ad4ffcd73cf708e7fdf8c52d9c15f8a8e14e3 | Ruby | wataru-nakamura/cm_system | /app/models/customer.rb | UTF-8 | 1,023 | 2.546875 | 3 | [] | no_license | class Customer < ApplicationRecord
belongs_to :user, optional: true
has_many :comments, dependent: :destroy
with_options presence: true do
validates :family_name_kana, :first_name_kana,
:birthday, :gender, :address
# 郵便番号(ハイフンあり7桁)
validates :postal_code, format: { with: /\A\d{3}[-]\d{... | true |
8d4779e9a570acb3f8cdb5c7f6ca1f3df6bf5097 | Ruby | jeremiahkellick/app-academy-homework | /W1D3/recursion.rb | UTF-8 | 549 | 3.625 | 4 | [] | no_license | def sum_to(n)
return nil if n < 0
return n if n == 0
n + sum_to(n - 1)
end
def add_numbers(nums)
return 0 if nums.empty?
nums.first + add_numbers(nums[1..-1])
end
def gamma_fnc(n)
factorial(n - 1)
end
def factorial(n)
return nil if n < 0
return 1 if n == 0
n * factorial(n - 1)
end
def ice_cream_sh... | true |
f668b016e855725e1aa305e05a54ce7c787ed1c5 | Ruby | jcovell/my-first-repository | /arrays/bang_op.rb | UTF-8 | 398 | 4.1875 | 4 | [] | no_license | puts "If you add the bang operator (!) to this method, you can perform the uniq function destructively. Much like the way the delete method works. So, b = [1, 1, 2, 2, 3, 3, 4, 4] with puts b.uniq! returns:"
b = [1, 1, 2, 2, 3, 3, 4, 4]
puts b.uniq!
puts "uniq and uniq! are two different methods for Ruby Arrays. You ... | true |
0fcbeaf8c76b911dc481990c82ea80bde6b11ac1 | Ruby | rodrigoms2004/rubyCourse2016 | /Aula1/exemplo8.rb | UTF-8 | 123 | 3.046875 | 3 | [] | no_license | frase = " o rato "
puts frase.strip # remove o espaço em branco da esquerda e direita
puts frase.lstrip
puts frase.rstrip
| true |
e5699b0478fd2b8deb8ddf0a991f17b4aeef1618 | Ruby | Sophie-Williams/GamesBot | /lib/games_bot/game/base.rb | UTF-8 | 518 | 2.734375 | 3 | [] | no_license | module GamesBot
module Game
# The base class for all games.
class Base
class << self
def inherited(subclass)
name = subclass.to_s.split(/::/).last.gsub( /([A-Z\d]+)([A-Z][a-z])/,'\1_\2' ).downcase.to_sym # GamesBot::Games::MyCoolGame converts to :my_cool_game
... | true |
cbb0cd4a2e452e8cb93dd3e384f1ef1636ba12bb | Ruby | shred14/ruby_projects | /tictactoe/app/services/rules.rb | UTF-8 | 1,094 | 3.5 | 4 | [] | no_license | class Rules
def initialize(board)
@board = board
@board_size = Math::sqrt(board.length)
end
def game_over?
return possible_moves?
end
def winner
find_winner_by_rows || find_winner_by_columns
end
def possible_moves?
return false if winner
possible_moves_by_group?(@board) || poss... | true |
4f6f8dd0fdafff6649496d27e521579610f4ec6f | Ruby | osiris43/Pool-Of-Greatness | /app/models/nba_player.rb | UTF-8 | 1,240 | 2.640625 | 3 | [] | no_license | class NbaPlayer < ActiveRecord::Base
include NbaPlayerStatistics
belongs_to :nba_team
has_many :nba_game_player_stats
validates :lastname, :presence => true
validates :position, :presence => true
def display_name
"#{firstname} #{lastname}"
end
def per(season=nil, gamedate=nil)
efficiency(s... | true |
240cabe5e2081d642a51f1a57721fcbb225ce239 | Ruby | akirn/rubinius | /spec/ruby/library/date/rand_spec.rb | UTF-8 | 1,952 | 2.953125 | 3 | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path('../../../spec_helper', __FILE__)
require 'date'
ruby_version_is '1.9' do
describe "Random#rand with a Range of Time" do
before do
@start = Time.new(2013, 1, 1)
@stop = Time.new(2014, 1, 1)
end
it "returns an element from the Range" do
Random.new.rand(@start..... | true |
006431287aefbd944219a31abf04cf95ed09c7da | Ruby | amywieliczka/sampleApp | /convert.rb | UTF-8 | 8,232 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# This script converts data from old eScholarship into the new eschol5 database.
# It should generally be run on a newly cleaned-out database. This sequence of commands
# should do the trick:
#
# bin/sequel config/database.yaml -m migrations/ -M 0 && \
# bin/sequel config/database.yaml -m migration... | true |
46f461f185ebbb1ee28f19b43ff1a6e686c152b9 | Ruby | NedM/RubyPractice | /HelloLoops.rb | UTF-8 | 592 | 4.25 | 4 | [] | no_license | num_loops = 8
counter = 1
while counter <= num_loops
puts "Hello #{counter} times!"
counter += 1
end
perhaps_exit = ""
until perhaps_exit == "exit"
print "Please type \"Exit\" here > "
perhaps_exit = gets.chomp.downcase
end
for num in 1..10 # .. = inclusive range ... = exclusive range
print "#{num}, "
... | true |
e6869f51a3df284ffff72aa8f4a8ee1c900b054c | Ruby | Andsbf/surveyApp | /backend/lib/lead_exporter.rb | UTF-8 | 1,497 | 2.640625 | 3 | [] | no_license | class LeadExporter
def self.export_leads(export, leads)
export_leads =
leads.map do |lead_hash|
lead = ExportLead.new(export, lead_hash.attributes)
lead.process_export if lead.valid?
end.compact
# There may be no valid leads in this batch. If so, don't attempt to export.
Expo... | true |
6f54564290d3bbab438cd8482876fd3657613936 | Ruby | sooo-s/AtCoder | /abc205/b/main.rb | UTF-8 | 113 | 3.171875 | 3 | [] | no_license | n = gets.to_i # 10
a = gets.chomp.split.map(&:to_i) # n = 10, m = 20
puts((1..n).to_a == a.sort ? 'Yes' : 'No')
| true |
fd040b048aebcbb47f3fec4f358f2f8d6269868e | Ruby | wor101-ls-ruby/ruby_book | /more_stuff/excercise4.rb | UTF-8 | 299 | 3.5625 | 4 | [] | no_license | # excercise4.rb
# modify the code in excercise2 to execute properly
def excecute(&block)
block.call # you chave to use the .call method on the variable (typically block but it could be anything) to initate the blocks code
end
excecute {puts "hello from inside the execute method! "} | true |
67c4f6c57aa0cab8d656f12234afa9dd01b76a3b | Ruby | alex-solo/ruby-problems | /bannerizer_further_exploration.rb | UTF-8 | 2,065 | 4 | 4 | [] | no_license | =begin
Write a method that will take a short line of text, and print it within a box.
Understand the problem:
- input: a string
- output: prints to the screen
- model the problem:
- given a string of length n
- output 5 strings
- each string is n length
-top and bottom: "+-" plus n times '-' plus "-+"
... | true |
9b828640fec7592f0f7b8c946b2184fdc4866b89 | Ruby | Yorickov/railway | /lib/services/train_service.rb | UTF-8 | 2,826 | 3.078125 | 3 | [] | no_license | class TrainService < Service
def create_train_console
type_index = input_index(@train_klass.types.keys, 'train type')
return unless type_index
begin
puts 'Enter train number or X to exit'
train_number = gets.chomp
return if train_number.downcase == 'x'
train = create_train(train... | true |
33e22542a52c02b5d74f53f0a597309f50756ab9 | Ruby | jasonronalddavis/ruby-music-library-cli-online-web-sp-000 | /lib/song.rb | UTF-8 | 1,454 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Song
extend Concerns::Findable
@@all = []
attr_accessor :artist, :name, :genre
def initialize(name, artist=nil, genre=nil)
self.artist = artist if artist != nil
self.genre = genre if genre != nil
@name = name
end
def self.all
@@all
end
def self.cr... | true |
6ec9e9255c70ff57817c15a59a41fa8d7b94e5b5 | Ruby | paddor/async-eventmachine | /lib/async/eventmachine/timers.rb | UTF-8 | 1,299 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Async
module EventMachine
def self.add_timer(interval, callback = nil, &block)
Timer.new interval, callback || block
end
def self.add_periodic_timer(interval, callback = nil, &block)
PeriodicTimer.new interval, callback || block
end
def self.ca... | true |
976e85844fb285b0a4c8df5bdfafbf0c0b8545b2 | Ruby | Wolfnet83/Vodovoz | /spec/models/client_spec.rb | UTF-8 | 915 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
describe Client do
before(:each) do
@attr = { :company => "Example Company", :phone_number => "023154565", :contact => ''}
end
it "should create new client using valid attributes" do
Client.create!(@attr)
end
it "shouldn't work without company name" do
no_company_name = Cl... | true |
c01b10f3afd936b058176b9b7664dbce49e5320b | Ruby | btapia/mashup-reco | /app/models/_api.rb | UTF-8 | 4,266 | 2.515625 | 3 | [] | no_license | class Api < ActiveRecord::Base
has_many :mashup_apis
has_many :mashups, through: :mashup_apis
has_many :api_tags
has_many :tags, through: :api_tags
# def co_apis
# mashup_ids = mashups.pluck(:id)
# Api.joins(:mashups).where('mashups.id IN (?)', mashup_ids).where.not(id: id).distinct
# end
# def ... | true |
b367cc9f2e9b7832b99b4efbcbdcac6a6a45b8e4 | Ruby | sleepingkingstudios/parchment | /app/models/origin.rb | UTF-8 | 523 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
# Abstract base class for ActiveRecord-based origin models.
class Origin < ApplicationRecord
self.abstract_class = true
def self.slug_attribute
'name'
end
### Attributes
attribute :slug, :string, default: ''
### Associations
has_many :sources, as: :origin, dependent: ... | true |
232fc0721a5ca1c901acbf3545ccd791388c1a17 | Ruby | pasalino/RoT | /servo2.rb | UTF-8 | 472 | 2.859375 | 3 | [] | no_license | require 'rpi_gpio'
#Reset active pins
RPi::GPIO.reset
#Set numbering in board pins
RPi::GPIO.set_numbering :board
#Set the pin direction
RPi::GPIO.setup 11, :as => :output
#New pwm object PIN, FREQUENCY
pwm = RPi::GPIO::PWM.new(11, 50)
#change angle
pwm.start 0
pwm.duty_cycle = 0.0001
loop do
print "Angle in %:... | true |
aa32fcb30e95280bbd98009e082bf6aca7790a72 | Ruby | Invoca/elasticsearch_models | /spec/query/query_string_spec.rb | UTF-8 | 4,507 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe ElasticsearchModels::Query::QueryString do
describe ".term_for" do
subject(:term) { ElasticsearchModels::Query::QueryString.term_for(condition) }
let(:condition) { "filter text" }
let(:expected_term) { '(*filter AND text*)' }
shared_examples "nothing" do
... | true |
93433c3b7ef113c5da9c062addf927e21f39ca22 | Ruby | wadziu/roomer | /test/unit/reservation_test.rb | UTF-8 | 2,010 | 2.546875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
class ReservationTest < ActiveSupport::TestCase
fixtures :reservations
def setup
@reservation = Reservation.new :room_id => reservations(:today).room_id,
:user_id => reservations(:today).user_id,
... | true |
300d7226c5df42e63fc949a86568c4b2b9a5cf0c | Ruby | aubuchcl/phase_0_unit_2 | /week_6/3_BoggleBoard/my_solution.rb | UTF-8 | 5,983 | 4.25 | 4 | [] | no_license | # U2.W6: Create a BoggleBoard Class
# I worked on this challenge [by myself, with: ].
# 2. Pseudocode
# 3. Initial Solution
class BoggleBoard
def initialize(dice_grid)
@dice_grid = dice_grid
end
def dice_grid
@dice_grid
end
def create_word(*coords)
coords.map { |coord| @dice_grid[coord.first][coor... | true |
5a638f66fff164176e757752ebb7765b6f9aee2b | Ruby | msh101/LS_101_L2 | /mortgage_calculator_push.rb | UTF-8 | 1,688 | 3.984375 | 4 | [] | no_license | puts "Hi! What's your name?: "
user_name = gets.chomp
puts "Okay, #{user_name}. Let's calculate your monthly mortgage payment."
loop do
puts "What is your total loan amount? (USD; use _ instead of a comma)"
loan_amount = ''
loop do
loan_amount = gets.chomp
if loan_amount.include? ","
puts "HEY! ... | true |
d28c746cfb27c9faf6b639d30c6ab148f165c020 | Ruby | code-builders/far_mar | /tammy/lib/far_mar/vendor.rb | UTF-8 | 985 | 2.78125 | 3 | [] | no_license | class FarMar::Vendor < FarMar::Base
attr_accessor :id,
:name,
:no_of_employees,
:market_id
def initialize(attrs)
@id = attrs[0].to_i
@name = attrs[1]
@no_of_employees = attrs[2].to_i
@market_id = attrs[3].to_i
end
de... | true |
387bd574cc8079bd6e1d8a7ef7c7043fc2fc7e2e | Ruby | rbao/super_role | /lib/super_role/action_alias.rb | UTF-8 | 1,625 | 2.796875 | 3 | [] | no_license | module SuperRole
class ActionAlias
cattr_reader :all
@@all = []
attr_reader :action, :resource_type
attr_accessor :aliases
def self.create(aliases, action, resource_types)
resource_types.each do |rt|
existing = find_by_action(action, rt)
if existing
existing.alia... | true |
066ee3cc35a5c4ec96ca88d7f897c9e96b56a600 | Ruby | mariozugaj/exercism | /ruby/pangram/pangram.rb | UTF-8 | 196 | 2.71875 | 3 | [] | no_license | # Determine if a sentence is a pangram
class Pangram
def self.pangram?(sentence)
sentence.downcase.scan(/[a-z]/).uniq.sort == ('a'..'z').to_a
end
end
module BookKeeping
VERSION = 3
end
| true |
74e470ab866021f55d445a6772b7a1e7c4fa68bb | Ruby | shelomohkhual/25JuneExercises | /exercise_69/Fibonacci(n)_Recursion.rb | UTF-8 | 411 | 3.9375 | 4 | [] | no_license | def recursive_nth_fibonacci_number(position)
position.times do
if position <= 2
return position=1
end
return recursive_nth_fibonacci_number(position-1) + recursive_nth_fibonacci_number(position-2)
end
end
print "Enter Fibonacci Position :"
position=gets.chomp.to_i
print "... | true |
01df82315967e27110e67c079258b212c04a94f6 | Ruby | d-ugol/simplesms | /app/services/twilio_text_messenger.rb | UTF-8 | 324 | 2.546875 | 3 | [] | no_license | class TwilioTextMessenger
attr_reader :phone
attr_reader :message
def initialize( phone, message)
@phone = phone
@message = message
end
def call
client = Twilio::REST::Client.new
client.messages.create( {
from: Rails.application.secrets.twilio_phone_number,
to: @phone,
body: @message
})
end
... | true |
a3c6dab1c4046e6014f6487fecb6ebf56b254209 | Ruby | rn0rno/kyopro | /aoj/ruby/01_ITP/ITP1_7_C.rb | UTF-8 | 227 | 2.8125 | 3 | [] | no_license | #!/usr/env/bin ruby
r, c = gets.chomp.split.map(&:to_i)
sheet = []
r.times do
sheet << gets.chomp.split.map(&:to_i)
end
sheet.map{|e| e << e.inject(:+)}.transpose.map{|e| e << e.inject(:+)}.transpose.map{|e| puts e * ' '}
| true |
e2a6739e0952c3cde2a82118b41faa76791ae872 | Ruby | ged/graphics | /examples/walker2.rb | UTF-8 | 3,727 | 2.78125 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/ruby -w
require "graphics"
require "graphics/trail"
class Person < Graphics::Body
COUNT = 40
D_A = 5.0
D_M = 0.25
M_M = 5.0
VISIBILITY = 100
ATTACK_DISTANCE = 6 * 2
VISIBILITY_SQ = VISIBILITY**2
ATTACK_DISTANCE_SQ = ATTACK_DISTANCE**2
attr_accessor :attack, :debug... | true |
95c531eb2a79371a0beb047f41f4a4e08b21b632 | Ruby | igorrfc/trades | /db/seeds.rb | UTF-8 | 748 | 2.546875 | 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 |
ee4c31ca540d5e074ffca3f672e1cb39e8122e14 | Ruby | daniellasheva/cli-project-week-guidelines-no-scrape-web-0716 | /lib/school.rb | UTF-8 | 730 | 3.296875 | 3 | [] | no_license | class Schools
attr_reader :name, :vscore, :mscore, :wscore, :total_score
@@all_schools = []
def initialize(name, vscore=0, mscore=0, wscore=0)
@name = name
@vscore = vscore
@mscore=mscore
@wscore=wscore
@total_score= vscore+mscore+wscore
@@all_schools << self
end
def self.all_schoo... | true |
19005dab13eac5b7724b96948308a414f4fed196 | Ruby | YikSurn/retailStore | /models/item.rb | UTF-8 | 219 | 3.234375 | 3 | [] | no_license | # An item of the store
class Item
def initialize(name, price, category)
@name = name
@price = price
@category = category
end
def get_category
@category
end
def get_price
@price
end
end
| true |
d9de00a224ce01c11b1795e150771b36f6f5db1f | Ruby | jmks/csv_blueprints | /lib/csv_blueprints/plan_builder.rb | UTF-8 | 417 | 2.609375 | 3 | [
"MIT"
] | permissive | module CsvBlueprints
class PlanBuilder
def initialize(blueprint)
@blueprint = blueprint
@plan = Plan.new(@blueprint)
end
def standard(number)
number.times { @plan.add_row }
self
end
def customized(number, overrides)
number.times { @plan.add_row(overrides) }
se... | true |
7f8fef04f591f28467e285ea1598c1aa3fa745fd | Ruby | EzraChiang/phase-0-tracks | /ruby/hamsters.rb | UTF-8 | 560 | 3.875 | 4 | [] | no_license | puts "What is the hamster's name?"
Name = gets.chomp
puts "What is the hamster's preferred noise level? (1-10)"
Noise_level = gets.chomp.to_i
puts "What is the hamster's fur color?"
color = gets.chomp
puts "Is the hamster a good candidate for adoption? (Yes/No)"
candidate = gets.chomp
puts "What is the ... | true |
26fa737c46d862af61a4008f2274922643861d52 | Ruby | hakobe/forblog | /bkc_group/20080616/test_tokuten_parser.rb | UTF-8 | 344 | 2.75 | 3 | [] | no_license | require 'test/unit'
require 'tokuten'
class TokutenParserTest < Test::Unit::TestCase
def test_parse
input = <<END
3
1000
342
0
5
2
2
9
11
932
0
END
datasets = Tokuten::Parser.parse(input)
assert_equal([1000, 342, 0], datasets.shift)
assert_equal([2, 2, 9, 11, 932], datasets.shift)
assert_nil(da... | true |
fab5e8b9d3e927e7b0d62b636951ff1656fd51a3 | Ruby | conversation/lita-buildkite | /lib/lita/buildkite.rb | UTF-8 | 834 | 2.6875 | 3 | [
"MIT"
] | permissive | require "lita"
require 'lita/buildkite_event'
require 'lita/buildkite_build_finished_event'
require 'lita/buildkite_job_finished_event'
module Lita
module Handlers
# Receives buildkite webhooks and emits them onto the lita event bus
# so other handlers can do their thing
class Buildkite < Handler
... | true |
fa8971c5fe5480d5ed689d01ff635a4aa43f8218 | Ruby | marysitz/ttt-3-display_board-example-q-000 | /lib/display_board.rb | UTF-8 | 405 | 3.578125 | 4 | [] | no_license | # Define a method display_board that prints a 3x3 Tic Tac Toe Board
def row
' | | '
end
def separator
'-----------'
end
def display_board
puts row
puts separator
puts row
puts separator
puts row
end
display_board
# "<pre> </pre>|<pre> </pre>|<pre> </pre>\n-----------\n<pre> </pre>|<pre> ... | true |
cad76f8ce5d8ceb21272eb5a653a7fb7dc2eefec | Ruby | Zhongyun-Huang/Next-Gen-Seq-data-cleaning | /hap2amap_12.rb | UTF-8 | 7,148 | 3 | 3 | [] | no_license | #!/usr/bin/ruby
$VERBOSE = true
require 'getoptlong'
# == Synopsis
#
# converts a set of hapmap files to ancestry map format. For each file, it:
# Creates three files: my_SNPs.c1.ancestrymapgeno
# my_SNPs.c1.snp
# my_SNPs.c1.ind... | true |
b983efd27e75aae03a8809ac0ba5acbc0df40ddf | Ruby | palkan/active_event_store | /lib/active_event_store/test_helper/event_published_matcher.rb | UTF-8 | 4,294 | 2.75 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ActiveEventStore
module TestHelper
class EventPublishedMatcher
attr_reader :attributes,
:matching_events
def initialize(expected_event_class, store: nil, with: nil, exactly: nil, at_least: nil, at_most: nil, refute: false)
@event_class = expected_... | true |
7be0efd49467e44ce75cafd838608b4f2e8f7430 | Ruby | roy-miller/gofish | /lib/player.rb | UTF-8 | 1,921 | 3.71875 | 4 | [] | no_license | require_relative './book.rb'
class Player
attr_accessor :name, :hand, :full_books
def initialize(name = 'default')
@name = name
@hand = []
@full_books = []
end
def add_card_to_hand(card)
book = book_for_card(card)
if book
add_card_to_book(card, book)
else
new_book = Book.n... | true |
d7c242a4f3bf4049b9a048e896e275f2fb1cafee | Ruby | khanhhuy288/Ruby-Aufgaben | /A6-Rekursion/C-RekursiveObjektstrukturen.rb | UTF-8 | 2,701 | 4.125 | 4 | [] | no_license | require 'Set'
class Set
def to_s
# return empty Set when Set's size equal 0
return 'Set {}' if size == 0
# map elements from Set to an array
set = "Set {#{self.map{|x| x }}}"
# delete square brackets
set.delete('[]')
end
end
def deep_collect_keys(a_hash)
raise ArgumentError, 'Der Param... | true |
c4921956b3d51894bde968988ad389c4fd963dac | Ruby | npeters5/MediaRanker | /app/models/work.rb | UTF-8 | 760 | 2.578125 | 3 | [] | no_license | class Work < ApplicationRecord
has_many :votes
validates :category, presence: true
validates :title, presence: true
validates :title, uniqueness: { scope: :category, message: "That title already exists in this category." }
validates :publication_year, numericality: true
validates :publication_year, length: ... | true |
60f29919dd503e854ea4ec788374a5c18fee78a9 | Ruby | TommyTeaVee/critter4us | /strangled-src/controller/externalizer.rb | UTF-8 | 970 | 2.859375 | 3 | [] | no_license | require './strangled-src/util/constants'
require './strangled-src/model/requires'
require 'json'
class Externalizer
def convert(hash)
convert_hash(hash).to_json
end
def convert_hash(hash)
converted = {}
hash.each do | key, value |
converted[convert_one(key)] = convert_one(value)
end
c... | true |
056db8a0761fec79543986a8f5400a6ae99fcbde | Ruby | scienceexchange/se_providers_api_client | /lib/se_providers_api_client/dsl/users.rb | UTF-8 | 955 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "se_providers_api_client/dsl"
module SeProvidersApiClient
module DSL
module Users
# GET /api/providers/v1/users
# Get users. See https://demo.scienceexchange.com/api-docs/providers#/users/getProvidersV1Users
# @return [Array].
def get_users
R... | true |
4191401068bb66fe2d7a3e0623c25dbccd30824b | Ruby | bjohnston98/ruby_functions | /division/test_div.rb | UTF-8 | 487 | 3.28125 | 3 | [] | no_license | #test_div.rb
#
require "minitest/autorun"
require_relative "my_division.rb"
class TestDivision<Minitest::Test
def test__div_10_equals_5
assert_equal(5, my_division(10,2))
#
end
def test__div_negative_7_equals_14_div_neg_2
assert_equal(-7, my_division(14,-2))
#
end
def test_div_zero_div... | true |
6d64d3f7c1ecb3ed670cd9144d8d33dd97596eb8 | Ruby | thnkr/gooddata_marketo | /lib/gooddata_marketo/loads.rb | UTF-8 | 5,044 | 2.5625 | 3 | [] | no_license | # encoding: UTF-8
# Jobs manages longer processes which may have failed or been terminated by the GoodData platform.
require 'gooddata_marketo/models/load'
require 'gooddata_marketo/helpers/webdav'
require 'digest/sha1'
class GoodDataMarketo::Loads
attr_accessor :available
def initialize config = {}
@user... | true |
e1931025269f3a962931849399a75b8770db678f | Ruby | MarioCarrion/json-array-fields-for | /app/models/concerns/article/tags.rb | UTF-8 | 752 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Concerns
module Article
module Tags
extend ActiveSupport::Concern
included do
validates :tags, associated: true
end
def tags
@tags ||= add_missing_values(build_from_column)
end
def tags_attributes=(attributes)
writ... | true |
90f94e36f91dc8cb15832abfb37bc63f58860935 | Ruby | dwest06/Proy3-Lenguajes | /UserInput.rb | UTF-8 | 938 | 3.390625 | 3 | [] | no_license | # Manejador de Input de Usuario
module UserInput
# Modulo de Jugadas
require './Jugadas.rb'
# Devuelve lambda que puede obtener una Jugada de usuario por consola
#
# @return Proc : Lambda que maneja obtener input de usuario por consola y lo convierte a una Jugada
def UserInput.from_console... | true |
f0a2b9479262c14d8684ed82b36ba25facecc4a2 | Ruby | grosser/maxitest | /lib/maxitest/threads.rb | UTF-8 | 1,095 | 2.53125 | 3 | [
"MIT"
] | permissive | # tests that leave extra threads running can break other tests in weird ways ... prevent that from happening
module Maxitest
module Threads
def setup
@maxitest_threads_before = Thread.list
super
end
def teardown
super
found = maxitest_extra_threads
raise "Test left #{found.... | true |
6a718e018a3fea72f24cee5a50f718f9e8548e3e | Ruby | evilstreak/adventofcode-2020 | /07/main.rb | UTF-8 | 1,210 | 3.5 | 4 | [] | no_license | input = $stdin.read.split(/\n/)
class BagType
attr_reader :colour, :held_by, :contents
def initialize(colour)
@colour = colour
@held_by = []
@contents = {}
end
def add_holder(other_type)
held_by << other_type
end
def add_contents(other_type, quantity)
contents[other_type] = quantity
... | true |
995b198c6da50826aadc1933044ef2faa0ed2d89 | Ruby | jeff-hykin/better-go-syntax | /main/tokens.rb | UTF-8 | 4,479 | 2.546875 | 3 | [
"MIT"
] | permissive | require "walk_up"
require_relative walk_up_until("paths.rb")
require_relative PathFor[:textmate_tools]
#
# Create tokens
#
# (these are from C++)
tokens = [
# arithmetic,
{ representation: "+", areOperators: true, areArithmeticOperators: true },
{ representation: "-", areOperators: true, areArithmet... | true |
cffc09e4cd4148d9b1ee217704e5a33799a8782c | Ruby | rishubtamirisa/42projects | /42projects-master/Day03/ex01/greetings_for_all.rb | UTF-8 | 277 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
def greetings(str = "noble stranger")
if str.is_a? String
puts "Hello " + str
elsif !str.is_a? String
puts "Error! That doesn't sound like a name!"
end
end
greetings "Rishub"
greetings
greetings 14
| true |
9a5ca2e51853d95bf9af419f1615f3e0124373bc | Ruby | portugol/decode | /Algoritmos Traduzidos/Ruby/Algoritmos_Diogo_Marques/10.rb | UTF-8 | 81 | 3.3125 | 3 | [] | no_license | puts "Digite o numero:"
numero = gets
if numero.to_f > 20
puts "#{numero}"
end | true |
2ac4cc7d50ad13695f199690b68e1d7a96bdb250 | Ruby | alex-wiggins/SensorStream | /Ruby/create-device.rb | UTF-8 | 820 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require_relative 'lib/SensorStream'
DEVICE_NAME = "Launchpad 1"
# Test creating a new device, verifies SensorStream.create_device
device = SensorStream.create_device("wdillon", DEVICE_NAME, "Stellaris Connected Launchpad")
if device.nil?
puts "Unable to create device. API test failed. "
exit... | true |
fd63083a0007b48bdc5b3f553f8cc3f4296403f2 | Ruby | JasdipChauhan/Finance-Tracker | /app/models/stock.rb | UTF-8 | 639 | 2.90625 | 3 | [] | no_license | class Stock < ApplicationRecord
def self.find_by_ticker(ticker_symbol)
where(ticker: ticker_symbol).first
end
def self.look_up_stock(ticker_symbol)
look_up = StockQuote::Stock.quote(ticker_symbol)
return nil unless look_up.name
stock = Stock.new(ticker: look_up.symbol, name: look_up.name)
s... | true |
e8c88946ad7ff7536f7b0fcc29e65adcf46ff875 | Ruby | 7e11/Dodge | /utilities.rb | UTF-8 | 261 | 2.765625 | 3 | [] | no_license | module Utilities
#This takes the difference between
def self.collideWithGosu?(player, ball)
dist = Gosu::distance(player.shape.body.p.x - 15, player.shape.body.p.y - 15, ball.x, ball.y)
#Player Radius: 30
#ball radius: 15
dist < 45
end
end | true |
7f1581e83c89e973b3ff8b4e6d6c9412d741e0d8 | Ruby | svyatogor/motion_data | /lib/migrations/relationship.rb | UTF-8 | 3,036 | 2.59375 | 3 | [
"MIT"
] | permissive | class Relationship
attr_reader :attributes
def initialize(name, type, options = {})
options.each { |key, _| raise_if_relationship_option_not_allowed(type, key) }
raise_if_deletion_rule_not_allowed(options)
@attributes = {
name: name,
optional: true.to_core_data_bool,
... | true |
d540fa45e397f4906cb1e2a529fe7600e1ca4cca | Ruby | bachmarc/ev3dev_ruby_stretch | /lib/ev3dev/image.rb | UTF-8 | 1,141 | 2.828125 | 3 | [
"MIT"
] | permissive | # You should install ImageMagick and its Ruby binding gem RMagick.
# robot@ev3dev:~$ sudo apt-get update
# robot@ev3dev:~$ sudo apt-get install ruby-rmagick
# (or ~$ sudo gem install rmagick -N -V)
module Ev3dev
class Image
def initialize(*args)
require 'RMagick'
case args.size
when 0
... | true |
499de006dcb0cebe3c724f263adbadebe56d6afc | Ruby | fairbanksdp/codingbat | /array2.rb | UTF-8 | 2,474 | 3.984375 | 4 | [] | no_license | def have_three?(arr)
n=0
arr.each do|a|
if a==3
n+=1
end
end
if n==3
return true
end
false
end
print have_three?([3, 3, 3, 4, 7,])
print have_three?([3, 3, 4, 7,])
print "\n"
def only14(ary)
ary.each do|n|
if !(n==1||n==4)
return false
end
end
true
end
print only14([1... | true |
b97de62a0a0c55638ba90a45be66b50818f6c686 | Ruby | VictorMarri/ruby-code-learn | /ConceitosBasicos/hello.rb | UTF-8 | 283 | 4.125 | 4 | [] | no_license | #Crie um programa que receba nome e idade de uma pessoa, e no final, exiba
#esses dois dados na mesma frase.
print 'Escreva aqui o seu primeiro nome: '
nome = gets.chomp
print 'Escreva aqui a sua idade: '
idade = gets.chomp
puts "Olá, #{nome}! A sua idade é de #{idade} anos!" | true |
bef29e795181a2924aa91038c4dcff61ba513ec2 | Ruby | conimorales/ProyectosEnRuby | /ruby/mayoredad.rb | UTF-8 | 134 | 3.34375 | 3 | [] | no_license | puts "¿qué edad tienes?"
edad = gets.chomp.to_i
if edad >=18
puts "Eres mayor de edad"
else
puts "Eres menor de edad"
end
| true |
8076bd56a3f1c98f8ae5752495f86208f493ccc9 | Ruby | amrase/RubyPractiseAlgos | /Loops/index.rb | UTF-8 | 2,136 | 4.125 | 4 | [] | no_license | def count_e(word)
countE = 0
i=0
while(i<word.length)
if(word[i]=='e')
countE+=1;
end
i+=1;
end
return countE;
end
puts count_e("movie") # => 1
puts count_e("excellent") # => 3
puts '------------------'
def count_a(word)
countA=0;
i=0
while(i<... | true |
6a04faea55156f7b5b54acba49bdcf9bf99a0bf3 | Ruby | OperaChrome/Sapphire | /lib/sapphire/Extensions/Symbol.rb | UTF-8 | 2,067 | 2.578125 | 3 | [
"MIT"
] | permissive | class Symbol
def Clear(item)
ExecuteAgainstControl(self) do |control, arg|
control.Clear
end
end
def Check
ExecuteAgainstControl(self) do |control, arg|
control.Check true
end
end
def Click
ExecuteAgainstControl(self) do |control, arg|
control.Click
... | true |
60b5b62afebf2fbecd4083e62a7c5c3791363831 | Ruby | rentalcustard/lsdir | /list_directory.rb | UTF-8 | 879 | 4.0625 | 4 | [] | no_license | # Given the name of a directory:
# 1. For each file:
# if it's a normal file:
# show its name
# if it's a directory:
# for each file in the directory:
# if it's a normal file:
# show its name
# if it's a directory:
# ...
#
#USAGE: ruby list_directory.rb /home/tom/code
# ARGV.firs... | true |
342470bf02269e09d0eafdfbe10e289d9e7b32a4 | Ruby | bumi/bundler-thankyou | /lib/bundler/thankyou/cli.rb | UTF-8 | 4,126 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'bundler'
require 'bundler/vendored_thor'
require 'yaml'
require 'lnrpc'
module Bundler
module Thankyou
class CLI < Thor
include Thor::Actions
MINIMUM_AMOUNT = 100 # minimum amount in sats for each recipient
CONFIG_FILE = File.join(ENV['HOME'], '.bundle-thankyou.yml')
attr_access... | true |
6a85ef7f1a926be32cae37d360812f295e901623 | Ruby | Kenta-Tanamachi/ruby_coding_test | /object_oriented/test/fizzbuzz_test.rb | UTF-8 | 15,866 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require '../lib/fizzbuzz'
class FizzBuzzTest < Minitest::Test
def test_if_ver
create_instance
assert_equal '1', @fizzbuzz.if_ver(1)
assert_equal '2', @fizzbuzz.if_ver(2)
assert_equal 'Fizz', @fizzbuzz.if_ver(3)
assert_equal '4', @fizzbuzz.if_ver(4)
assert_... | true |
e43d8683f3fc9d3a1e68a6d1a13e389c922859c5 | Ruby | DannyBen/minichart | /spec/minichart/base_spec.rb | UTF-8 | 1,248 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Base do
describe 'class methods' do
# Using a typical subclass
subject { LineChart }
describe '::options' do
it 'returns default options' do
expect(subject.options).to be_a Hash
expect(subject.options).to eq subject.master_defaults
end
co... | true |
e9b79e667b433d7d06529ece555ac0798a19e4a2 | Ruby | stageroom/lurker | /lib/lurker/json/parser/expertise.rb | UTF-8 | 922 | 2.578125 | 3 | [
"MIT"
] | permissive | module Lurker
module Json
class Parser
module Expertise
module_function
def type_polymorph?(array_or_hash)
return false unless array_or_hash.is_a?(Hash) || array_or_hash.is_a?(Array)
array_or_hash.empty?
end
def type_defined?(hash)
return fals... | true |
ba082339fa98d24a8f729be221a4321e86c0baf2 | Ruby | jhartwell/ironruby | /Tests/mspec/rubyspec/library/generator/fixtures/common.rb | UTF-8 | 322 | 2.65625 | 3 | [
"MIT"
] | permissive | not_supported_on :ironruby do
require 'generator'
end
module GeneratorSpecs
def self.empty
Generator.new([])
end
def self.one_elem
Generator.new([1])
end
def self.two_elems
Generator.new([1, 2])
end
def self.four_elems
Generator.new(['A', 'B', 'C', 'Z'])
end
end... | true |
a39fb41f4fd49cf0cfa48ff6209166742e78b133 | Ruby | kengos/cdigits | /lib/cdigits/luhn/random_table.rb | UTF-8 | 1,870 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Cdigits
module Luhn
class RandomTable
attr_accessor :previsous
def initialize(modulus:)
@modulus = modulus
@previsous = nil
end
# pick from number table exclude 0
# @return [Integer]
def pick_non_zero
pick(exclude:... | true |
041384224381a6cbf434250f192286691d1bbfc7 | Ruby | deanshmuel/hashes_symbols | /json_parse.rb | UTF-8 | 283 | 3.21875 | 3 | [] | no_license | require "json"
require "open-uri"
puts "what is your github username?"
name = gets.chomp
ADDRESS = "https://api.github.com/users/#{name}"
data = open(ADDRESS).read
user = JSON.parse(data) #user will be a Hash
puts "hello #{user["name"]} I know that your Bio is #{user["bio"]}"
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.