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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f14f67202177dd795adf84fa0f95800d37f926ea | Ruby | rapid7/rex-mime | /spec/lib/rex/mime/header_spec.rb | UTF-8 | 4,056 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | # -*- coding:binary -*-
require 'spec_helper'
require 'rex/mime'
RSpec.describe Rex::MIME::Header do
let(:mime_headers_test) do
<<-EOS
Content-Type: text/plain;
Content-Disposition: attachment; filename="test.txt"
EOS
end
subject do
described_class.new
end
describe "#initialize" do
subjec... | true |
a5495e78b9b059338db73c288e7ef69082c6f1c1 | Ruby | graygilmore/advent-of-code | /2020/22/crabs.rb | UTF-8 | 2,046 | 3.546875 | 4 | [] | no_license | require './base'
class PartOne
def initialize(input = Base.raw_input('2020/22/input.txt'))
@input = input
end
def solution
winning_hand(play_cards(hands))
end
private
attr_reader :input
def winning_hand(hand)
winner = hand.reverse
winner.sum { |n| n * (winner.index(n) + 1) }
end
... | true |
5bda33367cfb43c31eb53b348c34f4ad965faa0d | Ruby | gcooper76/ISE-Importer | /spec/phone_spec.rb | UTF-8 | 1,166 | 2.625 | 3 | [] | no_license | require 'spec_helper'
describe Phone do
context "No creation criteria created" do
let(:phone) { Phone.new }
it "should have the name and port set to unknown" do
phone.name.should eql('UNKNOWN')
phone.port.should eql('UNKNOWN')
end
end
context "Phone name and Upstream Port Supplied... | true |
079d86497f021e8d244cf73d44250e96ef14b3de | Ruby | codeandiron/versions | /version_sorter_test.rb | UTF-8 | 209 | 2.984375 | 3 | [] | no_license | require_relative 'version_sorter'
version1 = "22.a"
version2 = "1.d"
sorter = VersionSorter.new
newer = sorter.sortVersions(version1, version2)
puts "The " + newer + " version is more recent than the other"
| true |
51420d8599d6de9aa45e3412487e89ec83985614 | Ruby | invizinviz/ubgrade_db | /upgrade_test.rb | UTF-8 | 1,415 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'main'
class UpgradeTest < MiniTest::Unit::TestCase
LIST = Dir.entries("scripts")
VERSION = 44
def test_get_list
# skip
detector = Upgrade.new(LIST, VERSION)
assert_equal [".", "..", "045.createtable.sql", "046.createtable.sql", "047.createtable.sql", "05... | true |
af058dd95cdfa60a616c1f9fedff853543278cf7 | Ruby | psparrow/99bottles | /lib/single_bottles.rb | UTF-8 | 158 | 2.5625 | 3 | [] | no_license | class SingleBottles < Container
COLLECTION = Hash.new { |hash, key| "#{key} bottles" }
COLLECTION[1] = '1 bottle'
COLLECTION[0] = 'no more bottles'
end
| true |
471468b6066eaad34edebd1da4ce786221d24358 | Ruby | springbok/smerf | /lib/generators/templates/app/controllers/smerf_forms_controller.rb | UTF-8 | 5,449 | 3 | 3 | [
"MIT"
] | permissive | # This controller contains methods that displays the smerf form, allows
# the user to answer or edit responses on the form. The controller has
# been developed using REST and responds to the following requests:
#
# * GET /smerf_forms/smerf_form_file_name - displays specified smerf form
# * POST /smerf_forms - creates a... | true |
7cab871f4b44885cfbe2a520c7c6333f64aa7c46 | Ruby | TongDangTinh/CauTrucDuLieuVaGiaiThuat | /Binary-Recursion(DeQuiNhiPhan)/binary-recursion.rb | UTF-8 | 106 | 3.71875 | 4 | [] | no_license | def fib(n)
if n <= 2
return 1
else
return fib(n-1) + fib(n-2)
end
end
puts "Fib #{fib(7)}"
| true |
167c3076ebe52bef4788df946c00aba3b6c2fcf3 | Ruby | Shahana-Hamza-Mamutty/data_structures | /lazy_test.rb | UTF-8 | 3,025 | 3.6875 | 4 | [] | no_license | require 'prime'
prime_array = -> (array_size) do
Prime.each.lazy.select {|i| i.to_s == i.to_s.reverse}.first(array_size)
end
# p prime_array.(15)
def skip_animals(animals, skip)
# Your code here
result = []
animals.each_with_index do |animal, index|
next if index < skip
result << "#{... | true |
28de026707bab4320393c5ad3b6abcdf77ce1fe3 | Ruby | tracy-tucker/activerecord-associations-intro-online-web-sp-000 | /app/models/genre.rb | UTF-8 | 301 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #Define your class to inherit from ActiveRecord::Base
class Genre < ActiveRecord::Base
#Use the has_many macro to tell Genre that it can have many songs
has_many :songs
#Use the has_many through macro to tell Genre that it has many artists THROUGH songs
has_many :artists, through: :songs
end
| true |
b8aa4080c817eb51d80ae401ac4639b360931e98 | Ruby | terut/design_patterns-ruby | /observer/payroll.rb | UTF-8 | 220 | 2.78125 | 3 | [
"MIT"
] | permissive | # ConcreteObserver
class Payroll
def update(changed_employee)
puts "彼の給料は#{changed_employee.salary}になりました! #{changed_employee.title}のために新しい小切手を切ります。"
end
end
| true |
544e5d8acf9e3c4e5bd530d1a0b36c63c46f7dd5 | Ruby | markpothers/nyc-pigeon-organizer-houston-web-career-021819 | /nyc_pigeon_organizer.rb | UTF-8 | 652 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def nyc_pigeon_organizer(data)
org_data = {}
data.each do |attributes, attribute|
attribute.each do |option, names|
names.each do |name|
org_data[name] = {:color => [], :gender => [], :lives => []}
end
end
end
org_data.each do |name, attributes|
at... | true |
96401beb90f7b31c41c2150106df0a9fc44cb8f3 | Ruby | ysirman/rails-text_books_app | /spec/models/user_spec.rb | UTF-8 | 1,509 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
# 名前、メール、パスワードがあれば有効な状態であること
it 'is valid with a name, email, and password' do
user = User.new(
name: 'hoge taro',
email: 'hoge@hoge.hoge',
password: 'hoge password'
)
expect(user).to be_valid
end
# 名前がなければ無効な状態であること
... | true |
3d082f24da6295ff9fd7a4404261a8c691238b72 | Ruby | AlmostADev/DL_Week6_Challenge_1 | /2 ciclos/ejercicio3.rb | UTF-8 | 272 | 4.1875 | 4 | [] | no_license | # Mostrar todos los divisores del número 990 con:
# while, for, times.
counter = 1
while counter <= 990
puts counter if 990 % counter == 0
counter += 1
end
for i in 1..990
puts i if 990 % i == 0
end
990.times do |i|
puts i + 1 if 990 % (i + 1) == 0
end | true |
280c6f660dfc45ba3640316ad969b487be93af35 | Ruby | cielavenir/codeiq_solutions | /kawazoe/tyama_codeiq3229_naive.rb | UTF-8 | 398 | 2.796875 | 3 | [] | no_license | #!/usr/bin/ruby
def comb(n,k)
r=1
k.times{|i|
r=r*(n-i)/(i+1)
}
r
end
N,K=gets.split.map(&:to_i)
raise if N>4
r=0
(1..K).each{|k|
r0=0
[*0...N*N].combination(k){|a|
b=[]
a.each_with_index{|e,i|
b[i]=true
x,y=e.divmod N
i.times{|j|
x0,y0=a[j].divmod N
if x==x0||y==y0
b[i]=b[j]=false
... | true |
34f4abb9d03f5307a3d0bb0d5157e1e9a24155f7 | Ruby | w0nd3r0us/ruby_fundamentals2 | /exercise4.rb | UTF-8 | 184 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env ruby -wKU
def take_s(string)
if string.length < 8
return "false"
else
return "true"
end
end
puts "enter a word"
string = gets.chomp
puts take_s(string)
| true |
d870afa8ad8a009a2f1a507549eef6943a280a9b | Ruby | acarlson90/movie_app | /spec/models/user_spec.rb | UTF-8 | 5,596 | 3.25 | 3 | [] | no_license | require 'spec_helper'
describe User do
# The block runs the code inside the bloc before each example - in this case, creating a new @user instance variable using User.new and a valid initialization hash
before do
@user = User.new(name: "Example User", email: "user@example.com",
password: ... | true |
ff334747a8d9409207d2372f5b831faf63ac782c | Ruby | fedemcmac/tweet-shortener-london-web-060319 | /tweet_shortener.rb | UTF-8 | 1,392 | 3.796875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def dictionary
{"hello" => "hi",
"to, two, too" => "2",
"for, four" => "4",
"be" => "b",
"you" => "u",
"at" => "@",
"and" => "&"
}
end
def word_substituter(tweet)
cleaned_dictionary = {}
dictionary.map do |key, value|
if key.include? ", "
... | true |
2bc56979417aface3103509ca4327606c4728a37 | Ruby | olouie/dragon | /dragon.rb | UTF-8 | 1,842 | 4.15625 | 4 | [] | no_license | class Dragon
def initialize(name)
@name = name
@hunger = 2
@poop = 2
@sleepy = false
puts "#{@name} has hatched!"
end
def feed
puts "You fed #{@name} a piece of meat."
if @hunger < 4
puts "#{@name} still looks kind of hungry."
else
puts "#{@name} is very full!"
end
@... | true |
75e916a665516c16040e9dc4057adca68b37c2b8 | Ruby | codedogfish/ruby-in-action | /ror/chapter1-5/case.rb | UTF-8 | 335 | 3.46875 | 3 | [] | no_license | newDate=Time.new
weekNum=newDate.wday
case weekNum
when 0
puts "Sunday"
when 1
puts "Monday"
when 2
puts "Thuesday"
when 3
puts "Wednesday"
when 4
puts "Thursday"
when 5
puts "Friday"
when 6
puts "Saturday"
else
puts "someth... | true |
2abb8fdb9fc8fbe42f199c3102797f265ed2fbca | Ruby | CodingDojoDallas/ruby_dec_2018 | /chris_truax/ruby_stack/first_vagrant_box/tdd/ruby_tdd/apple_tree/apple_tree_spec.rb | UTF-8 | 2,166 | 3.046875 | 3 | [] | no_license | require_relative 'apple_tree'
RSpec.describe AppleTree do
before(:each) do
@appletree1 = AppleTree.new(1)
@appletree1.age = 4
end
it 'has a getter and setter for age attribute' do
@appletree1.age = 7
expect(@appletree1.age).to eq(7)
end
it 'has a getter for height at... | true |
e31fe60e370f2a3bca77f7209ae0dd4abb60f297 | Ruby | llausa/coder_academy_terminal_app | /tests/user_test.rb | UTF-8 | 772 | 2.78125 | 3 | [] | no_license | # frozen_string_literal: true
require 'test/unit' # https://www.rubydoc.info/gems/test-unit/2.3.1/Test/Unit
require_relative '../src/user.rb' # importing User class
require_relative '../src/configuration' # loading confirguation.rb file for EMAIL and TOKEN constants
# Setup tests for the User class
class UserTest < T... | true |
50735681f123cba73614a1cdcea622a879e98954 | Ruby | holderdeord/hdo-storting-importer | /lib/hdo/storting_importer/parliament_session.rb | UTF-8 | 1,551 | 2.53125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
module Hdo
module StortingImporter
class ParliamentSession
include HasJsonSchema
include IvarEquality
attr_reader :external_id, :start_date, :end_date
schema_path StortingImporter.lib.join("hdo/storting_importer/schema/parliament_session.json").to_s
def self.fro... | true |
f6388c72a591a3e23716da034d0a85f85515b119 | Ruby | lacresni/101_programming_foundations | /small_programs/easy_5/after_midnight_part1_further.rb | UTF-8 | 838 | 4.125 | 4 | [] | no_license | # How would you approach this problem if you were allowed to use ruby's
# Date and Time classes? Suppose you also needed to consider the day of week?
# (Assume that delta_minutes is the number of minutes before or after midnight
# between Saturday and Sunday; in such a method,
# a delta_minutes value of -4231 would nee... | true |
a489681338657c77c5ce54bcb46ba0e80b3b0e99 | Ruby | dudo/cardbinder | /app/helpers/sessions_helper.rb | UTF-8 | 1,331 | 2.609375 | 3 | [] | no_license | module SessionsHelper
# in and out
def sign_in(user)
remember_token = User.new_remember_token
cookies.permanent[:remember_token] = remember_token
user.update_attribute(:remember_token,
User.digest(remember_token))
self.current_user = user
end
def sign_out
current_u... | true |
21f0f4ee7e7052c3c7b795b50dde598269c9405c | Ruby | ptmccarthy/euler | /ruby/pe016.rb | UTF-8 | 261 | 3.1875 | 3 | [] | no_license | =begin
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?
=end
bignum = 2**1000
sum = bignum.to_s.chars.map(&:to_i).inject(:+)
puts sum
#1366
#
#real 0m0.034s
#user 0m0.024s
#sys 0m0.008s | true |
129ce5a9fba6a1ba34447679ae8b9b42e08a5f5d | Ruby | vicomte/esi-sdk-ruby | /lib/esi/client/skills.rb | UTF-8 | 4,041 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module ESI
class Client
# ESI skills operations.
module Skill
# Return attributes of a character.
#
# This endpoint is cached for up to 120 seconds.
#
# This endpoint requires authorization (see {ESI::Client#authorize}).
#
# @esi_scope e... | true |
8ee5145d8f75d8b1a5ce4a8b6a982ff245957e13 | Ruby | vatavian/Advent-of-Code-2020 | /10.rb | UTF-8 | 309 | 2.71875 | 3 | [] | no_license | # Advent of Code 2020 Day 10
input = IO.readlines('10-input.txt', chomp: true).map(&:to_i).sort
input.append(input[-1] + 3) # Add built-in adapter
p input
prev_j = 0
differences = Hash.new(default = 0)
input.each do |j|
difference = j - prev_j
differences[difference] += 1
prev_j = j
end
p differences
| true |
11223d8cb35e497f8a00ced76b6b7423b6c43e02 | Ruby | acareaga/scrabble | /test/scrabble_test.rb | UTF-8 | 657 | 3 | 3 | [] | no_license | gem 'minitest'
require 'minitest/autorun'
require 'minitest/pride'
require './lib/scrabble'
class ScrabbleTest < Minitest::Test
def test_it_can_score_a_single_letter
assert_equal 1, Scrabble.new.score("a")
assert_equal 4, Scrabble.new.score("f")
end
def test_it_can_score_multiple_letters
assert_equ... | true |
b3e511004590fb28da0e88f837f0bcc958e0cdec | Ruby | mojotron/hangman | /lib/hangman.rb | UTF-8 | 7,111 | 3.578125 | 4 | [] | no_license | require 'json'
class Hangman
attr_accessor :misses, :secret_word, :guessing_word, :turns
@@dictionary = "dictionary.txt"
def initialize
puts `clear`
@display_hangman = DisplayHangman.new
@misses = Array.new
@guessing_word = Array.new
@turns = 0 #variable used for calling correct display from @display_han... | true |
3c9fd366f1aab3832c1a79364ade304865681e58 | Ruby | neioge/aws_rails_cap | /test/models/employee_test.rb | UTF-8 | 4,574 | 2.765625 | 3 | [] | no_license | require 'test_helper'
class EmployeeTest < ActiveSupport::TestCase
# validな従業員をセットアップする。
def setup
@employee = Employee.new(
name: "Example Employee",
email: "employee@example.com",
password: "foobar",
password_confirmation: "foobar"
)
end
test "should be valid" do
asser... | true |
37d564f3579464844bf1e60086cfde33e29258cd | Ruby | rongxanh88/1module-sorting_suite | /bubble_sort.rb | UTF-8 | 759 | 4.09375 | 4 | [] | no_license | require 'pry'
class BubbleSort
def sort(collection)
if collection.length < 2
puts "Array has less than two elements"
return collection
end
sorted = false
while !sorted do
swapped = false
index = 0
while index < collection.length - 1 do
if collection[index] > co... | true |
cfaa429e0a8f8f76b68afd9263211c67cf835709 | Ruby | nimam1992/ruby-enumerables-introduction-to-map-and-reduce-lab-nyc-web-030920 | /lib/my_code.rb | UTF-8 | 1,238 | 3.4375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map_to_negativize(source_array)
i = 0
new_array = []
while i<source_array.length do
new_array << source_array[i]*-1
i+=1
end
new_array
end
def map_to_no_change(source_array)
i = 0
new_array = []
while i<source_array.length do
new_array << source_array[i]
i+=1
end
new_array
e... | true |
13827c05cf9340fb884e0ba25fea4ced05d8dfb5 | Ruby | Tracht/OysterCard | /spec/journey_spec.rb | UTF-8 | 1,280 | 2.921875 | 3 | [] | no_license | require 'journey'
require 'card'
shared_context "topped up & tapped_in" do
let(:subject) do
entry_station = double()
min_balance = Card::MIN_BALANCE
subject = Card.new
subject.top_up(min_balance)
subject.tap_in(entry_station)
subject
end
end
describe Journey do
context 'when initialized... | true |
6ff2de4b1ee628fe30a3ff4814cf5df23eee2946 | Ruby | sfllaw/radtrack-core | /app/models/task_state.rb | UTF-8 | 621 | 2.53125 | 3 | [] | no_license | # == Schema Information
# Schema version: 20100613153258
#
# Table name: task_states
#
# id :integer not null, primary key
# name :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
#
class TaskState < ActiveRecord::Base
STARTED =... | true |
dd6b09bf0730afabf876e78240f31c3fc60765ec | Ruby | mark-jordanovic-lewis/ruby-cogs | /examples/cog_fizzbuzz.rb | UTF-8 | 1,274 | 3.40625 | 3 | [
"CC-BY-3.0"
] | permissive | require_relative '../cog'
# must instantiate cog names at top.
room, bob, alice, nicola = nil
def fizzbuzz(n)
n % 15 == 0 ? 'fizzbuzz' : nil
end
def fizz(n)
n % 3 == 0 ? 'fizz' : nil
end
def buzz(n)
n % 5 == 0 ? 'buzz' : nil
end
responses = (1..100).to_a
.map{|i| fizzbuzz(i) || fizz(i) ||... | true |
57249fd6d6b5432326905387030d254c86fe6e9d | Ruby | rbaddam/ruby | /code/ruby_projects/users.rb | UTF-8 | 495 | 2.78125 | 3 | [] | no_license | require 'json'
class User
attr_accessor :name, :email, :permissions
def initialize(*args)
@name = args[0]
@email = args[1]
@permissions = User.permissions_from_file
end
def self.permissions_from_file
file = File.read 'user_permissions.json'
JSON.load(file, nil, sumbolize_name... | true |
c4a097ada75d417650ecb6fa9a1338e06e9ef5a5 | Ruby | ga-wolf/WDI9_Homework | /warmup_exercises/week_04/nucleotide.rb | UTF-8 | 429 | 3.5625 | 4 | [] | no_license | require 'pry'
def valid_nucleotide?( char )
%W[ A T C G U ].include? char
end
def count( nucleotide, char )
if valid_nucleotide? char
nucleotide.count char
else
0
end
end
def nucleotide_counts( nucleotide )
{
:a => count( nucleotide, "A" ),
:t => count( nucleotide, "T" ),
:c => count(... | true |
5fea0c71b76cdceb9eb08f9893d4768973eb5fbd | Ruby | Wumingla/GameClub-ChatRoomManagement | /lib/array.rb | UTF-8 | 3,963 | 2.9375 | 3 | [] | no_license | require 'rexml/document'
class Array
def write_excel_xml(filename, worksheet_name, col_attrs = nil)
open(filename, 'w') do |f|
self.to_excel_xml(worksheet_name, col_attrs).write f
end
end
def to_excel_xml(worksheet_name, col_attrs = nil)
doc = REXML::Document.new(
'<?xml... | true |
a050e9ff5c63b9eefb6cc68214a25de7ff7e6baa | Ruby | southgate/hothubs | /crawl.rb | UTF-8 | 1,268 | 2.625 | 3 | [] | no_license | require 'httparty'
require 'pp'
require 'json'
require 'uri'
# Fredom patch URI so it doesn't puke on [ or ] coming from HTTParty
module URI
class << self
def parse_with_safety(uri)
URI::Parser.new(:UNRESERVED=>URI::PATTERN::UNRESERVED+'\[\]').parse uri
end
alias parse_without_safety parse
al... | true |
7ce5124cc1785c7fc47ecc720d67eab49a7b56b8 | Ruby | neelabhgupta/Geometry | /lib/rectangle.rb | UTF-8 | 268 | 3.765625 | 4 | [] | no_license | #Represents a rectangle given by its length and breadth and the related operations
class Rectangle
attr_reader :length, :breadth
def initialize(length, breadth)
@length = length
@breadth = breadth
end
def perimeter
(length + breadth) * 2
end
end | true |
3af510a0d499bf84036c6ed44161a5a1af4f2144 | Ruby | osu-sig/miq-automation | /Infrastructure/VM/Provisioning/StateMachines/Methods/PostProvision.rb | UTF-8 | 2,067 | 2.59375 | 3 | [] | no_license | ###################################
#
# EVM Automate Method: PostProvision
#
# Notes: This method is used to process tasks immediately after the VM has been provisioned
#
###################################
def log(level, message)
@method = 'PostProvision'
@debug = true
$evm.log(level, "#{@method} - #{message}")... | true |
bfc2936bf4f37be095ee651b74a7bbcdf82be14e | Ruby | mence/website | /plugins/related_posts.rb | UTF-8 | 1,834 | 3.09375 | 3 | [] | no_license | require 'jekyll/post'
# Differs from standard Jekyll LSI related posts implementation
# https://github.com/LawrenceWoodman/related_posts-jekyll_plugin
# Implementation example at https://github.com/LawrenceWoodman/techtinkering.com
# Uses category implementation instead of tags
module Jekyll
module RelatedPostsByC... | true |
47837c63cee17a5a9e22a8f1d3f7938800c8449f | Ruby | Anna-Myzukina/Algorithms-Data-Structures | /Stack.rb | UTF-8 | 1,585 | 4.375 | 4 | [] | no_license | =begin
Min Stack
Create a Stack that contains the standard push and pop methods.
It should also contain another method min that returns the minimum number in the Stack.
Extra Credit
All operations should take O(1) time.
Example
This is an example of a test case:
stack = Stack.new
stack.push(3)
stack.push(5)
put... | true |
e376c474d32f893e1e8f8d40b4b0736086600cd8 | Ruby | lc-guy/ASBot | /utils/markovchains.rb | UTF-8 | 1,409 | 2.96875 | 3 | [
"MIT"
] | permissive | # code made by pickdenis, at https://github.com/pickdenis/ps-chatbot/blob/master/triggers/speaker/markovchains.rb
require 'json'
module Markov
class Chain
attr_accessor :nodes, :keysize
def initialize elements=[], keysize=2
@keysize = keysize
@nodes = {}
add_to_nodes(elements)
... | true |
e2caf64e65d373c94d6ec8fb5a844f219426164d | Ruby | ckirney/SundryCode | /json_to_xlsx/motors_to_xlsx.rb | UTF-8 | 1,165 | 2.90625 | 3 | [] | no_license | require 'write_xlsx'
require 'json'
require 'fileutils'
col_titles = [
"Motor Use",
"Motor Type",
"Minimum Capacity (HP)",
"Maximum Capacity (HP)",
"Motor Full Load Efficiency"
]
json_titles = [
"motor_use",
"motor_type",
"minimum_capacity",
"maximum_capacity",
"nominal_full_lo... | true |
0d620c7c93d4ee1313a5233527f3e87105861c11 | Ruby | plapicola/enigma | /lib/enigma.rb | UTF-8 | 880 | 3.265625 | 3 | [] | no_license | require_relative 'enigma_cipher'
require_relative 'cracker'
require_relative 'key'
require 'date'
class Enigma
def initialize
@character_set = ("a".."z").to_a << " "
@cipher = EnigmaCipher.new
end
def encrypt(message, key = nil, date = today)
key = make_key(key)
{key: key.key,
date: date,
... | true |
87c4c09721e004fb9ca28fb80d533669a195f8bc | Ruby | dareosMyr/ruby_exercises | /hangman/hangman.rb | UTF-8 | 2,769 | 3.890625 | 4 | [] | no_license |
def choose_word
possible_words = []
dictionary = File.readlines("5desk.txt", chomp: true)
dictionary.each do |word|
if word.length >= 5 && word.length <= 12
possible_words.push(word)
end
end
possible_words[rand(possible_words.length)]
end
def generate_goal(goal_word)
goal_correct = []
goal_array = goal... | true |
eba066966a4daecf1905b39a53d240b5df43def0 | Ruby | katkic/janken_exam | /sample.rb | UTF-8 | 1,090 | 4.125 | 4 | [] | no_license | class Player
def hand
puts '数字を入力してください', '0: グー', '1: チョキ', '2: パー', ''
puts '最初はグー、ジャンケン...'
gets.chomp
end
end
class Enemy
def hand
rand(3).to_s
end
end
class Janken
def pon(player, enemy)
hands = { '0' => 'グー', '1' => 'チョキ', '2' => 'パー' }
player_hand = ''
enemy_hand = ''
... | true |
5486ab57ebf9067fc6ba63d15bea31bbc9e2dc66 | Ruby | NYULibraries/browbeat | /lib/browbeat/collection_base.rb | UTF-8 | 704 | 3.125 | 3 | [] | no_license | module Browbeat
class CollectionBase
include Enumerable
extend Forwardable
delegate [:each, :length, :empty?, :<<, :[]] => :@members
def initialize(members = [])
@members = members
end
# wrapper for Array#select that returns instance of this class
def select(&block)
self.clas... | true |
25bba2547244af3b5e07e16b6ee773c11af68452 | Ruby | aanand/transformers-talk | /code/transformers.rb | UTF-8 | 566 | 2.5625 | 3 | [] | no_license | module Sequence
class << self
include Transformer
def bind(obj, &fn)
fn.call(obj)
end
end
end
module NilCheck
class << self
include Transformer
def bind(obj, &fn)
if obj.nil?
nil
else
fn.call(obj)
end
end
end
end
module Search
class << self
... | true |
fb07e09b5c6600f83fb55ed3fb7f124faedff5c0 | Ruby | mattgrande/img-resizer | /get-background-color.rb | UTF-8 | 1,665 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require File.join(File.dirname(__FILE__), 'classes', 'get-outside-colors.rb')
options = { :file_name => nil }
optparse = OptionParser.new do |opts|
opts.banner = 'Usage: get-background-color.rb [options]'
opts.on('-f [file name]', '--filename [file name]', 'The file name of ... | true |
f4530c5457df8285a54542657b1b0ed978c8bfc8 | Ruby | RobHaii/miniMips-Virtual-machine | /assembler/assembler-ruby/assembler.ru | UTF-8 | 3,564 | 2.984375 | 3 | [] | no_license | #!/usr/bin/ruby
$LOAD_PATH << '.'
require 'operation_validity.rb'
require 'registers.rb'
require 'op_codes.rb'
require 'identify_labels.rb'
counter =1
obj_file = File.new("obj_file.ob", "w")
File.open("assemblycode.txt", "r") do |infile|
identified_labels = Identify_Labels.identify()
while (line = infile.gets... | true |
eadffc49b71ee8b593998e2cd1aad2ec26b15192 | Ruby | DouglasAllen/code-Programming_Ruby_3rd_ed | /Part_II--Ruby_in_its_setting/ch15_Ruby_and_Its_World/Environment_Variables/envirronment.rb | UTF-8 | 28 | 2.53125 | 3 | [] | no_license | ENV.each {|item| puts item } | true |
24042a2be11b5951d8cb3cd1de556e1a1111b8fc | Ruby | kunaldi/Code-Samples | /Ruby/Chessboard/queen.rb | UTF-8 | 713 | 3.28125 | 3 | [] | no_license | require './chess_board'
require './chess_piece'
class Queen < ChessPiece
# Specific movement ability of Queen piece
# calculates up-down, left-right and each diagonals
def movable_squares
x, y = self.position
squares = (1..8).inject([]) do |m, o|
m << [
[x, y - o], # down offset
... | true |
f3d5619fbd45c970270235b4ff802cae824dd2de | Ruby | cklim83/launch_school | /02_rb101_rb109_small_problems/02_easy_2/10_mutation.rb | UTF-8 | 3,623 | 4.59375 | 5 | [] | no_license | =begin
Mutation
What will the following code print, and why? Don't run the code
until you have tried to answer.
array1 = %w(Moe Larry Curly Shemp Harpo Chico Groucho Zeppo)
array2 = []
array1.each { |value| array2 << value }
array1.each { |value| value.upcase! if value.start_with?('C', 'S') }
puts array2
My answe... | true |
a32b606adec61959c39a9203e46c799c148726d8 | Ruby | cpan001/collections_practice_vol_2-prework | /collections_practice.rb | UTF-8 | 1,058 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
def begins_with_r(array)
array.all? { |i|
i.start_with?("r")
}
end
def contain_a(array)
array.select { |i|
i.include?("a")
}
end
def first_wa(array)
array.find { |i|
i[0] == "w" && i[1] == "a"
}
end
first_wa_array = ["candy", :pepper, "wall", :ball, "wacky"]
puts first_w... | true |
a4923a60d256d4ff9d77cfa2a4901f8bc4e14923 | Ruby | cferwin/Constellation | /src/item.rb | UTF-8 | 213 | 2.703125 | 3 | [
"MIT"
] | permissive | class Item
attr_accessor :id, :name, :short_desc, :long_desc
def initialize(name, &block)
@name = name
@short_desc = short_desc
@long_desc = long_desc
instance_eval(&block) if block
end
end
| true |
723670c6a52ef4280f9226930a7b1dbb0bfafee9 | Ruby | dharshan/html-css-workshop | /ruby/variables.rb | UTF-8 | 546 | 3.859375 | 4 | [] | no_license | # no need to add datatype to variables, like int a = 10;
# anything that holds a value
# But
# - variables should not be numbers
# - variables should not be keywords
# -
name = 'Donald'
first_name = 'Donld'
second_name = 'Trimp'
age = 50
height = 6.5
puts first_name # go and fetch value present in first_name... | true |
3b50aa640bbc2ac03d099f6aa53e56f0125d6d02 | Ruby | neilconway/garbage-collection | /misc/rse_cart_prod_rewrite.rb | UTF-8 | 1,880 | 2.546875 | 3 | [] | no_license | require 'rubygems'
require 'bud'
# Additional unspecified safety conditions:
# (1) 'sbuf' must not appear on the RHS of any other (user) rules
# (2) 'send_ack' must not appear on the LHS of any deletion rules
class RseCartesianProdTest
include Bud
state do
table :sbuf, [:id]
table :node, [:addr]
scr... | true |
fc395f6ad3e5823380a733d4f48e103e7001f2d1 | Ruby | roselinapradjanata/forex-api | /app/services/exchange_rate_service.rb | UTF-8 | 1,262 | 2.8125 | 3 | [] | no_license | class ExchangeRateService
def self.create(from, to, params)
currency_pair = CurrencyPairService.get_by_currency(from, to)
currency_pair.exchange_rates.create(params)
end
def self.get_trend(from, to, days)
currency_pair = CurrencyPairService.get_by_currency(from, to)
exchange_rates = currency_pair... | true |
3e64d1fea5cb219439de2bd727595219c91da34a | Ruby | AteroConfigs/vocab | /vendor/plugins/ruby_and_rails_extensions/tasks/codesmell.rake | UTF-8 | 2,011 | 2.640625 | 3 | [
"MIT"
] | permissive | class SourceSmeller
class CodeyBits < Struct.new(:line, :tag, :text)
def to_s(options={})
s = "[%3d] " % line
s << "[#{tag}] " if options[:tag]
s << text unless text.nil?
end
end
def self.enumerate(tag, options={})
extractor = new(tag)
extractor.display(extractor.find, options)
... | true |
3d1313dd6cc94a0533890a7411b614f3d23b456b | Ruby | tiiabjork/ruby-tehtava1 | /koodi.rb | UTF-8 | 41 | 2.546875 | 3 | [] | no_license | def summa(luku1,luku2)
luku1+luku2
end
| true |
6bbe50ea2f2ae346bb3228b01bedac6eaf4bab2a | Ruby | Negend/Army-Manager | /classes/base.rb | UTF-8 | 311 | 2.9375 | 3 | [] | no_license | class Base
attr_accessor :location, :platoons, :tools_for_base
def initialize location
@location = location
@platoons = []
@tools_for_base = []
end
def add_platoon platoon
@platoons.push platoon
end
def add_tool tool
@tools_for_base.push tool
end
def to_s
"#{@location} base"
end
end | true |
acea5be699e0fa688c8d676b26e79286bd267cb4 | Ruby | adarowski/Hall-of-Stats | /app/models/bio_formatter.rb | UTF-8 | 1,112 | 2.859375 | 3 | [] | no_license | class BioFormatter
REGEX = /(^|[\W])(@(.+?\d+))(:\w+)?/
def initialize(input, context = nil)
@input = input.strip
@context = context
end
def to_s
mark_down(linked_text)
end
def linked_text
@linked_text ||= link_text
end
def mentioned_players
player_ids = @input.scan(REGEX).map{|m... | true |
55ca110462ba247e2827905c4df48f1a63697976 | Ruby | pjb4752/latch | /lib/latch/cpu_arch/validation.rb | UTF-8 | 894 | 2.5625 | 3 | [] | no_license | module Latch
module CpuArch
module Validation
InvalidInstructionError = Class.new(StandardError)
def validate(name, opcode, operands, operation)
if opcode < MIN_OPCODE || opcode >= MAX_OPCODE
fail_instruction(name, 'opcode out of valid range')
elsif operation.nil?
... | true |
830c5cf7594b2419d10db472fa5468916a742ba1 | Ruby | xaviercrochet/music_apis | /music_apis/query.rb | UTF-8 | 1,305 | 2.6875 | 3 | [] | no_license | require 'json'
require 'open-uri'
module MusicApis
class Query
def self.search(&blk)
raise ArgumentError, "Block not given" unless block_given?
new(&blk).response
end
def initialize(&blk)
@params = {}
if block_given?
instance_eval &blk
end
end
def respons... | true |
bbecf35cde1452bc2a9442184f287fc50a7eebbd | Ruby | antoniomachine/bigml-ruby | /test/test_20_rename_duplicated_names.rb | UTF-8 | 2,234 | 2.890625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../lib/bigml/api"
require_relative "../lib/bigml/model"
require "test/unit"
class TestDuplicatedFields < Test::Unit::TestCase
def setup
@api = BigML::Api.new
@test_name=File.basename(__FILE__).gsub('.rb','')
@api.delete_all_project_by_name(@test_name)
@project = @api.create_project({'n... | true |
81815b8c798ca9e42ae8cbc9fab6cce21d85f242 | Ruby | pinnacol/linecook | /test/linecook/cookbook_test.rb | UTF-8 | 2,717 | 2.53125 | 3 | [
"MIT",
"X11-distribute-modifications-variant"
] | permissive | require File.expand_path('../../test_helper', __FILE__)
require 'linecook/cookbook'
class CookbookTest < Test::Unit::TestCase
include ShellTest::FileMethods
Cookbook = Linecook::Cookbook
FIXTURES_DIR = File.expand_path('../../fixtures', __FILE__)
DIR_ONE = File.expand_path('dir_one', FIXTURES_DIR)
DIR_TWO... | true |
e5ef8498c6cfab6b4dcf5f265daedce19a1f2945 | Ruby | GoodMorningNissim/boker-tov-bot | /lib/boker_tov_bot/message_handlers/thh_handler.rb | UTF-8 | 667 | 3 | 3 | [
"MIT"
] | permissive | require 'boker_tov_bot/message_handlers/base_handler'
module BokerTovBot
module MessageHandlers
class ThhHandler < BaseHandler
def initialize(options = {})
@regex = /\b(ט+ח+)\b/mi
super(options)
end
def match?(message)
@regex.match(message.downcase) ? true : false
... | true |
0560d49d4c906f2fc499cc567a671272c69f08f7 | Ruby | geniusninja88/my-test-repo | /sean-code/joe-developed/sort.rb | UTF-8 | 1,257 | 4.125 | 4 | [] | no_license | # Sorting Function.
# Reads from file "sort_test.txt" and sorts the numbers found within
file_handle = File.open(File.dirname(__FILE__) + "/unsorted_files/unsorted_random.txt", "r") or die "Unable to open file"
numbers = []
file_handle.each_line do |line|
numbers.push(line.to_i)
end
# Crude bubble sort. Still not... | true |
50bd7f822077b5ca9f560367096f8b01da69bb77 | Ruby | sebcoetzee/pmt | /spec/pmt/primes_spec.rb | UTF-8 | 1,435 | 3.421875 | 3 | [
"MIT"
] | permissive | describe Pmt::Primes do
describe "#is_prime_number function" do
describe "for an array of expected inputs" do
let(:inputs) { [
[2, true],
[3, true],
[4, false],
[23, true],
[24, false],
[33, false],
[195, false],
[197, true]
] }
it... | true |
ae0e3269c76ae17448a0fd897d783343a14afba6 | Ruby | janx/lovd-by-less | /vendor/gems/avatar-0.0.5/lib/avatar/object_support.rb | UTF-8 | 138 | 2.765625 | 3 | [
"MIT"
] | permissive | unless Object.method_defined?(:returning)
Object.class_eval do
def returning(value)
yield(value)
value
end
end
end | true |
89f3f8b4f522c09048d4314df28a816c7f789359 | Ruby | hanmoonkyo/tt-lib | /tests/TT_Lib/TC_Color.rb | UTF-8 | 2,012 | 2.921875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'testup/testcase'
require 'modules/color'
module SkippyLib
class TC_Color < TestUp::TestCase
def setup
# ...
end
def teardown
# ...
end
def test_initialize
color = Color.new(64, 128, 192, 32)
assert_kind_of(Color, color)
as... | true |
343461d26e5c42b286fa08fc108acb9f4b778810 | Ruby | cmloegcmluin/AppAcademy-exercises-archive | /early_ruby_exercises/make_change_2.rb | UTF-8 | 1,189 | 3.46875 | 3 | [] | no_license | def make_change(amount, coins)
biggest_coin = coins.first
if amount == 0
change = []
elsif coins.empty?
raise "Unable to make this change with these coins."
else
count = 0
until amount < biggest_coin
count += 1
amount -= biggest_coin
end
change = make_change(amount, coins.d... | true |
fdefa1d590abbee866abd4b9dcd7365344aa7f81 | Ruby | kespry/ffi-gdal | /lib/ffi-gdal/major_object.rb | UTF-8 | 1,840 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative '../ffi/gdal'
module GDAL
module MajorObject
include FFI::GDAL
# @return [Array<String>]
def metadata_domain_list
# I don't quite get it, but if #GDALGetMetadataDomainList isn't called
# twice, the last domain in the list sometimes doesn't get read.
GDALGetMetadataDom... | true |
d1410de36c9291afcd1fd7da450bc004185e3a1a | Ruby | cwhight/codewars | /ruby/6_consecutive_strings.rb | UTF-8 | 332 | 3.28125 | 3 | [] | no_license | def longest_consec(strarr, k)
return "" if strarr.length == 0 || k > strarr.length || k <= 0
maxLength = 0
string = ""
strarr.each_with_index do |str, ind|
if strarr[ind, k].join.length > maxLength
maxLength = strarr[ind, k].join.length
string = strarr[ind, k].join
end
end
return ... | true |
cf1d8f831f8377f0f35b1e1382603755725afe27 | Ruby | tonytu16/ics-bootcamp1 | /ics-bootcamp_assignment_1/chapter10/shuffle.rb | UTF-8 | 772 | 4.03125 | 4 | [] | no_license | def shuffle array_List
shuffle array_List, []
end
def shuffle Array_Input, Shuffled_Array
if Array_Input.length == 0 or Array_Input.length = 1
puts Shuffled_Array
else
element = rand(Array_Input.length)
Shuffled_Array.push(Array_Input[element])
Array_Input.delete.at(element)
shuffle(Array_Inp... | true |
a74265efdd327c26538d5ab3e5176dee8ffce412 | Ruby | TonyNarisi/battleship-challenge | /model/submarine.rb | UTF-8 | 144 | 2.625 | 3 | [] | no_license | require_relative 'ship.rb'
class Submarine < Ship
def initialize
super
@size = 1
@name = "Submarine"
@code = "S"
end
end
| true |
3e18f9f7d198c7e35535ddc465e34ffa984f6b16 | Ruby | mtrense/mahuta | /lib/mahuta/common/tree_producer.rb | UTF-8 | 3,808 | 2.609375 | 3 | [] | no_license | # encoding: UTF-8
# Copyright 2017 Max Trense
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agre... | true |
6d6b6379082758446787a5b40a2a57a1b9ff4a5b | Ruby | iumehara/cat-collector | /spec/models/dish_spec.rb | UTF-8 | 1,745 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Dish, type: :model do
describe 'RELATIONSHIPS' do
let(:yard) { Yard.create }
let(:dish) { Dish.create(yard_id: yard.id) }
describe 'belongs to yard' do
it 'belongs to yard' do
expect(dish.yard).to eq(yard)
end
end
describe 'has one food'... | true |
c005ee80e068bace7da5ec16659914bcd84662ce | Ruby | ikwzm/rbvhdl | /lib/rbvhdl/ast/association/actual_part.rb | UTF-8 | 1,826 | 2.8125 | 3 | [
"BSD-2-Clause"
] | permissive | module RbVHDL::Ast
class Association
class ActualPart
attr_accessor :_owner
def initialize(owner)
@_owner = owner
end
end
class ActualName < ActualPart
attr_reader :_name
def initialize(name)
super(nil)
@_name = name
end
end
class A... | true |
124ce8f1ef3870b24192859dbfac0609db5f1ed2 | Ruby | jaerodyne/phase-0-tracks | /ruby/shout2.rb | UTF-8 | 550 | 3.765625 | 4 | [] | no_license | # module Shout
# def self.yell_angrily(words)
# puts words + "!!!" + " :("
# end
# def self.yelling_happily
# puts "It's raining men hallelujah!"
# end
# end
# Shout.yell_angrily 'PARKOUR'
# Shout.yelling_happily
module Shout
def yell_angrily(words)
puts words + "!!!" + " :("
end
de... | true |
cdef3f0050002e8cc558847b19350051963508f9 | Ruby | tmock12/sup-race-finder | /app/retrievers/distressed_mullet_race_retriever.rb | UTF-8 | 956 | 2.609375 | 3 | [] | no_license | class DistressedMulletRaceRetriever < BaseRaceRetriever
def url
'http://distressedmullet.com/calendar'
end
def get_races
page.css(".view-race-calendar .views-row").each do |race|
title = race.at_css('.views-field-title').text.strip
date = race.at_css('.date-display-single').text + '.2014'
... | true |
01bd2e0586aaf3e1668ff5792ddb6e653b134fc7 | Ruby | wadiim/kira | /spec/sudoku_test.rb | UTF-8 | 5,254 | 3.25 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require 'kira/sudoku'
RSpec.describe Kira::Sudoku do
before(:each) do
@grid =
"5.67..34.\n"\
"492.35718\n"\
"3.78...69\n"\
"..9281.7.\n"\
"7..9562..\n"\
"2.14.389.\n"\
"9...67..3\n"\
".7..9.6.4\n"\
".6534.927"
@solved_grid =
... | true |
3962a93b2bfbf7fb79c1457cd09c79410290d912 | Ruby | Alung-0/design-2 | /ruby/academy/11.4.now-you-try.rb | UTF-8 | 1,320 | 4.6875 | 5 | [
"Apache-2.0"
] | permissive |
=begin
Now You Try!
Great work! You've written your own lambda and seen
how to pass it to a method. Now it's time for you
to write a lambda and pass it to a method!
If you think this will be a lot like what you've
already done with procs, you're exactly right.
Just like with procs, we'll need to put & at
the... | true |
346589350a2514b711fa999c1a593de86fc5894c | Ruby | djangid/jlogger | /lib/jlogger.rb | UTF-8 | 5,713 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rubygems'
require 'rjack-logback'
# Redefine how to get logger names
module RJack
module SLF4J
def self.to_log_name classobject
classline = []
parent_is_a_logback = false
loggingname = 'none'
ancestors = []
classobject.ancestors.each do |c|
c = c.to_s
if c ... | true |
7b2ff27ecec52ce7dd2cb8508c9d9d35ec34ba34 | Ruby | jraphael/project-euler | /problem_2.rb | UTF-8 | 518 | 3.578125 | 4 | [] | no_license | # encoding: utf-8
# #
# Even Fibonacci numbers
# Problem 2
=begin
def fib(n)
if n > 2
fib(n-1) + fib(n-2)
else
1
end
end
nums = []
i=1
while i < 4000000 do
nums.push fib(i)
i = i + 1
end
puts nums.select {|n| n.even? }.inject(0, &:+)
=end
#i=1
#while i <= 10 do
# a,b=[a+... | true |
6c21433f3c820dfae32216b39cb68a7f8946d7d2 | Ruby | kaseymccormick/assignment_tracker | /models/old/age.rb | UTF-8 | 638 | 3.109375 | 3 | [] | no_license | require "SQLite3"
require_relative "../database_setup.rb"
require_relative "../database_class_methods.rb"
require_relative "../database_instance_methods.rb"
class Age
extend DatabaseClassMethods
include DatabaseInstanceMethods
attr_reader :id
attr_accessor :range
#initalize a new responder object
... | true |
3eb7fe1419d604c004cbb9c469c3808277c01521 | Ruby | rordev2/largest_prime | /consecutive_prime_sum.rb | UTF-8 | 610 | 3.578125 | 4 | [] | no_license | require 'mathn'
def largest_prime_sum
prime_numbers = Prime.each(10000).to_a # generate prime numbers till 10000
largest_prime = []
sum = 0 # make sum for each consective prime number
prime_numbers[0..10].each_with_index do |p, i|
n = i
begin
n += 1
consective_prime = prime_... | true |
1cd55ab8d2375e2db0f32cc34d2520cb91fb9a31 | Ruby | tondol/NicoVideo | /nico/base.rb | UTF-8 | 2,984 | 2.59375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
####################################
# Base
####################################
module Nicovideo
# constant values
BASE_URL = 'http://www.nicovideo.jp'
BASE_HOST = 'www.nicovideo.jp'
WATCH_PATH = '/watch/'
# proxy configuration
PROXY_HOST = nil
PROXY_PORT... | true |
9c79d6944c4966f0843ce51614ce9192529d4263 | Ruby | sselea/crm | /crm.rb | UTF-8 | 2,704 | 3.875 | 4 | [] | no_license | require_relative "contact"
require_relative "rolodex"
class Crm
attr_reader :name
def self.run(name)
crm = Crm.new(name)
crm.main_menu
end
def initialize(name)
@name = name
@database=Rolodex.new
puts "Welcome to #{name}" #you can do this because of the accessor
end
def print_main_menu
puts "... | true |
21f68846e14f49fcc312732edcce7d387c984791 | Ruby | intecrb/sample_app | /app/helpers/application_helper.rb | UTF-8 | 501 | 2.671875 | 3 | [] | no_license | module ApplicationHelper
# ページごとの完全なタイトルを返します。
def full_title(page_title = '')
base_title = "Ruby on Rails Tutorial Sample App"
# .empty?で文字列が空かどうか
# .nil?でobjectそのものが空かどうか
# .blank?で...?
if page_title.empty?
base_title
else
# page_title + "|" + base_title
# + で文字列はジョインしないほ... | true |
aae1fc2d202151f91c9986e2e3909142796c9801 | Ruby | niri4/training | /exercise25_part2.rb | UTF-8 | 496 | 3.3125 | 3 | [] | no_license | require "./exercise25_part1.rb"
include Ex25
sentence = "All good things come to those who wait."
#ob = Ex25.new()
words = Ex25.break_words(sentence)
puts words
sorted_words = Ex25.sort_words(words)
sorted_words
Ex25.print_first_word(words)
Ex25.print_last_word(words)
words
Ex25.print_first_word(sorted_words)
Ex25.pri... | true |
1f50a65d087750259e1830a793d488bb1c06f220 | Ruby | aspgems/locomotivecms-search | /app/services/locomotive/search_service.rb | UTF-8 | 1,594 | 2.515625 | 3 | [
"MIT"
] | permissive | module Locomotive
class SearchService
def from_backoffice(site, text, options = { radius: 150 })
# scope the search by the site
conditions = { 'site_id' => site._id }
# locale agnostic
options[:locale] = false
# launch the search with the current engine
::ActiveSearch.search... | true |
4f1f6a591675588e9da642fa923e7c2798fa3bf7 | Ruby | mestahh/bowling_game | /lib/bowling_game.rb | UTF-8 | 1,293 | 3.296875 | 3 | [] | no_license | class BowlingGame
def initialize
@frames = []
@frames << Frame.new
end
def roll score
if ended?
raise "Game ended."
end
frame = get_current_frame
frame.roll score
end
def frame_score frame_index
@frames[frame_index].score
end
def score
sum_of_scores = 0
... | true |
99e81a3035c5c7ef90ac80bd8b666b2590f3d106 | Ruby | hellosylvee/object-relations-assessment-web-031317 | /app/models/review.rb | UTF-8 | 315 | 3.09375 | 3 | [] | no_license | class Review
attr_accessor :customers, :restaurants
@@all = []
def initialize(name)
@name = name
@@all << name
end
def self.all
@@all
end
def customer
self.name = customer.name
customer.name
end
def restaurant
self.name = restaurant.name
restaurant.name
end
end
| true |
5677383df5a80dfe71d43ff0d39281049a904e5b | Ruby | seanhawkridge/tournament-ruby | /Rakefile | UTF-8 | 1,373 | 3.1875 | 3 | [] | no_license | require './lib/player.rb'
require './lib/match.rb'
require './lib/tournament.rb'
namespace :examples do
task :all => [:example_one]
tournament = Tournament.new
p1 = Player.new("Bill")
p2 = Player.new("Bob")
p3 = Player.new("Jim")
p4 = Player.new("Jon")
p5 = Player.new("Jack")
p6 = Player.new("Ed")
... | true |
02a893c7c107c63eddb53a4ae690bf0724178924 | Ruby | fierytortilla/week01_day03_hw | /for_loops.rb | UTF-8 | 266 | 3.265625 | 3 | [] | no_license | numbers = [1,2,3,4,5]
total=0
for number in numbers
total+=number
end
p total
chickens= [
{:name =>"bill",:eggs=>3},
{:name=>"fred", :eggs=>4},
{:name=>"augustus", :eggs=>5},
{:name=>"lauren", :eggs=>2}
]
for chicken in chickens
p chicken[:name]
end
| true |
eebb46d92501780ae6c761307d2fbb503494a930 | Ruby | Shehbaz/prima | /bin/prima | UTF-8 | 376 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'prima'
require 'trollop'
opts = Trollop::options do
opt(:count, "Select amount of primes", type: :integer)
end
Trollop::die :count, "must be greater than 0 " if opts[:count].nil? || opts[:count] < 1
primes = Prima::Prima.new(opts[:count]).generate
table = Prima::Table.generate(pr... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.