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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6bdd11c8093b00d6a1d69943d41933ca30e98ade | Ruby | codegourmet/spawning_logger | /test/spawning_logger_test.rb | UTF-8 | 2,746 | 2.515625 | 3 | [
"MIT"
] | permissive | require_relative "./test_helper"
require_relative "../lib/spawning_logger"
class SpawningLoggerTest < MiniTest::Test
def setup
@log_base_dir = Dir.mktmpdir('spawning_logger_test')
@log_dir = File.join(@log_base_dir, 'test_subdir')
@logfile_name = 'test_file.log'
@logfile_path = File.join(@log_base_... | true |
49bd4ec7a888359b1ebe8deb5a397a41e14f0b13 | Ruby | ketwalters/FIS-Homework | /Number-Guesser/number-guesser.rb | UTF-8 | 229 | 3.53125 | 4 | [] | no_license | while true
puts "Please enter a number between 1 and 100"
number = gets.chomp.to_i
answer = rand(100)
if answer == number
puts "You are correct"
break
else answer != number
puts "Guess again"
end
end | true |
a191d091bd84f1afe610abebd4b21a96d6710785 | Ruby | kos31de/RubyForPro | /Section7/redefine_eql?.rb | UTF-8 | 233 | 3.46875 | 3 | [] | no_license | # frozen_string_literal: true
a = 'japan'
b = 'japan'
# eql?が真なら、hashも値も同じ
puts a.eql?(b)
puts a.hash
puts b.hash
c = 1
d = 1.0
# eql?が偽なら、hashも値も異なる
puts c.eql?(d)
puts c.hash
puts d.hash
| true |
b8286fb8e699e51da35916286bc18d4687f1ed45 | Ruby | tomaaszq/name-array-capping | /namearray.rb | UTF-8 | 91 | 3.015625 | 3 | [] | no_license | def cap_me(arr)
a = arr.each {|i| i.downcase!}
b = a.each {|n| n.capitalize!}
return b
end
| true |
d942ceeeaacc42126d234c5560d23e9316b7ca55 | Ruby | rayning0/tealeaf | /hw1.rb | UTF-8 | 2,645 | 4.46875 | 4 | [] | no_license | #1. Use the "each" method of Array to iterate over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and print out each value.
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
x.each {|i| puts i}
puts
#2. Same as above, but only print out values greater than 5.
=begin
x.each do |i|
if i > 5
puts i
end
end
x.each do |i|
puts i if i > 5
end... | true |
b8954582b298480e7efe514f77283ee19d9b7d33 | Ruby | happyjedi/challenges | /Codility/lesson1-1-binary_gap.rb | UTF-8 | 139 | 2.828125 | 3 | [] | no_license | def solution(num)
return 0 if num.zero?
max = num.to_s(2).gsub(/^0+/, '').gsub(/0+$/, '').split(/1+/).max
max.nil? ? 0 : max.size
end | true |
540c4456928a8911573470a6bc67ef4c9fb9c450 | Ruby | wbabicz/birthday-countdown | /birthday.rb | UTF-8 | 201 | 2.5625 | 3 | [] | no_license | require 'sinatra'
d = Date.today
get '/' do
output = case birthday
when d.month == 8 && d.day == 10
'YEP.'
else
'NOPE.'
end
erb :index, :locals => {:output => output}
end
| true |
b5bd317f54c624a0dbdaaa24b58dcbc425e893bd | Ruby | ncalibey/Launch_School | /exercises/120_oop/oo_basics_accessors/oob_409.rb | UTF-8 | 190 | 3.59375 | 4 | [] | no_license | # oob_409.rb - Calculated Age
class Person
def age=(age)
@age = age * 2
end
def age
@age * 2
end
end
person1 = Person.new
person1.age = 20
puts person1.age
| true |
6bd988a77e1d798a550594576f5d7a2dfe6d3ad8 | Ruby | henningde/Zweitag-App1 | /app/youtube.rb | UTF-8 | 735 | 2.578125 | 3 | [] | no_license | # coding: utf-8
require 'nokogiri'
require 'pry'
require_relative 'api_module.rb'
class YouTube
include ApiModule
attr_accessor :xml_code
def format
:xml
end
def initialize(location, url=nil)
@url = url
@location= location
@url||= "https://gdata.youtube.com/feeds/api/videos?q=#{@location}"
end
def re... | true |
0400bffd450595401444eadcc8c5c7cc6a8b99ad | Ruby | elreyatee/launch-school | /oop/lesson_5/oo_tictactoe/displayable.rb | UTF-8 | 1,852 | 3.4375 | 3 | [] | no_license | module Displayable
SPACING = 40
private
def display_winner
if human.score == data[:max]
puts "#{human.name} won the game!"
elsif
puts "#{computer.name} won the game!"
end
end
def display_final_scores
clear_screen
final_scores = <<-FINAL_STATS
GAME STATS
#{display_d... | true |
be2eacaaa8591847f9ae9e8cf03422b72d583dd0 | Ruby | chrischi90/NYCDA-homework | /homework-1/problem-3/problem-three.rb | UTF-8 | 88 | 3.4375 | 3 | [] | no_license | def join_strings(x,y)
x.to_s + ' ' + y.to_s
end
puts join_strings('Hello', 'World!')
| true |
9cb18c83353cb17f6e1a7d201faedb7cb092f11a | Ruby | Ivymark/maily | /app/helpers/maily/emails_helper.rb | UTF-8 | 673 | 2.53125 | 3 | [
"MIT"
] | permissive | module Maily
module EmailsHelper
def total_emails(mailers)
mailers.map { |mailer| mailer.total_emails }.sum
end
def email_description(email)
return unless email.description
content_tag(:div, class: 'mail_description') do
concat content_tag(:strong, 'Description ')
conca... | true |
59519b9d83848462ed8d27c29825a1252fc31bcf | Ruby | dmitryjum/photoviewer_api | /spec/requests/images_controller_spec.rb | UTF-8 | 3,957 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
describe V1::ImagesController do
before do
@image1 = Image.create url: "https://picsum.photos/id/12", dimensions: ["400/200", "300/300"]
@image2 = Image.create url: "https://picsum.photos/id/44", dimensions: ["250/250"]
@image3 = Image.create url: "https://picsum.photos/id/48", di... | true |
f8b316d3606bc80dcc0b9ec3740fbc46dac7b262 | Ruby | ahoff23/sample_app | /app/controllers/users_controller.rb | UTF-8 | 5,628 | 2.578125 | 3 | [] | no_license | class UsersController < ApplicationController
#Only allow edit and update functions after running 'signed_in_user' function (private)
before_action :signed_in_user, only: [:edit, :update, :index, :destroy, :following, :followers]
#Only allow edit and update functions after running 'correct_user' function (private... | true |
1274367dee23c1992fea7468ff96d3a3f2e17023 | Ruby | cyanoprem/timebot | /lib/message/logger.rb | UTF-8 | 680 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Message
module Logger
def log_incoming_message(user, message)
return unless user && message
Rails.logger.info "#{Time.zone.now.strftime('%H:%M:%S %d.%m.%Y')} - Receive message from #{user.name}: " \
"#{remove_new_lines(message)}"
end
def ... | true |
5c0f1b832751aba600e35f2b0b31821bd1a4d595 | Ruby | jasonwells/ruby-jet | /lib/jet/client/orders.rb | UTF-8 | 1,381 | 2.53125 | 3 | [
"MIT"
] | permissive | module Jet
class Client
# Orders client
class Orders
STATUSES = {
created: 'created',
ready: 'ready',
acknowledged: 'acknowledged',
inprogress: 'inprogress',
complete: 'complete'
}
def initialize(client)
@client = client
end
def g... | true |
a77d3a53d923cda034d528f82ed474c090114c5b | Ruby | Vizzuality/trase | /app/services/api/v3/dashboards/nodes_to_filter_by.rb | UTF-8 | 1,805 | 2.578125 | 3 | [
"MIT"
] | permissive | module Api
module V3
module Dashboards
class NodesToFilterBy
WHITELISTED_KEYS = [
:sources_ids,
:companies_ids,
:exporters_ids,
:importers_ids,
:destinations_ids
].freeze
attr_reader :keys, :node_types_ids, :nodes
# @param n... | true |
322ab49852b93fd0c89c4e348a9d80000bf97a4d | Ruby | BookingSync/bookingsync-api | /lib/bookingsync/api/client/living_rooms.rb | UTF-8 | 2,637 | 2.734375 | 3 | [
"MIT"
] | permissive | module BookingSync::API
class Client
module LivingRooms
# List living_rooms
#
# Returns living_rooms for the account user is authenticated with.
# @param options [Hash] A customizable set of options.
# @option options [Array] fields: List of fields to be fetched.
# @return [Arr... | true |
488f72a42108e72c8361fafa5f27e7e5e3dba3aa | Ruby | ruthedition/ruby-music-library-cli-onl01-seng-pt-030220 | /lib/MusicLibraryController.rb | UTF-8 | 2,676 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class MusicLibraryController
attr_accessor :music_importer
def initialize(path="./db/mp3s")
MusicImporter.new(path).import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts "To list all of the artists in your library, enter '... | true |
b59ee41d8cef5eea3a05fed1e6a0f4252684c8bd | Ruby | VitoMendoza/CucumberRubyAutomationProject | /features/step_definitions/upwork_steps/find_freelancers_steps.rb | UTF-8 | 3,758 | 3.015625 | 3 | [] | no_license | # encoding: UTF-8
# Use steps from upwork_steps.rb
# Use steps from commons_steps.rb
# Step 3
#
# Navigate to upwork site web.
# The URL is taken from a global variable $pages. It's declared in env.rb file
# Log action.
Given /^go to www.upwork.com$/ do
puts "3. Go to www.upwork.com."
visit $pages['upwork'... | true |
ab965eab641e1e4f6cf98ec26ad43f37d7cf6765 | Ruby | arieldavis22/ruby-enumerables-introduction-to-map-and-reduce-lab-atlanta-web-021720 | /lib/my_code.rb | UTF-8 | 1,227 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # My Code here....
def map_to_negativize(source_array)
arr = []
i = 0
while i < source_array.length do
arr << source_array[i] * -1
i += 1
end
arr
end
def map_to_no_change(source_array)
source_array
end
def map_to_double(source_array)
i = 0
arr = []
while i < source_array.length do
arr <... | true |
0cb667cd2a1866a02517c1c5764cdb77461499b7 | Ruby | asadujjamandm/testRepo | /app/models/list_item.rb | UTF-8 | 306 | 2.65625 | 3 | [] | no_license | class ListItem < Tableless
column :id, :string
column :display, :string
attr_accessible :id, :display
def self.get(arr)
return nil if arr.nil? || arr.count == 0
item = ListItem.new
item.id = arr["Id"]
item.display = arr["Display"]
return item
end
end | true |
b3f3d043c91ec755d1fda43c4ff993a5e24425c5 | Ruby | DanielJWagener/app-academy-exercises | /software-engineering-foundations/todo_board_project/todo_board.rb | UTF-8 | 1,379 | 3.40625 | 3 | [] | no_license | require_relative "list"
class TodoBoard
def initialize(label = "no label")
@board = Hash.new
end
def get_command
print "\nEnter a command: "
cmd, list, *args = gets.chomp.split(' ')
case cmd
when 'mklist'
@board[list] = List.new(list)
when 'ls'
@board.each_key { |label| put... | true |
6cc47e513eb7136544758529ca2fe7e77cfe1470 | Ruby | akozl/cats-dealer | /app/services/product_aggregation_service.rb | UTF-8 | 791 | 2.796875 | 3 | [] | no_license | class ProductAggregationService
attr_accessor :products
def initialize(products)
@products = products
end
def allowed_query_params
[{location: []}, {shop: []}]
end
def filter_options
{
locations: locations.sort,
shops: shops.sort
}
end
def locations
@locations ||= pro... | true |
4032544c211b248a3628ac9199e015708b65238c | Ruby | Dmarmy/ruby | /task6/passenger_wagon.rb | UTF-8 | 216 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'wagon'
class PassengerWagon < Wagon
def take_volume
super(1)
end
def to_s
"Type: passenger. Volume: free #{free_volume}, busy #{busy_volume}"
end
end
| true |
430d15ded0f9c3110ad93af88f776aabe2457b5a | Ruby | annadolan/headcount | /lib/enrollment_repository.rb | UTF-8 | 972 | 2.953125 | 3 | [] | no_license | require_relative 'shared_methods'
require_relative 'enrollment'
class EnrollmentRepository
attr_reader :district, :enrollments, :input
include SharedMethods
def initialize
@enrollments = {}
end
def load_data(input)
path = input[:enrollment][:kindergarten]
if input[:enrollment][:high_school_grad... | true |
4b22a17163e7853baca3bbf5cf465f6cd1c43915 | Ruby | victoralvesf/ruby-study | /basics/loops.rb | UTF-8 | 294 | 3.59375 | 4 | [] | no_license | 5.times do |i|
puts i + 1
end
i = 0
while i <= 10 do
puts "Count #{i}"
i += 1
end
for i in (0...10)
puts "Count #{(i + 1) * 10}"
end
avengers = ['Iron Man', 'Hulk', 'Spider Man']
for avenger in avengers
puts avenger
end
avengers.each do |avenger|
puts avenger
end
| true |
7f3101c857faa9df67df66515612aad685284236 | Ruby | BeccaSheldon/Library | /LibraryProject.rb | UTF-8 | 5,113 | 3.859375 | 4 | [] | no_license | # 1. Users should be able to add books to library.
# Make Library and Book classes.
class Library
def initialize(books)
@books = [] # I think I'm setting up an array for all the books to live in (be stored in). But I think there's something missing...
@books << Book # This means a Book object will be added to boo... | true |
b53d4fe1bbc81a1808f9ebe455b4e17691df4c5f | Ruby | reqshark/commandlinetools | /sysadmin/backup/rubycookbook/10-Metaprogramming/12 - Evaluating Code in an Earlier Context.rb | UTF-8 | 566 | 3.34375 | 3 | [] | no_license | def broken_print_variable(var_name)
eval %{puts "The value of #{var_name} is " + #{var_name}.to_s}
end
#---
tin_snips = 5
broken_print_variable('tin_snips')
# NameError: undefined local variable or method `tin_snips' for main:Object
var_name = 'tin_snips'
eval %{puts "The value of #{var_name} is " + #{var_name}.to_... | true |
674a75aff89a99fcf4ef29e7a93d9c7640a42bc0 | Ruby | digpanda/legacy-germany-in-the-box | /app/services/metrics/total_orders.rb | UTF-8 | 1,764 | 2.5625 | 3 | [] | no_license | class Metrics < BaseService
class TotalOrders < Base
def settings
{
title: '# of Orders',
type: :bar,
vertical_label: 'Volume'
}
end
def render
draw(:new_orders_per_month, label: 'New orders', color: :light)
draw(:total_orders_per_month, label: 'Total orde... | true |
bf7779c7680133feb68b0d8d9e4be21e35db1b9b | Ruby | usman-tahir/codewars-kata | /ruby/count_smileys.rb | UTF-8 | 122 | 3.171875 | 3 | [] | no_license |
def count_smileys(arr)
count = 0
arr.each { |smiley| count += 1 if smiley =~ /(;|:){1}(-|~)*(\)|D){1}/ }
count
end
| true |
f0b171c87c260fce7d4380bd13bad63ee072cbff | Ruby | tiffanychu/labs | /to_dos/leap_year.rb | UTF-8 | 901 | 4.5 | 4 | [] | no_license | # Write a method that takes in two arguments for a starting year and an ending year, and then puts all of the leap years between them (including the starting and ending years, if they are also leap years).
# Hint: Leap years are years divisible by four (like 1984 and 2004). However, years divisible by 100 are not leap... | true |
cb2d5131cc629a2e57504a78fd9f1dac15414c6f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/bdb03969bb874c9bb2e06e735ee5c327.rb | UTF-8 | 229 | 3.359375 | 3 | [] | no_license | class Phrase
attr_reader :phrase
def initialize(phrase)
@phrase = phrase.downcase.split(/[^0-9a-z']+/)
end
def word_count
tallies = Hash.new(0)
phrase.each { |word| tallies[word] += 1}
tallies
end
end
| true |
7d3a1d6f172ff8559b6e7c9473dc4cf6261b67e4 | Ruby | jeffbski/modulize | /spec/modulize_include_spec.rb | UTF-8 | 1,267 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
# show use of modulize_include inside of a class, automatically modulizing methods
class ClassModulizeInclude
def foo
"ClassModulizeInclude#foo"
end
def bar
"ClassModulizeInclude#bar"
end
end
module MModuleInclude1
def foo
"MMod... | true |
4db922ca8feaf384fa9e9122f5731b67e5288ec4 | Ruby | talon55/Exman | /app/models/group.rb | UTF-8 | 2,524 | 2.640625 | 3 | [] | no_license | class Group
include Mongoid::Document
field :name
field :owner_id, type: BSON::ObjectId
field :admin_ids, type: Array
validates_presence_of :name
#validates_uniqueness_of :name, case_sensitive: false
attr_accessible :name
after_destroy do
self.users.each do |user|
if user.group_ids.include? s... | true |
47d660b9cd8460be3b449056e38034c2e8ede788 | Ruby | ObjectIsAdvantag/tropo-ready-vscode | /samples/ruby/tutorial/19-recordaudio.rb | UTF-8 | 661 | 2.984375 | 3 | [
"MIT"
] | permissive | ## -----------------
## Tutorial 19 - recording audio input
## -----------------
answer
## record a message. Play the beep, caller must speak within 10 seconds.
## Allow 7 seconds of silence and up to 60 seconds of recording.
result = record "Hello. Thanks for calling. Leave your message at the beep.",
{ ... | true |
7154c4ec970297ff5f9b12887fdcfa5eb5a66a08 | Ruby | koriroys/reuser | /spec/reuser/role_spec.rb | UTF-8 | 1,366 | 2.515625 | 3 | [] | no_license | require 'spec_helper'
describe ReUser::Role do
subject do
role = ReUser::Role.new(:admin)
role.can(:read)
role
end
it 'is initialized with a name, and optionally an array of permissions' do
role = ReUser::Role.new :admin
role.name.should == :admin
role.permissions.should == []
role ... | true |
bb08a663fa6a2358f8914bf4fc13f6e772a14df4 | Ruby | eatmorehufu/chess | /lib/pieces/king.rb | UTF-8 | 441 | 2.625 | 3 | [] | no_license | class King < SteppingPiece
def deltas
default_deltas = SteppingPiece::KING_DELTAS
if board.castling[color][:king_side] == true &&
board.clear_castle_path?(color, :king)
default_deltas << [0, 2]
end
if board.castling[color][:queen_side] == true &&
board.clear_castle_path?(color, :qu... | true |
66f3ba9f40e9bd2d0d2e82dd936861e1c09c28b2 | Ruby | emilology/booking-devil | /app/views/number/number.rb | UTF-8 | 183 | 2.75 | 3 | [] | no_license | class Number < ActiveRecord::Base
gets.to_i.chomp
validates :Number, presence: true
end
Number.create(number: 1-50).valid? # => true
Number.create(number: nil).valid? # => false
| true |
7023a4dd3e5552e92cdbdb637db54311e8e5cd21 | Ruby | febuiles/timer.rb | /bin/timer | UTF-8 | 321 | 3.0625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -rubygems
require "timer"
def usage
puts "Usage: timer.rb [duration]\n\n"
puts "Examples: timer.rb 2h"
puts "\t timer.rb 2s"
puts "\t timer.rb 2m"
puts "\t timer.rb 2m 2h 2s\n\n"
end
duration = Timer::TimeParser.parse_duration(ARGV)
duration.nil? ? usage : Timer::Timer.new(duration)... | true |
ac2284718f4b9314df23be14ce76bb6d85ac4029 | Ruby | leighad/activerecord-tvland-onl01-seng-ft-012120 | /app/models/character.rb | UTF-8 | 459 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Character < ActiveRecord::Base
belongs_to :actor
belongs_to :show
def say_that_thing_you_say
"#{self.name} always says: #{self.catchphrase}"
end
end
# Character
# has a first and last name (FAILED - 7)
# belongs to an actor (FAILED - 8)
# belongs to a show (FAILED - 9)
# has a c... | true |
be1922397d38c3f83b85b6685a406bc02aca5367 | Ruby | wilboron/simple_bank | /my_api/app/models/transfer.rb | UTF-8 | 1,377 | 2.796875 | 3 | [] | no_license | class Transfer < ActiveRecord::Base
belongs_to :sender, class_name: 'Account', foreign_key: 'sender_id'
belongs_to :recipient, class_name: 'Account', foreign_key: 'recipient_id'
validates :amount, numericality: { greater_than: 0 }
def validade_transfer
if (@account_sender.balance - amount).negative?
... | true |
9535aed6b46908f053f2dfc618aa22a80387bf8a | Ruby | langlk/doctor_office | /spec/doctor_spec.rb | UTF-8 | 3,390 | 2.9375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "spec-helper"
describe('Doctor') do
it "stores the name, id, and specialty of a doctor" do
doc_test = Doctor.new({:id => 1, :name => "Strange", :specialty => "Surgeon"})
expect(doc_test.name).to(eq("Strange"))
expect(doc_test.specialty).to(eq("Surgeon"))
expect(doc_test.i... | true |
5e291100d7a66e78665b42813c488616461bd4af | Ruby | Gabriel-Batista/sql-library-lab-dumbo-web-071618 | /lib/querying.rb | UTF-8 | 1,277 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def select_books_titles_and_years_in_first_series_order_by_year
"SELECT books.title, books.year FROM books WHERE series_id IS 1 ORDER BY year"
end
def select_name_and_motto_of_char_with_longest_motto
"SELECT characters.name, characters.motto FROM characters ORDER BY LENGTH(motto) DESC LIMIT 1"
end
def select_val... | true |
a52fb6be486fcf406946063a297aa421a528350c | Ruby | lombardo-chcg/grassoverflow | /db/seeds.rb | UTF-8 | 1,658 | 2.796875 | 3 | [
"MIT"
] | permissive | User.destroy_all
Question.destroy_all
Answer.destroy_all
Comment.destroy_all
Vote.destroy_all
25.times do
User.create!(
username: Faker::Name.name,
email: Faker::Internet.email,
password: "password"
)
end
grass_questions = [
"Why does my hair smell like grass?",
"Can I eat grass for dinner?",
"I hav... | true |
cf7e9bd1e2f325c53992fd1e225ae31aa47e31a4 | Ruby | jtbourke/iaccdb | /lib/iac/collegiate_team_computer.rb | UTF-8 | 5,070 | 3.140625 | 3 | [] | no_license | module IAC
class CollegiateTeamComputer
class Result
attr_accessor :total
attr_accessor :total_possible
attr_accessor :combination
attr_accessor :qualified
attr_accessor :has_non_primary
def initialize
@total = 0.0
@total_possible = 0
@combination = []
@qualified = false
@has_non_prima... | true |
cd79f8d41809bb2b369d5c8ead824b26587e34cd | Ruby | alvindng/contacts_ruby | /spec/phone_spec.rb | UTF-8 | 834 | 2.78125 | 3 | [] | no_license | require("rspec")
require('phone')
describe('Phone') do
before() do
Phone.clear()
end
describe('#initialize') do
it "will add a phone contact" do
test_phone = Phone.new({:area_code => "555", :number => "555-5555", :type => "home"})
expect(test_phone.area_code()).to(eq('555'))
end
end
... | true |
977a06824a438c7b4261f93cead99bb3bb3b89d7 | Ruby | sas1ni69/ruby_blocks | /01_greet_user.rb | UTF-8 | 113 | 2.75 | 3 | [] | no_license | def greet_user(name)
puts "hello #{name}"
yield
end
greet_user('Hass') do
puts "welcome to this app"
end
| true |
179f665f6521b5d0e895d9d35df8f0f8f45bb09c | Ruby | yousefokka/pract | /problem/Beautiful.rb | UTF-8 | 316 | 3.5 | 4 | [] | no_license | i = 1
j = 1
while i <= 5
while j <= 1
puts "take a x"
x = gets.chomp.split.map(&:to_i)
puts "i tike and i will pluss it"
if x = 1
puts"this big"
end
puts "this is j #{j}"
j = j + 1
end
puts "this is i #{i}"
i = i + 1
j = 1
end
| true |
7837de3129ca814a69eee506a435930c8a507bf0 | Ruby | Navirator/courses | /классс.rb | UTF-8 | 164 | 3 | 3 | [] | no_license | class Class
alias oldNew new
def new(*args)
print "Создается новый #{self.name}\n"
oldNew(*args)
end
end
class Name
end
#n = Name.new | true |
0f60a81d7f1f935f9c3e0b6a7476bc1841aad6f5 | Ruby | tico14/calculators | /slope_calculator.rb | UTF-8 | 593 | 3.671875 | 4 | [] | no_license | puts "Welcome to Tristan's Patented SLOPE Calculator!"
puts "Please enter 2 (x,y) coordinates"
puts "The first x-coordinate is..."
x_cord1 = gets.to_f
puts "Now enter first y-coordinate..."
y_cord1 = gets.to_f
puts "Now enter the second x-coordinate..."
x_cord2 = gets.to_f
puts "Now enter the second y-coordinate.... | true |
88826640c408bf6c24f305339cc43efe3ff68782 | Ruby | jashimgit/ruby_practice | /basics/string.rb | UTF-8 | 1,614 | 4.53125 | 5 | [] | no_license | # All string method
a = "A quick brown fox jumps over the lazy dog"
# get string length
p a.length # returns the length of the string
p a.size # returns length of the string
#how to check if a string is empty?
"".size == 0
b = ""
p b.empty?
# string Interpolation
name = "Jhon"
age = 49
puts "Hello, #{name}, I t... | true |
03da00e8008686422f2bec882e1427c68b15d23a | Ruby | fahadqazi/monos | /lib/monos/creature.rb | UTF-8 | 4,770 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | module Monos
class Creature
attr_accessor :x, :y, :actual_x, :actual_y, :level, :state, :can_move
ANIMATION_DURATION = 100
def sprite_frames
row = 0
frames = { :dead => [[9, 9]], :standing => [[row, 3]], :up => [[row, 3]], :right => [[row, 3]], :left => [[row, 3]], :down => [[row, 3]... | true |
2e4df53c3b8e5e32911a3be81520cf45ad85bfbf | Ruby | JeanPierreGrau/promo-2-challenges | /01-Ruby/02-Arrays-Enumerable/02-Sorting-the-wagon/lib/wagon_sort.rb | UTF-8 | 138 | 2.75 | 3 | [] | no_license | def wagon_sort(students)
students.sort_by { |student| student.downcase } # TODO: return a copy of students, sorted alphabetically
end
| true |
b688526b8d940111684bf0e2288604873e1b1bec | Ruby | noptran/bendrocorp-api | /config/initializers/rack_attack.rb | UTF-8 | 946 | 2.546875 | 3 | [] | no_license | Rack::Attack.throttle("requests by ip", limit: 10, period: 2) do |request|
request.ip
end
# Throttle login attempts for a given email parameter to 6 reqs/minute
# Return the *normalized* email as a discriminator on POST /login requests
# Rack::Attack.throttle('limit logins per email', limit: 6, period: 60) do |req|
... | true |
0604a3e574aec616e99e7d08d0e78d16b03ba8fe | Ruby | ArpanMaheshwari144/Complete-Ruby-Programming | /tut3.rb | UTF-8 | 664 | 4.4375 | 4 | [] | no_license | # puts "Enter your age"
# age=gets.to_i # for storing integer value
# puts age
# puts "Enter the area"
# area=gets.to_f
# puts area
# puts "Enter a number"
# number=gets.to_i
# puts number * 5
# puts "Enter 1st number"
# number1=gets.to_i
#
# puts "Enter 2nd number"
# number2=gets.to_i
#
# print "The sum of two nu... | true |
abf64c52124b3b8322c8556306a4d9be244fd306 | Ruby | ParrotFx/Parrot.Ruby | /Parser/stream.rb | UTF-8 | 684 | 3.828125 | 4 | [
"MIT"
] | permissive | class Stream
def initialize(source)
@list = source
@index = -1
@count = source.length
end
def peek
temp = @index + 1
while temp < @count do
if @list[temp].type != TokenType::Whitespace
return @list[temp]
end
temp += 1
end
return nil
end
... | true |
aec01cbc0b4e2371784ffa9933790787b2dd421f | Ruby | jellybob/NeosShop | /app/models/order_item.rb | UTF-8 | 1,151 | 2.578125 | 3 | [] | no_license | # == Schema Information
#
# Table name: order_items
#
# id :integer not null, primary key
# item_id :integer
# order_id :integer
# user_id :integer
# quantity :integer
# total_price :decimal(12, 2)
# created_at :datetime not null
# updated_at :datetime not null
... | true |
ef65472caff4ab058f9aec5b9e4b741e8c5b9f7a | Ruby | Mvrkwr23/fizzb | /app.rb | UTF-8 | 532 | 3.84375 | 4 | [] | no_license | # numbers = []
counter = 0
puts 'Enter the number to be a mod.'
a = gets.chomp.to_i
puts 'Enter a second number to be a mod'
b = gets.chomp.to_i
puts 'Enter a third number to be a mod'
c = gets.chomp.to_i
puts 'Enter a word to put'
d = gets.chomp.to_i
puts 'Enter a word to put'
e = gets.chomp.to_i
puts 'Enter a word to... | true |
11f3ed623997b10ecd8f34e8161e441d1f34c867 | Ruby | nahmisa/ScrabbleSinatra | /lib/scrabble_score.rb | UTF-8 | 737 | 3.234375 | 3 | [] | no_license | class Scrabble
LETTER_SCORES = {"a"=>1, "b"=>3, "c"=>3, "d"=>2, "e"=>1, "f"=>4, "g"=>2,
"h"=>4, "i"=>1, "j"=>8, "k"=>5, "l"=>1, "m"=>3, "n"=>1, "o"=>1, "p"=>3,
"q"=>10, "r"=>1, "s"=>1, "t"=>1, "u"=>1, "v"=>4, "w"=>4, "x"=>8, "y"=>4,
"z"=>10}
MAXIMUM_NUMBER_OF_LETTERS = 7
def initialize(options = {})
... | true |
15d4f23cfce7635246d786246b53a74f9aab4dcf | Ruby | Cooky90/LaunchSchool | /ProgrammingFoundations-101/Lesson_3/PracticeProblems-Easy1/Easy_6.rb | UTF-8 | 327 | 3.484375 | 3 | [] | no_license | # show two different ways to put the expected "Four score and " in front of it.
famous_words = "seven years ago..."
#famous_words.insert(0, "Four score and") # method 1
famous_words.prepend("Four score and ") # method 2
# examples suggested using --
## ""Four score and " << famous_words
## "Four score and" + famous... | true |
fd3ffad9c9f2fea1ed6132b31e2d9a0f0a73a8f9 | Ruby | epuber-io/bade | /lib/bade/runtime.rb | UTF-8 | 3,577 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Bade
module Runtime
Location = Struct.new(:path, :lineno, :label, keyword_init: true) do
def template?
path == TEMPLATE_FILE_NAME || path&.include?('.bade')
end
def to_s
"#{path || TEMPLATE_FILE_NAME}:#{lineno}:in `#{label}'"
end
e... | true |
0c23414b96182e3adecb244df1b174a146f92d6e | Ruby | aguscipo/sample_app | /app/helpers/sessions_helper.rb | UTF-8 | 1,074 | 2.59375 | 3 | [] | no_license | module SessionsHelper
def sign_in(user)
remember_token = User.new_remember_token #Crear token
cookies.permanent[:remember_token] = remember_token # Ubicar token en las cookies del browser
user.update_attribute(:remember_token, User.digest(remember_token)) #guardar token (hasheado) en la base de datos
... | true |
ee56ec66cdde53e24b4146b9f88f8cd22401f9b8 | Ruby | PriceHardman/ProjectEuler | /001_multiples_of_3_and_5/problem_1.rb | UTF-8 | 282 | 3.78125 | 4 | [] | no_license | # Problem 1:
# If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
puts (1..999).to_a.select{|i| i%3==0 and i%5==0}.reduce(:+) # => 33165 | true |
41e2189bc233dd79d7bbdc91245d5b8d9acca056 | Ruby | liambarstad/Enigma | /lib/reading.rb | UTF-8 | 1,462 | 3.546875 | 4 | [] | no_license | module Reading
def get_file_string(filename)
File.read(filename)
end
def string_to_4_arrays(strang)
result_array = [[],[],[],[]]
char_count = 0
strang.each_char do |char|
result_array[char_count % 4] << char
char_count += 1
end
result_array
end
# seperates a string into... | true |
2938f4d1a79b8a1243d66d1c95a06c3a7774464f | Ruby | FionaDong/Design_Pattern_Ruby | /composite/fill_pan.rb | UTF-8 | 161 | 2.59375 | 3 | [] | no_license | #fill pan is leaf
require_relative 'task'
class FillPan < Task
def initialize
super("Fill in the pan.")
end
def get_time_required
3.0
end
end | true |
4edbf5f9826b78cacd7051a988e8b61043accead | Ruby | aribray/stacks-queues | /lib/queue.rb | UTF-8 | 909 | 3.78125 | 4 | [] | no_license | require 'pry'
class Queue
def initialize
@limit = 4 # item limit for queue
@size = @limit + 1 # size of the internal array
@internal_array = Array.new(@size)
@front = 0
@back = 0
end
def enqueue(element)
return "Stack is full" if @front == (@back + 1) % @internal_array.length
@inte... | true |
9d11b61e50f456bba9555a0a2421672b929c370f | Ruby | pedrocarrico/rabbithole | /script/subscriber.rb | UTF-8 | 700 | 2.640625 | 3 | [] | no_license | require 'rubygems' if RUBY_VERSION < "1.9"
require 'bunny'
class Subscriber
def self.subscribe
bunny = Bunny.new
bunny.start
exchange = bunny.exchange "rabbithole"
queue = bunny.queue "rabbithole.messages" , :durable => true
queue.bind exchange, :key => "message"
Rails.logger.info 'Subscrib... | true |
8598d51c5acf3a9eee6e09ffbc730315f22beeff | Ruby | karimmtarek/rbnd-udacitask-part2 | /lib/listable.rb | UTF-8 | 615 | 2.78125 | 3 | [] | no_license | module Listable
PRIORITY_VALUES = %(low medium high)
def format_date(start_or_due_date: nil, end_date: nil)
dates = start_or_due_date.strftime("%D") if start_or_due_date
dates << " -- " + end_date.strftime("%D") if end_date
dates || no_date
end
def no_date
return "No due date" if self.type == ... | true |
afbcf5d9d8225dd6b067904b2d9a2749fc274c3a | Ruby | pdgonzalez872/atp_data | /lib/main.rb | UTF-8 | 2,723 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'atp_data_gatherer'
require_relative 'ranking_fetcher_utils'
require 'thread'
require 'rubygems'
#require 'pry'
class Manager
def self.gather_data_from_urls(urls:, pool_size:)
# vars
jobs_mutex = Mutex.new
result_mutex = Mutex.new
all_data = []
workers =... | true |
e42292c19a0a2cd59eef599803b0beda29a8065a | Ruby | splybon/advent-of-code | /2018/solutions/day-7/solution_part_1.rb | UTF-8 | 1,431 | 3.53125 | 4 | [] | no_license | require_relative('../../utils/data_reader.rb')
class SleighKit
include DataReader
def initialize
@input = read_data(File.dirname(__FILE__), 'input.txt')
@nodes = []
@edges = []
@removed_nodes = ''
@solved = false
end
def populate_directed_graph
@input.each do |line|
@nodes += li... | true |
22cde9617dd7de682e8722ee3a5e269da03f7f88 | Ruby | moexmen/sls_adf | /lib/sls_adf/util/adapter.rb | UTF-8 | 3,514 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'typhoeus'
require 'json'
module SlsAdf
module Util
# Custom adapter written for github/graphql-client, built to achieve 2 things:
# 1. Expose HTTP status of response through the #execute method.
# 2. Automatically GETs token from token endpoint if call is unaut... | true |
04c1f21946e4acb91e0963c030ca1407bb012c38 | Ruby | yosiat/git_commits_rewriter | /lib/git_commits_rewriter.rb | UTF-8 | 608 | 2.546875 | 3 | [] | no_license | module GitCommitsRewriter
def self.rewrite repository, provider_config
# Get the filter script
script = File.join(File.dirname(__FILE__), "commits_fixer.rb")
# The command will run filter-branch with env-filter because we want
# to update the commits data by exporting the enviroments.
#
# I... | true |
ed37135ee8f3739ea1e2440584a9c16b98c55bc9 | Ruby | toasterbob/review | /challenges/ruby/hackerrank/implementation/happy_ladybugs.rb | UTF-8 | 828 | 3.21875 | 3 | [] | no_license | #!/bin/ruby
def happy(b)
happy = ""
b.split("").uniq.each { |el| happy += (el * b.count(el)) if b.count(el) > 1 }
return "YES" if b.count("_") == 0 && happy == b
b.split("").uniq.each do |el|
next if el == "_"
return "NO" unless b.count(el) > 1 && b.count("_") >= 1
end
"YES"
e... | true |
5807df6e1720cc8c6a16cae71c205ebe272ef9be | Ruby | SThiara/jungle-app | /spec/models/user_spec.rb | UTF-8 | 3,005 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
it 'will succeed if all parameters are provided' do
@user = User.new(first_name: "Test", last_name: "User", email: "test@user.com", password: "testPassword", password_confirmation: "testPassword")
expect(@user).to ... | true |
66ed2a1beddfab823b60331029a30a9c2da6d934 | Ruby | chriseichler/Cookbook | /db/seeds.rb | UTF-8 | 2,277 | 2.765625 | 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 |
2cb3f0ef3c85b18de7d871f5855357b60e6a4ddb | Ruby | nonnax/arraycsv | /arraycsv.rb | UTF-8 | 1,090 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
# Id$ nonnax 2021-09-10 17:39:07 +0800
# csv pseudo-array
require 'csv'
require 'forwardable'
class ArrayCSV
extend Forwardable
attr_accessor :dataframe
def_delegators :@dataframe, :[], :values_at, :size, :first, :last, :empty?, :map, :each, :sort_by
def initialize(fname)
@fname=fn... | true |
51d45b7be14490cb8793f03b3f52c9af7e12b61c | Ruby | bsingr/opal | /src/browser/lib/browser/dimensions.rb | UTF-8 | 1,575 | 2.65625 | 3 | [
"MIT"
] | permissive | #
# dimensions.rb
# vienna
#
# Created by Adam Beynon.
# Copyright 2010 Adam Beynon.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the ... | true |
49d647b3d19946bf6fe16f4745414feb3289c628 | Ruby | apache/whimsy | /www/secretary/workbench/views/check-signature.js.rb | UTF-8 | 1,721 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #
# Check signatures for validity using gpg on the server
#
class CheckSignature < Vue
def initialize
@signature = nil
@checked = nil
end
def render
if @signature
_div.alert @alert, class: @flag
end
end
def mounted()
@signature = CheckSignature.find(decodeURIComponent(@@selected),... | true |
2d15e5652e49650cf4a0da56668c3a9ea4457aa1 | Ruby | oggy/looksee | /spec/looksee/adapter_spec.rb | UTF-8 | 9,880 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'spec_helper'
describe "Looksee.adapter" do
include TemporaryClasses
before do
@adapter = NATIVE_ADAPTER
end
describe "#lookup_modules" do
#
# Filter out modules which are hard to test against, and returns
# the list of module names. #inspect strings are used for names
# of singl... | true |
4766922bf18bdd0fd38196b969a7a545cfc38426 | Ruby | Zvorykin/custom_mardown_parser | /app/services/parsers/underscore.rb | UTF-8 | 195 | 2.640625 | 3 | [] | no_license | module Parsers
module Underscore
REGEXP_TO_MATCH = /__(?<text>.*)__/.freeze
def self.html(match)
"<p style=\"text-decoration: underline;\">#{match[:text]}</p>"
end
end
end
| true |
c9203108f5f009aafa0a08fb1b769b4e5d4f3cf8 | Ruby | cfis/pgdiff | /bin/pgdiff | UTF-8 | 2,207 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/bin/env ruby
# This is a simple approach to track database schema changes in PostgreSQL.
# In some way it is similar to diff program, finding out structure changes
# and results in SQL script to upgrade to new schema.
#
# Differences are tracked on schemas, domains, sequences, views, tables, indices, constraints,... | true |
702c6e212b6db7d40847560adf5a718834bbc762 | Ruby | Jackwhitener/Coinchanger | /coinchangertest.rb | UTF-8 | 1,127 | 2.859375 | 3 | [] | no_license | require "minitest/autorun"
require_relative "coinchanger.rb"
class My_test < Minitest::Test
def test1
assert_equal(1,1)
end
def test_penny
change = 1
assert_equal({"Pennies" => 1}, coinage(change))
end
def test_penny_two
change = 2
assert_equal({"Pennies" => 2}, coinage(change))
end
def test_nickel
c... | true |
9360d04758e64f8ef10f080b9e67db786cb79c3c | Ruby | balalnaeem/launch-school-101-lessons | /eda_bit/eda_bit.rb | UTF-8 | 504 | 3.25 | 3 | [] | no_license | =begin
def xo str
lowercase_str = str.downcase
return true if lowercase_str.count('xo') == 0
lowercase_str.count('x') == str.count('o')
end
p xo("ooxx") == true
p xo("xooxx") == false
p xo("ooxXm") == true
p xo("zpzpzpp") == true
p xo("zzoo") == false
def seven_ate_9(str)
str.gsub('797', '77').gsub('7 97', '7... | true |
51dea1f75375aa71aaa8c114dd7f3dacd3f4c239 | Ruby | p0deje/watir-timecop | /lib/watir-timecop/timer.rb | UTF-8 | 753 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Watir
module Timecop
class Timer
#
# Executes given block until it returns true or exceeds timeout.
# It is different from default Watir::Wait::Timer implementation
# since it does not use `Time.now` to determine if
# waiting has exceeded timeout. Usage of `Time.now` is not c... | true |
10c9467d65d2bc3f85e0c18c571a2ee6a80f3f18 | Ruby | ql/sypex_geo | /spec/lib/pack_spec.rb | UTF-8 | 1,923 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'sypex_geo'
describe SypexGeo::Pack do
describe '#parse' do
it 'reads int8' do
expect(SypexGeo::Pack.new('t:value').parse("\xff")[:value]).to eq(-1)
end
it 'reads uint8' do
expect(SypexGeo::Pack.new('T:value').parse("\xff")[:value]).to eq(255)
end
it 'r... | true |
9bc2d104039a483990d4ba7ddb26ef016cc689d1 | Ruby | hkulekci/treehouse-ruby-notes | /07-Methods/visibility.rb | UTF-8 | 663 | 3.21875 | 3 | [] | no_license | # Visibility
load './bank_account.v.4.rb'
bank_account = BankAccount.new("Haydar", "KULEKCI")
bank_account.deposit(400)
puts bank_account.inspect
# bank_account.reset! # catch an error
bank_account.call_the_reset
puts bank_account.inspect
# Private and Protected example
account1 = BankAccount.new("haydar", "Kulekc... | true |
a0d52e71492d74c087f8536d09a6048e28e89bf3 | Ruby | charliecorrigan/battleship | /lib/display_board.rb | UTF-8 | 1,508 | 3.265625 | 3 | [] | no_license | class DisplayBoard
attr_accessor :current_board
def initialize(working_gameboard)
working_gameboard_size = working_gameboard.length
@current_board = []
generate_blank_display_board(working_gameboard_size)
end
def generate_blank_display_board(working_gameboard_size)
generate_border(working_game... | true |
281cd3b47c3b574ab4c62579d97d9441d7f80269 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/07442822c5d2453c9afaada8c9333507.rb | UTF-8 | 435 | 3.28125 | 3 | [] | no_license | class Hamming
def self.compute(reference, examinee)
if reference.length > examinee.length
run_length = examinee.length
else
run_length = reference.length
end
run_length -= 1
hamming_distance = 0
(0..run_length).each do |string_index|
if examinee[string_index] !=... | true |
31470f6596e7e24b792fe912fc6c9c309e36b4b9 | Ruby | christineoen/planit | /app/models/concerns/sluggable.rb | UTF-8 | 871 | 2.609375 | 3 | [] | no_license | module Sluggable
extend ActiveSupport::Concern
included do |base|
unless defined?(DEFAULT_SLUG_CHARS)
DEFAULT_SLUG_CHARS = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).freeze
DEFAULT_SLUG_SIZE = 20
end
cattr_accessor :slug_chars
cattr_accessor :slug_size
validates :slug, pr... | true |
ad7e30189be6a1c126562f69360f67ae9ec23c91 | Ruby | joshkmcdonald/ruby-coding-exercises | /january/6.rb | UTF-8 | 531 | 3.453125 | 3 | [] | no_license | #done
require 'rspec'
def increment_value str
str + str.next.slice(-1)
end
describe 'Increment string value sequence' do
it 'appends the next item in the sequence of a string' do
expect(increment_value 'abcde').to eq('abcdef')
expect(increment_value '123').to eq('1234')
end
end
# def increment_value st... | true |
3946d36ceb09915c56899281613fc97cca856db1 | Ruby | evafriana/THP-Projects | /20200414_ASCII_Ruby/lib/caesar_cipher.rb | UTF-8 | 728 | 4.28125 | 4 | [] | no_license | def caesar_cipher(string, integer)
a = string.split
a.map { |w| caesar_word(w, integer) }.join(' ')
end
def caesar_word(string, integer)
string.chars.map { |x| check_special(x) ? caesar_letter(x, integer) : x }.join
end
def caesar_letter(string, integer)
if check_end(string, integer)
(string.ord + integer... | true |
c63689254a997b8e037705feb7aac415eff132f7 | Ruby | SarahBunker/rb101_programming_foundations | /small_problems/easy8/reverse_dig_number.rb | UTF-8 | 521 | 4.34375 | 4 | [] | no_license | =begin
in: positive integer
out: same number with digits reversed
rules:
input arguement will not have leading zeros
outputs will not have leading zeros
plot:
convert to string
use reverse
convert to integer
return integer
=end
def reversed_number(integer)
integer.to_s.reverse.to_i
end
p reversed_number(12345... | true |
0b66d128eab10657cfdc80d1ec53ca5c84a535d0 | Ruby | gwen-marina/seattle_grace_ic | /lib/hospital.rb | UTF-8 | 365 | 2.90625 | 3 | [] | no_license | require './lib/doctor'
class Hospital
attr_reader :name, :cheif_surgery, :doctors
def initialize(name, cheif_surgery, doctors)
@name = name
@cheif_surgery = cheif_surgery
@doctors = doctors
end
def total_salary
doctors.sum { |doctor| doctor.salary }
end
def lowest_paid_doctor
doctor... | true |
483c62fec65b4c1415d5251a6965e6498af88b14 | Ruby | myokoym/oxlinegame | /lib/oxlinegame/scene/main.rb | UTF-8 | 2,189 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "oxlinegame/scene"
require "oxlinegame/object"
require "oxlinegame/player"
module Oxlinegame
module Scene
class Main
include Base
def initialize(window, players=nil)
players ||= [Player::MAN, Player::COM]
super(window)
@n_rows = @window.options[:n_rows] || 3
@... | true |
f5390baae251e0a7786f83106fad06902b5c6cb2 | Ruby | fenotesb/Basic-Ruby | /The_Right_Crew.rb | UTF-8 | 919 | 3.0625 | 3 | [] | no_license | Required_crew_size = 6
#Used symbols and an array to represent the members of the crew
avaiable_members = [
:captain,
:first_mate,
:second_mate,
:navigator,
:first_engineer,
:info_systems_tech,
:environmental_control_tech,
:lead_maintenance,
:first_medical,
:first_food_ops,
:combat_systems_officer... | true |
b6197b53517d497ab27a95faa74f7f59abe88988 | Ruby | cassar/skrol_basic | /lib/catalogues/records.rb | UTF-8 | 2,999 | 2.890625 | 3 | [] | no_license | # { record_id => record }
def derive_record_id_to_record(records)
record_id_to_record = {}
records.each { |record| record_id_to_record[record.id] = record }
record_id_to_record
end
# { record => [ assoc, ...] }
def derive_record_to_assocs(records, assocs)
record_id_to_record = derive_record_id_to_record(record... | true |
e1ceb6754ecd03d197eadeae6d7c1c3a6fff6e85 | Ruby | brad1/development-setup | /files/bin/prototypes/sandbox/sql/builder.rb | UTF-8 | 1,604 | 3.21875 | 3 | [] | no_license | require 'sqlite3'
def database_create(name)
db = nil
begin
`rm #{name}`
`echo ".tables\n.exit\n" | sqlite3 #{name}`
db = SQLite3::Database.new name
rescue SQLite3::Exception => e
raise e
end
return db
end
def query(db,search_string)
puts " --------- #{search_string} ------------ "
stm = ... | true |
2fbab14690ea83653fcd70a1d0f6de6816415d00 | Ruby | riddochc/assert | /lib/assert/default_suite.rb | UTF-8 | 1,313 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'assert/suite'
module Assert
# This is the default suite used by assert. It stores test/result data in-memory.
class DefaultSuite < Assert::Suite
# Test data
def ordered_tests
self.tests
end
def reversed_tests
self.tests.reverse
end
def ordered_tests_by_run_time
... | true |
4287c8dc5c646c2d9138c6cecc7d68e26535b548 | Ruby | jlusche/go_free | /app/queries/google_places_query.rb | UTF-8 | 774 | 2.734375 | 3 | [] | no_license | class GooglePlacesQuery
#attr_accessor :museums
def initialize(query, lat, long, radius)
@query = query
@lat = lat
@long = long
@radius = radius
end
def place_id
museums_google = HTTParty.get("https://maps.googleapis.com/maps/api/place/textsearch/json?query=#{@query}&location=#{@lat},#{... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.