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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
af49eadc9a7701507261838d1e30af72b9389098 | Ruby | mitsu9/study_programming | /src/ALDS1/bubble_sort.rb | UTF-8 | 516 | 4.25 | 4 | [] | no_license | # バブルソート
def bubble_sort(ary, len)
swp = 0
len = len - 1
(0...len).each { |n|
(0...len-n).each { |j|
if ary[j] > ary[j+1]
ary[j], ary[j+1] = ary[j+1], ary[j] # swapの書き方
swp += 1
end
}
}
return ary, swp
end
# main
len = gets.to_i
ary = gets.split(' ').map(&:to_i) # 半角スペース区切... | true |
28d196b096a315f0acbe4c39d6cf0a9aea0c5647 | Ruby | eminnett/sample-shopping-cart | /lib/shopping_cart.rb | UTF-8 | 1,642 | 3.265625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'validations'
require_relative 'basket'
require_relative 'catalogue'
require_relative 'delivery_cost_schedule'
require_relative 'offer'
# The core shopping cart entity that has a catalogue, set of delivery charges, available offers.
# Products can be added and put in a b... | true |
05cd8600f5f94e876ad4cf6b84bb121dc65f3649 | Ruby | victorvitalino/platform | /components/brb/app/models/brb/barcode.rb | UTF-8 | 3,579 | 2.640625 | 3 | [
"MIT"
] | permissive | module Brb
class Barcode
include ActiveModel::Model
# capitulo 1 - composição da chave
#váriveis bancárias
attr_accessor :bank, :bank_agency, :bank_account, :bank_wallet
#variaveis de execução
attr_accessor :sequential, :due, :value
#variaveis de calculo
attr_accessor :key_dig... | true |
eda9cd5788e972f9bc5012f2d32dbd858058f646 | Ruby | DarkBones/Stishly | /test/system/users_test.rb | UTF-8 | 3,787 | 2.546875 | 3 | [] | no_license | require 'application_system_test_case'
class UsersTest < ApplicationSystemTestCase
test 'visit the index' do
"""
Go the the root path
Expected result:
- See welcome screen
- See link to sign up
- See link to sign in
"""
visit root_path
assert_selector 'h1', text: "Sign Up"
assert_selector '.nav... | true |
25f36e6d446f9580fc7d38a073981e7b2a956f85 | Ruby | barunecka/advent_of_code_2018 | /day_2/calculate_checksum_for_box_ids.rb | UTF-8 | 764 | 3.453125 | 3 | [] | no_license | class CalculateChecksumForBoxIds
def initialize(list_of_ids)
@list_of_ids = list_of_ids
@two_letter_id_boxes = Array.new
@three_letter_id_boxes = Array.new
end
def call
sort_boxes_by_id
print_checksum(calculate_checksum)
end
private
attr_accessor :list_of_ids, :two_letter_id_boxes, :... | true |
375081cce6d277d63b7f840a3b78d2bce9985295 | Ruby | matus-tomlein/ics_parser | /lib/event_parser.rb | UTF-8 | 3,273 | 3.296875 | 3 | [] | no_license | require 'ostruct'
require 'time'
class EventParser
def initialize(calendar_content)
@calendar_content = calendar_content
end
def events
events = []
get_events_in_calendar.each do |event|
summary = parse_summary event
starts_at = parse_starts_at event
ends_at = parse_ends_at event
... | true |
02502a33412f5db6d544b1503afa1c04eedeaada | Ruby | deniseyu/FAAST-challenge | /spec/passenger_spec.rb | UTF-8 | 818 | 2.890625 | 3 | [] | no_license | require './lib/spec_helper'
require './lib/passenger'
require './lib/station'
describe Passenger do
let(:passenger) { Passenger.new }
let(:station) { double :station }
it "should have balance in his wallet" do
expect(passenger.wallet_balance).to_not eq 0
end
it "should be able to pay for a trip when tappin... | true |
0519166eb6b8526fa0cfc6349bcff08fbf980dd0 | Ruby | afshinator/playground | /Ruby-BuildingBlocks/building_blocks_spec.rb | UTF-8 | 2,474 | 3.6875 | 4 | [] | no_license | # # Odin Project - Ruby >> Basic Ruby >> Project: Building Blocks & Advanced Building Blocks
#
# http://www.theodinproject.com/curriculum/ruby/basic_ruby/project_building_blocks.md
#
# Afshin Mokhtari
#
require "building_blocks"
describe "==>Building Blocks Warmup: Word Counter" do
describe "#Given example" do
it... | true |
0c8e4f71ce97fe1ac77b72cec50f2d2034c60df3 | Ruby | Jakintero/sinatra-intro | /challenges/1-CRUD/sinatra-mvc-skeleton/app/controllers/notes_controller.rb | UTF-8 | 851 | 2.671875 | 3 | [] | no_license |
#Index
get '/' do
@notes = Note.all
erb :index
end
#New
get '/notes/new' do
erb :new
end
#Show
get '/notes/:id' do
@note = Note.find_by(id: params[:id])
erb :show
end
#Create
post '/notes' do
@note = Note.new(name: params[:name], description: params[:description], quantity: params[:quantity])
... | true |
dec4620ec570b2a219f0fe9c0938dd6d6870545b | Ruby | viditn91/vinsol-training | /Ruby_exercise/Interest_Difference/main/main.rb | UTF-8 | 275 | 3.109375 | 3 | [] | no_license | require_relative '../lib/interest.rb'
puts "enter principal_"
principal = gets.chomp
puts "enter time period_"
time = gets.chomp
interests = Interest.new { [principal.to_i, time.to_i ] }
p "The difference between Simple and Compound Interest is #{ interests.get_difference }" | true |
1af5ba0fbcb02f7a5a49367459a6e39b4a60744c | Ruby | anamsoomro/my-collect-houston-web-012720 | /lib/my_collect.rb | UTF-8 | 501 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def my_collect(array)
#collect modifies the given array
i = 0
result = []
while i < array.length do
# yield (array[i])
# result << array[i]
# this is shoveling in the unoperated element
# I need to shovel in the operated element
# whatever I shove... | true |
e0acfc34c2e2c43e267d54acb85d7d47ffbe2278 | Ruby | AndersonNguyen1/CodeEval | /armstrong_numbers.rb | UTF-8 | 224 | 3.28125 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
a = line.strip.split ''
sum = 0
a.each do |character|
sum += character.to_i ** a.length
end
if sum.to_s == line.strip
puts 'True'
else
puts 'False'
end
end
| true |
1726052c737ac15215526ac93ad83baac9225b33 | Ruby | tilo/smarter_logging | /lib/smarter_logging/anomaly_logger.rb | UTF-8 | 390 | 2.65625 | 3 | [
"MIT"
] | permissive | module SmarterLogging
class AnomalyLogger < BaseLogger
def log(unique_identifier, data, &block)
data = {:anomaly => unique_identifier}.merge( data )
_log_wrapper(data, &block)
end
def _log(data)
# If activity logging broke, make sure we log it as an anomaly:
data[:anomaly] = dat... | true |
967696a4908534b7d82a9487d9e513a2c90b6be4 | Ruby | voke/payson_api | /lib/payson_api/shipping_address.rb | UTF-8 | 1,146 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'cgi'
module PaysonAPI
class ShippingAddress
FORMAT_STRING = "shippingAddress.%s"
attr_accessor :name, :street_address, :postal_code, :city, :country
def initialize(name, street_address, postal_code, city, country)
@name = name
@street_address = street_address
@postal_code = postal_code
... | true |
2c9bd2a56bf948e872c59270638c996efeafdf5e | Ruby | oumiya/click_rpg | /scripts/Scene_Box.rb | UTF-8 | 8,675 | 2.84375 | 3 | [] | no_license | require_relative 'Scene_Base.rb'
require_relative 'Scene_Home.rb'
require_relative 'Message_Box.rb'
require_relative 'Wave_Result.rb'
require_relative 'Paper_Snow.rb'
# 戦闘結果シーンクラス
class Scene_Box < Scene_Base
def initialize(result)
@result = result
# 背景画像読み込み
@background = nil
case $dungeon_id
w... | true |
ddd20e6dfb1f086b8324b5d3d35cd99d059cd20d | Ruby | ericzhonghou/fa15-hw2 | /app/controllers/pages_controller.rb | UTF-8 | 575 | 2.796875 | 3 | [] | no_license | class PagesController < ApplicationController
def home
foo = Foobar.new "baz"
@baz = foo.bar :cat, sat: :dat, dat: :sat
end
def stringify
@text = "You are nothing!"
name = params[:name]
adj = params[:adjective]
@string = @text
if !(name.empty? or adj.empty?)
@string = "#{name} i... | true |
c50e06d3a22b96ae2f3a88b427f7ee772116b099 | Ruby | timtan93/week-1-group-review-london-web-121018 | /review-question-3.rb | UTF-8 | 1,097 | 3.46875 | 3 | [] | no_license | # begin to build a simple program that models Instagram
# you should have a User class, a Photo class and a comment class
class User
attr_accessor :name, :photos
def initialize(name)
@name = name
@photos = []
end
def photos
@photos
end
end
class Photo
attr_accessor :user
... | true |
c47b8da8556ae351b748385c9c1235af6f1a5039 | Ruby | joshnevius/orlando-tech-meetups-cli-gem | /lib/orlando_tech_meetups/cli.rb | UTF-8 | 1,073 | 3.25 | 3 | [
"MIT"
] | permissive | class OrlandoTechMeetups::CLI
def call
list_meetups
menu
end
def menu
input = nil
while input != "exit"
input = gets.strip.downcase
if input.to_i > 0
the_group = @meetups[input.to_i-1]
puts "#{the_group.name}"
puts "The next meetup is: #{the_group.next_meetup... | true |
383e96340ac802d53e563272cadbcca22f49cc9e | Ruby | johnkchow/cached_record | /lib/cached_record/store/block_collection.rb | UTF-8 | 7,921 | 2.640625 | 3 | [
"MIT"
] | permissive | class CachedRecord
class Store
class BlockCollection
include Util::Assertion
attr_reader :header, :store_adapter, :order, :block_size, :data_fetcher
def initialize(header_key,
store_adapter:,
data_fetcher:,
order:,
... | true |
0cb1fc601b5eb52ba9c334afa219a40072266b50 | Ruby | thisirs/event_scraper | /lib/event_scraper/scrapers/tvrage/tvrage.rb | UTF-8 | 5,481 | 2.546875 | 3 | [] | no_license | module EventScraper
class TVRageOrgFormatter
conf "TVRage/OrgFormatter"
def format(events)
body = events.map do |e|
time_format = (e.option("time_format") ||
option("time_format") ||
"%Y-%m-%d %H:%M")
template = (e.option("org_template") |... | true |
d585db6eb1f87043a5152609775af61c881bfc32 | Ruby | shaneoston72/bank_tech_test | /lib/account.rb | UTF-8 | 874 | 3.265625 | 3 | [] | no_license | class Account
attr_reader :statement
def initialize(transaction_klass: Transaction, statement_klass: Statement)
@balance = 0
@account_history = []
@transaction = transaction_klass
@statement = statement_klass
end
def transaction(type: type, amount: amount)
complete... | true |
ae418f09f61e776f62ec001daf1b343963fd2db0 | Ruby | udaltsova-nastya/ruby | /lesson3/rail_road_interface.rb | UTF-8 | 10,756 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
# Интерфейс для управления железной дорогой
class RailRoadInterface
attr_reader :rail_road
def initialize(rail_road)
@rail_road = rail_road
end
def run
loop do
action = main_menu_action
break if action.zero?
main_menu_process(action)
end
end
p... | true |
fd169b7519a192c7ed55584144dc61142b86e132 | Ruby | Iaox/IaoxRubyWebServer | /models/rs/clientHandler.rb | UTF-8 | 597 | 2.796875 | 3 | [] | no_license | class ClientHandler
@clients
@active_rs_accounts
def initialize
@clients = Array.new
@active_rs_accounts = Array.new
end
def add(client)
@clients.push(client)
end
def remove(client)
if @clients.include?(client)
if !client.get_rs_account.nil?
client.get_rs_account.update(:a... | true |
3e2cad1975c631372fbd281a0bef502f0e9e8879 | Ruby | wxq92109/JOB | /第五次任务/《Ruby基础教程》示例程序/case_class.rb | UTF-8 | 252 | 3.75 | 4 | [] | no_license |
class Case_class
array = ["a",1,nil]
array.each do |item|
case item
when String
puts item," is a string"
when Numeric
puts item,"item is a numeric"
else
puts item,"item is something"
end
end
end | true |
ef74ec292ae6f550f02d8bc02d12546fc14aa638 | Ruby | jm96441n/phase-0 | /week-4/add-it-up/my_solution.rb | UTF-8 | 1,405 | 4.15625 | 4 | [
"MIT"
] | permissive | # Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge [with: Ivy Vetor].
# 0. total Pseudocode
# make sure all pseudocode is commented out!
=begin
def total(array)... | true |
3ecb32966a5b166baa98035796443faad1cf476e | Ruby | citygent/W4D2-BikeHire | /spec/bike_spec.rb | UTF-8 | 533 | 2.921875 | 3 | [] | no_license | require_relative './spec_helper.rb'
require_relative '../lib/bike.rb'
#describing functionlity of the specific bike class
describe Bike do
let(:bike) {Bike.new} #instantiate an instance of the Bike Class every test.
it 'should not be broken after we create it' do
expect(bike.broken?).to be false
end
... | true |
37fd1d39ad853410c3547a2e1b60c44aa7a32233 | Ruby | gracexinran/sorting-string-manipulation | /lib/reverse_sentence.rb | UTF-8 | 1,152 | 4.125 | 4 | [] | no_license | # A method to reverse the words in a sentence, in place.
# Time complexity: O(n2)
# Space complexity: O(1)
require 'pry'
def reverse_sentence(my_sentence)
# raise NotImplementedError
return nil if my_sentence.nil?
i = 0
j = my_sentence.length - 1
until i >= j
temp = my_sentence[i]
my_sentence[i] = my_... | true |
807b6333dd60e4eafcbca94a29003136b1651916 | Ruby | therichey/PlusPlus-Analytics | /categorizer_test.rb | UTF-8 | 5,693 | 2.734375 | 3 | [] | no_license | require './categorizer'
require 'minitest/autorun'
class TestCategorizer < MiniTest::Unit::TestCase
def test_single_upc_is_returned
assert_equal 'single-upc', Categorizer.categorize('/search/?q=06250003')
assert_equal 'single-upc', Categorizer.categorize('/search/?q= 07358210')
assert_equal 'single-upc',... | true |
61638404f7ef293118088f88fb03128458337436 | Ruby | nikosd/roodi | /lib/roodi/checks/npath_complexity_check.rb | UTF-8 | 1,629 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'roodi/checks/check'
module Roodi
module Checks
class NpathComplexityCheck < Check
# , :when, :and, :or
MULTIPLYING_NODE_TYPES = [:if, :while, :until, :for, :case]
ADDING_NODE_TYPES = [:rescue]
COMPLEXITY_NODE_TYPES = MULTIPLYING_NODE_TYPES + ADDING_NODE_TYPES
def initializ... | true |
d8558d284a6ffdfb452c672fa23abbd9b46e1b41 | Ruby | didiermarques/tests-ruby | /lib/01_temperature.rb | UTF-8 | 91 | 3.28125 | 3 | [] | no_license | def ftoc(f)
return (f - 32) * 5/9.0
end
def ctof (c)
return (c * 9.0/5) + 32
end | true |
cb734dd55224ba4421e9cfff8b818e8d9539f8ef | Ruby | matthewbillienyc/postgres-lukather | /lukather_csv_writer.rb | UTF-8 | 2,037 | 3.65625 | 4 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'csv'
require 'pry'
years = 1977..2016
class Artist
@@artists = []
def self.all
@@artists
end
def self.find_by_name(name)
all.find { |a| a.name == name }
end
attr_accessor :name
def initialize(name)
Artist.all << self unless Artist.find_by_n... | true |
98cbaa14a3dcf9761ff840a668924c08b017a110 | Ruby | Matevito/Chess | /lib/pieces/knight.rb | UTF-8 | 1,687 | 3.453125 | 3 | [] | no_license | require_relative "../board"
require_relative "../player"
require_relative "../game_methods"
class Knight < Board
include GameMethods
def possible_moves(player, position, board)
color = player.color
possible_moves = []
current_board = board.board
current_position = position.dup.m... | true |
5a915e6bbb01e45f471afa1c2b044c4c9fa403c1 | Ruby | andyw8/codeclimate-engine-rb | /lib/cc_engine/issue.rb | UTF-8 | 1,398 | 2.5625 | 3 | [
"MIT"
] | permissive | require "json"
module CCEngine
class Issue
def initialize(
check_name:,
description:,
categories:,
location:,
remediation_points:,
content:,
fingerprint:
)
@check_name = check_name
@description = description
@categories = categories
@location... | true |
5b07334f7bfe053071856ce6217194136e8d79d1 | Ruby | ept/invoicing_generator | /lib/invoicing_generator/name_tools.rb | UTF-8 | 4,518 | 2.921875 | 3 | [
"MIT"
] | permissive | # Tools for dealing with names of controllers or models, passed to us by the user
# from the command line when invoking the generator. Designed to be included into
# a subclass of Rails::Generator::NamedBase.
#
# This code is inspired by the generator in restful_authentication.
module InvoicingGenerator
module NameTo... | true |
32702cfdce62232e6259f101d5cfeb17c0ceb2a5 | Ruby | WeilerWebServices/Hulu | /vfl2objc/vfl2objc.rb | UTF-8 | 14,373 | 3.3125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
class UIView
# r means right, b means bottom
# xref means reference object for x. e.g. [v1]-10-[v2] makes v2.xref=v1, v2.x=10 if v1's size is unknown
attr_accessor :name, :x, :y, :r, :b, :w, :h, :xref, :yref, :rref, :bref, :added_to_list, :centerx, :centery
def code_for_x
... | true |
c6de6d2a9d115c12ead3f0d9ccfafb076980058e | Ruby | nono/unified-redis | /lib/unified_redis/core.rb | UTF-8 | 298 | 2.65625 | 3 | [
"MIT"
] | permissive | module UnifiedRedis
class Core
def initialize(redis)
@redis = redis
@adapter = Adapter.get_adapter(redis)
end
def method_missing(command, *args, &block)
#return unless @redis.respond_to?(command.to_sym)
@adapter.call(command, *args, &block)
end
end
end
| true |
8865c6d34f2426371503ce5ab0b3c00a00074869 | Ruby | DeveloperAlan/WDI_SYD_7_Work | /w01/d01/alan/hw_w01_d01.rb | UTF-8 | 4,915 | 4.65625 | 5 | [] | no_license | # Building Ruby Familiarity
# In this exercise you will take a first look at some common commands in Ruby
# The idea here is to build familiary with Ruby syntax
# This will likely be the first time you've seen some of these commands
# Just type them in and see the displayed output
# Steps:
# 1. Open up a new termin... | true |
2f336844246bc62582608748eb1f78f23fca26f3 | Ruby | kwatch/rubinius | /spec/ruby/1.8/core/numeric/div_spec.rb | UTF-8 | 1,173 | 3.03125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../../spec_helper'
# FIXME: this awful wording
describe "Numeric#div" do
it "div right integers" do
13.div(4).should == 3
4.div(13).should == 0
end
it "div right integers and floats" do
13.div(4.0).should == 3
4.div(13).should == 0
end
it "div ri... | true |
081d0b0ca105555d2ba57e52b4de68d637774d24 | Ruby | lroberts77/GildedRose-Refactoring-Kata | /lib/gilded_rose.rb | UTF-8 | 3,084 | 3.375 | 3 | [
"MIT"
] | permissive | require_relative 'item'
class GildedRose
MAXIMUMQUALITY = 50
MINIMUMQUALITY = 0
MINIMUMSELLIN = 0
def initialize(items)
@items = items
end
def update_quality()
@items.each do |item|
#Generic item
if generic_item(item)
item.sell_in <= MINIMUMSELLIN ? item.qual... | true |
72acbcf194c0ecd01b1dc5e992dd54e5996347ca | Ruby | breakliu/MatrixCalc | /matrix_calc.rb | UTF-8 | 2,366 | 3.765625 | 4 | [] | no_license | class MatrixCalc
attr_reader :foot_print
def initialize(array)
@array = array
end
def calc
if matrix?
result = 0
@row = 0
@col = 0
@foot_print = []
init_steps
# 超始方向是1(右:1, 下:2, 左:3, 上:4)
@direction = 1
begin
mark_step
result += @array[... | true |
b8eebd72d4393eeb9aae53992b3ab33d558070db | Ruby | kuraga/survey_rgnf | /populations/by_question_and_population_mapper_processor.rb | UTF-8 | 938 | 2.984375 | 3 | [] | no_license | require_relative '../lib/processors/by_question_and_group_mapper_processor'
module Populations
class ByQuestionAndPopulationMapperProcessor < ByQuestionAndGroupMapperProcessor
def initialize(data, population_question_name, populations = DEFAULT_POPULATIONS)
super data, population_question_name
@pop... | true |
dd01cd3c6c0d3dde3b11e1a929a36c837267f99e | Ruby | craighdunn/skillcrush-ruby-challenges | /pareent_classes.rb | UTF-8 | 782 | 3.796875 | 4 | [] | no_license | #I am not a gun nut. I thought really hard about an example to use. This was the best I could come up with for a group of things that had enough in common and different to be good practice.
class Weapon
attr_writer :name, :material
attr_reader :name, :material
end
class Pistol < Weapon
attr_accessor :ammo, :ra... | true |
cf44b4738d345acd925eae4116499e8ecff4897b | Ruby | lishulongVI/leetcode | /ruby/685.Redundant Connection II(冗余连接 II).rb | UTF-8 | 4,955 | 3.6875 | 4 | [
"MIT"
] | permissive | =begin
<p>
In this problem, a rooted tree is a <b>directed</b> graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents.
</p><p>
The given input is a directed graph that started as ... | true |
511f6b496f8a3a70b8844eede04abcd5cd26000e | Ruby | postazure/Ruby-Practice | /CH8/ArrayNames.rb | UTF-8 | 197 | 3.5625 | 4 | [] | no_license | names = ["Ada", "Belle","Chris"]
puts names
puts
puts names[0]
puts names[1]
puts names[2]
puts names[3] # this is out of range
#this does not produce and error,
# in ruby its actually empty (nil) | true |
3cdd72b9b23e931e522444a024a46ccac353d485 | Ruby | lgreenberg23/ruby-collaborating-objects-lab-web-062617 | /lib/song.rb | UTF-8 | 823 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # The Song class will be responsible for creating songs given
# each filename and sending the artist's name (a string) to the Artist class
require 'pry'
class Song
attr_accessor :name, :artist
# attr_reader :artist
#@@song_array = []
def initialize(name)
@name = name
end
# def self.artist=(artist)
# se... | true |
8f0d11b6b6acbbc9430d72adf292932631e81da3 | Ruby | danliu277/project-euler-sum-square-difference-nyc-web-120919 | /lib/oo_sum_square_difference.rb | UTF-8 | 491 | 3.6875 | 4 | [] | no_license | # Implement your object-oriented solution here!
class SumSquareDifference
attr_accessor :difference
def initialize(input)
@difference = self.square_sum(input) - self.sum_square(input)
end
def sum_square(input)
sum = 0
(1..input).each do |x|
sum += (x * x)
end... | true |
e0e03be48d7b9a4b3180b29be40fe74ad756f8fd | Ruby | ftomassetti/codemodels-javaparserwrapper | /test/test_parser.rb | UTF-8 | 3,031 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require 'helper'
$CLASSPATH << 'test/dummyjavaparser/classes'
java_import 'it.codemodels.javaparserwrapper.ast.Project'
java_import 'it.codemodels.javaparserwrapper.ast.Todo'
java_import 'java.util.Date'
java_import 'java.util.GregorianCalendar'
class TestParser < Test::Unit::TestCase
include CodeModels::JavaPa... | true |
a4f4565778092fe276106fc464dec9f9dea4acbf | Ruby | reqshark/commandlinetools | /sysadmin/backup/rubycookbook/21-ui/10 - Allowing Input Editing with Readline.rb | UTF-8 | 509 | 3.03125 | 3 | [] | no_license | #!/usr/bin/ruby -w
# readline.rb
require 'readline'
vegetable = Readline.readline("What's your favorite vegetable?> ")
puts "#{vegetable.capitalize}? Are you crazy?"
#---
$ ruby readline.rb
What's your favorite vegetable?> okra
Okra? Are you crazy?
#---
# readline_windows.rb
print "What's your favorite vegetable?> "
pu... | true |
f2326be8320388f42869322f276d19dfb00f53a2 | Ruby | rgo594/school-domain-nyc-web-career-040119 | /lib/school.rb | UTF-8 | 539 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class School
attr_accessor :grade
attr_reader :roster
def initialize(name)
@name = name
@grade
@roster = {}
end
def add_student(name, grade)
if roster[grade]
roster[grade] << name
else
roster[grade] = []
roster[grade] << name
end
end
def grade(g... | true |
88a6b5fec1ef07fff4da621f55b9489bd7fcfe24 | Ruby | jdan/adventofcode | /2015/rb/2015/19a-medicine.rb | UTF-8 | 1,199 | 3.4375 | 3 | [] | no_license | # http://adventofcode.com/day/19
def index_all(haystack, needle)
offset = 0
indices = []
# Initial value
index = haystack.index(needle, offset)
until index.nil?
indices << index
# Move the offset
offset = index + 1
# Find the next index
inde... | true |
9253d19e5b3ab9f10396b0f58af718849cda39d6 | Ruby | draffensperger/tt_demos | /lib/tt_demos/arg_checked_double/no_method_on_arg.rb | UTF-8 | 452 | 3.453125 | 3 | [
"MIT"
] | permissive | module NoMethodOnArg
class GreetingApp
def self.run
# give nil for default language
language = nil
Greeter.new.greet(language)
end
end
class Greeter
HELLOS = { english: 'Hello',
german: 'Hallo' }
def greet(language)
# language can be string or symbol
... | true |
db74a3595062bddfcdac6d94c4f0d1bb6d664756 | Ruby | jenpoole/rb-grade-avg | /user_input.rb | UTF-8 | 1,075 | 3.921875 | 4 | [] | no_license | require_relative("averages.rb")
class Input
attr_accessor :student_name, :score1, :score2, :score3, :students_and_scores
def user_input
@students_and_scores = {}
counter = 0
while counter < 25
puts "Enter student name: "
@student_name = gets.chomp
... | true |
6e56d201cee01c55ccb621080d8e63a1496bac9a | Ruby | batizhevsky/puzzlenode-solutions | /1/trade.rb | UTF-8 | 1,748 | 3.1875 | 3 | [] | no_license | require 'rexml/document'
require 'csv'
require 'bigdecimal'
class Trade
def self.total item, currency
prices = Trade.get_item_price item
conv = Trade.convert prices, currency
total = conv.inject(BigDecimal.new(0)){|sum, pr| sum + pr}.round(2, :banker).to_s('F')
File.open('OUTPUT.txt', 'w') { |f| f.pu... | true |
f029033eb8a64d9c5a422e60139395911b5b8452 | Ruby | LukeRobertsonUK/pet_shop | /main.rb | UTF-8 | 3,062 | 3.21875 | 3 | [] | no_license | require 'pry'
require_relative 'client'
require_relative 'animal'
require_relative 'shelter'
#initialize existing objects
hq = Shelter.new("Headquarters", "55 Clapham High Street")
people = [
Client.new("Luke", 35, :male, 1),
Client.new("Fred", 22, :male, 1),
Client.new("Wilma", 45, :female, 0),
Client.new("... | true |
0587d20d6b616422e0b683589d227ad014c687d6 | Ruby | npogodina/hotel | /lib/date_range.rb | UTF-8 | 780 | 3.265625 | 3 | [] | no_license | module Hotel
class DateRange
attr_reader :start_date, :end_date
def initialize(start_date:, end_date:)
#TODO: validate dates' input
#TODO: add defaults (for example, one year from/before Date.today)
@start_date = Date.parse(start_date)
@end_date = Date.parse(end_date)
rai... | true |
b1df788d4b42253eda8e2f39b8a19be14fc8a21b | Ruby | puffsun/itebooks | /test/lib/itebooks/base_test.rb | UTF-8 | 1,179 | 2.625 | 3 | [
"MIT"
] | permissive | require_relative '../../test_helper.rb'
describe Itebooks::Base do
subject {Itebooks::Base}
describe "querying from www.it-ebooks.info website" do
it "must have the it-ebooks.info api base url" do
subject.base_uri.must_equal("http://it-ebooks-api.info/v1")
subject.request.wont_be_empty
subj... | true |
db52f1a78f71b877769cda42b44a4d99b815b708 | Ruby | sjv-vinsol/Learning | /advance_ruby/exercise_dynamic_method_calling/bin/main.rb | UTF-8 | 405 | 3.125 | 3 | [] | no_license | require_relative '../lib/derived'
require_relative '../lib/string'
extract_class_pattern = /(.*).new/
puts 'Create object : '
input_object = gets.chomp
extract_class_pattern.match(input_object)
klass = Object.const_get($1)
obj = klass.new
print 'Enter a method name :'
input_method = gets.chomp
parsed = input_method... | true |
0e678e86cbbf138fa94702bdb9137fc69dca3f8e | Ruby | PayTrace/paytrace_ruby | /lib/paytrace/debug.rb | UTF-8 | 3,108 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'paytrace'
require 'minitest/autorun'
module PayTrace
# Useful helper methods for debugging.
module Debug
#
# Helper that loops through the response values and dumps them out
#
def self.dump_transaction
puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
response = PayTrace:... | true |
b4dc60f5b460f6330ebc17b670bcee2352168039 | Ruby | blackeaglejs/BEWD_DC_JAN2015 | /class18/zoheb/cc_validator_luhn.rb | UTF-8 | 599 | 3.640625 | 4 | [] | no_license | require 'pry'
def sumDigits(num, base = 10)
num.to_s(base).split(//).inject(0) {|z, x| z + x.to_i(base)}
end
def valid(x)
cc_arr = x.to_s.chars.map.to_a
cc_arr_int = []
cc_arr.each do |x|
y = x.to_i
cc_arr_int.push(y)
end
cc_arr_doubl = cc_arr_int.map.with_index{|v,i| i % 2 == 0 ? v: v*2}
total = 0
cc... | true |
3e65493193e118f25a0e6c28b7aac88d42ec2a09 | Ruby | Richmj/rForRuby | /times.rb | UTF-8 | 146 | 3.421875 | 3 | [] | no_license | # Write a method that can ring the bell N times,
#where N is a parameter passed to the method.
def ring(bell, n)
n.times do
bell.ring
end
end | true |
d04551b395e6076c7abab879ddb2e85d5cd5cb1b | Ruby | BlackwingKakashi/fibonaccicalculator | /quadraticequationcalculator.rb | UTF-8 | 229 | 3.5 | 4 | [] | no_license | puts "What is the a value"
a = gets.to_f
puts "What is the b value"
b = gets.to_f
puts "What is the c value"
c = gets.to_f
x1 = ((-1)*b+((b**2-4*a*c)**0.5))/(2*a)
x2 = ((-1)*b-((b**2-4*a*c)**0.5))/(2*a)
puts "X ="
puts x1
puts x2 | true |
2a67e231afe6ce744716ab96e0910845e1333b1a | Ruby | Zainab-Omar/ruby-puppy-onl01-seng-pt-070620 | /lib/dog.rb | UTF-8 | 280 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_accessor :name
@@all=[]
def initialize (name)
@name=name
self.save
end
def self.all
@@all
end
def self.print_all
@@all.each do |dog_name|
puts dog_name.name
end
end
def save
@@all << self
end
def self.clear_all
@@all.clear
end
end | true |
f770034e489d5ba1805fd464dfe286d13c2db549 | Ruby | kalves-rally/automation_learning | /sample_module.rb | UTF-8 | 1,441 | 3.09375 | 3 | [] | no_license | #setting the argument equals something will use that value if you don't pass one
def adopt_puppies(num, pay_type, email="j@test.com",name, address)
view_details_button(num).click
adopt_me_button.click
complete_the_adoption_button.click
name(name)
address(address)
email(email)
pay_type(pay_type)
@browser.... | true |
05d648c5a19d253638a0ae1df26e88d91fca2bb3 | Ruby | jchappypig/kidcare | /app/pdf/weekly_program_printer.rb | UTF-8 | 4,368 | 2.609375 | 3 | [
"MIT"
] | permissive | class WeeklyProgramPrinter
include Prawn::View
include Printer
def initialize(weekly_program)
initialize_fonts
@weekly_program = weekly_program
if @weekly_program.instance_of? WeeklyProgram
write_header
write_title('Weekly Program from ' + @weekly_program.week_range)
write_indoor_pr... | true |
dcc645c32eae218bbf4f2d85987054784e17a616 | Ruby | Michaelreforged/charts_hw | /app/models/product.rb | UTF-8 | 1,398 | 2.515625 | 3 | [] | no_license | class Product < ApplicationRecord
belongs_to :seller
# SELECT p.name, p.description, p.price, p.category, s.name AS sellers_name, s.email
# FROM products AS p
# LEFT JOIN sellers AS s
# ON p.seller_id = s.id
def self.w_seller
select('p.name, p.description, p.price, p.category, p.id as product_id , s.name ... | true |
762e3391b4d6cb3e304462435128cfc6565d073c | Ruby | LittleCatBear/Question3 | /team.rb | UTF-8 | 2,135 | 3.53125 | 4 | [] | no_license | class Team
Member = Struct.new(:name)
def initialize
@members = []
end
def <<(name)
@members << Member.new(name)
end
def members_names
@members.map { |member| member.name }
end
def pro_print(limit = 10)
members_names.take(limit).each { |name| puts name.capitalize }
end
def rever... | true |
782e57bfb23a0f3410560e3919a4ea301b6cfb16 | Ruby | Justafigurehead/CodeClanWork | /week_1/day_3/loops/function_loops.rb | UTF-8 | 1,095 | 4.125 | 4 | [] | no_license | # chicken_hash = [
# {name: "Clucky", eggs: 0, age: 2},
# {name: "Maggie", eggs: 2, age: 3},
# {name: "June", eggs: 3, age: 2},
# {name: "Wilma", eggs: 4, age: 4},
# {name: "Betty", eggs: 1, age: 1}
# ]
# def count_eggs(array)
# total = 0
# for chicken in array
# total += chicken[:eggs]
# chi... | true |
3875b88d9045f3bf14c21a4c529410ef4a82518d | Ruby | jknight1725/payday | /deal_deck.rb | UTF-8 | 456 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
class DealDeck
attr_accessor :cards, :deck
def initialize(args={})
@cards = args[:cards]
@deck = args[:deck]
end
def to_h
{
cards: self.cards.map{|k,v| [k.to_i, v.to_h]}.to_h,
deck: deck
}
end
def reset_deck
self.deck = cards.keys
end
def... | true |
0c6550151d38456c59bcdb19812ed2b9e09af9e9 | Ruby | Stono/migsql | /spec/migration_spec.rb | UTF-8 | 8,025 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'yaml'
require 'fileutils'
describe 'Migration' do
after :each do
FileUtils.rm_rf './db'
end
before :each do
FileUtils.mkdir_p './db'
@migration = Migration.new './db/config.yml'
@test_server = get_test_server
end
# Helper Methods
def create_example_server
... | true |
384014a6cbdba6ab4e16d38bb7a598b95b8ba266 | Ruby | ricecakemonster/BankAccounts | /specs/money_market_spec.rb | UTF-8 | 2,763 | 2.6875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/reporters'
require 'minitest/skip_dsl'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
# TODO: uncomment the next line once you start wave 3 and add lib/checking_account.rb
require_relative '../lib/money_market'
describe "MoneyMarket" do
describe "#initial... | true |
b43fc15c5aa9986dd589ae3cf272241941fb6604 | Ruby | DanielJPark/phase-0-tracks | /Ruby/hashes.rb | UTF-8 | 2,738 | 3.625 | 4 | [] | no_license | =begin
pseudocode
initialzie empty hash
Greet the new client and ask them to answer questions
prompt user for name, age, marital status, decor theme
return all information to client and ask if it is correct.
allow for corrections.
ask again until all info is correct
return upated information with message saying client... | true |
130f1ff042c73b876ff3cee22274f14c16c05972 | Ruby | caachz/backend_module_0_capstone | /day_4/exercises/methods.rb | UTF-8 | 1,172 | 4.625 | 5 | [] | no_license | # In the exercises below, write your own code where indicated
# to achieve the desired result. You should be able to run this
# file from your terminal with the command `ruby day_4/exercises/methods.rb`
# example: Write a method below that, when called will print your name
def print_name
p "Severus Snape"
end
print... | true |
21b459152dc3d77af4272c9e49083a6e6f8e0529 | Ruby | bbatsov/ruby-lint | /lib/ruby-lint/analysis/undefined_variables.rb | UTF-8 | 1,493 | 2.828125 | 3 | [
"MIT"
] | permissive | module RubyLint
module Analysis
##
# The UndefinedVariables class checks for the use of undefined variables
# (such as instance variables and constants). The order of definition and
# use of a variable does not matter.
#
# This analysis class does *not* check for undefined local variables. Rub... | true |
888f43a19ed9da13374402e5631877a2cb6723e9 | Ruby | barrettclark/AdventOfCode | /2016/day07/abba.rb | UTF-8 | 1,734 | 2.921875 | 3 | [] | no_license | class Abba
attr_reader :ip_address
# create 2 capture groups and match against each one
ABBA_PATTERN = /(.)(.)\2\1/
# http://stackoverflow.com/a/2403148/2100028
HYPERNET_PATTERN = /\[([^\]]+)\]/
def initialize(ip_address)
@ip_address = ip_address
end
def supports_tls?
has_abba? && abba_valid?... | true |
5bf6cfb345620e80c6a6e6ed245ac33fd274163d | Ruby | eventide-project/identifier-uuid | /lib/identifier/uuid/random.rb | UTF-8 | 831 | 2.515625 | 3 | [
"MIT"
] | permissive | module Identifier
module UUID
class Random
def get
self.class.get
end
def self.get
UUID.format(raw)
end
def self.raw
SecureRandom.uuid
end
def self.configure(receiver, attr_name=nil)
instance = new
if attr_name.nil?
if... | true |
e94ea638c113ddf2a176cd291c6fc640878ee153 | Ruby | lethan/Advent-of-Code | /2019/day19.rb | UTF-8 | 1,473 | 3.25 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'intcode'
program = []
file = File.open('input_day19.txt', 'r')
while (line = file.gets)
program = line.strip.split(',').map(&:to_i)
end
file.close
def print_beam(points)
x_min, x_max = points.keys.map { |a| a[:x] }.minmax
y_min, y_max = points.keys.map { |a| a[:y... | true |
2bdb47d19f833faba0036645be3ee42c23850fdc | Ruby | rhinorphan/gossip_mvc | /lib/controller.rb | UTF-8 | 670 | 2.9375 | 3 | [] | no_license | require 'gossip'
require 'view'
require 'csv'
class Controller
attr_accessor :view
def initialize(view)
@view = view
end
def create_gossip
view.display_create_gossip
puts "Choisi un ID pour ton potin"
id = gets.chomp
puts "Quel est ton nom ?"
author = gets.chomp
puts "Maintenant ... | true |
dce02c9bca0ccd74a61cc1cc3a10cf39856acfb2 | Ruby | charlesskariah/challenge | /app/models/task.rb | UTF-8 | 513 | 2.625 | 3 | [] | no_license | class Task < ActiveRecord::Base
belongs_to :user
has_many :user_tasks
has_many :user_answers
def winner_name
User.find(self.winner).name
end
def current_user_points(current_user_id)
self.user_tasks.where(user_id: current_user_id ).first.points
end
def opponent_user_points(current_user_id)
user_id... | true |
5828af419c10a443398c96c57297977b36ad853b | Ruby | Jesus/aoc-2020 | /day-5/solution.rb | UTF-8 | 740 | 3.5625 | 4 | [] | no_license | #!/bin/env ruby
def bsp(code, upper_char, lower_char)
code.each_char.reduce(0) do |acc, c|
if c == upper_char
(acc << 1) + 1
elsif c == lower_char
acc << 1
else
raise ArgumentError, "Unrecognized character: #{c}"
end
end
end
Seat = Struct.new(:row, :column) do
def self.from_boa... | true |
f8f630366671b545c524b6591b69a500bb766569 | Ruby | PerleOramay/THP_ruby | /exo_06.rb | UTF-8 | 645 | 3.4375 | 3 | [] | no_license | number_of_hours_worked_per_day = 10
number_of_days_worked_per_week = 5
number_of_weeks_in_THP = 11
puts "Travail : #{number_of_hours_worked_per_day * number_of_days_worked_per_week * number_of_weeks_in_THP}"
#Pour chaque variable une valeur est définie dans les lignes 1 à 3 donc dans la ligne 5 l'opération entre les ... | true |
ee106e5955255a43be8788ccba73739bc570a835 | Ruby | gps2601/dependency-injection-testing | /spec/exercise_1_spec.rb | UTF-8 | 1,656 | 3.46875 | 3 | [] | no_license | # Amend the following to be testable in isolation.
class Note
def initialize(title, body, note_formatter)
@title = title
@body = body
@formatter = note_formatter
end
def display
@formatter.format(self)
end
attr_reader :title, :body
end
class NoteFormatter
def format(note)
"Title: #{n... | true |
768b75d47f19cd8611d6fdf92ef0625b9d5e3959 | Ruby | FelipeGuz/ruby_kommit_fgs | /unit6/statement_modifiers.rb | UTF-8 | 403 | 3.75 | 4 | [] | no_license | ## Reducing some operations to only one line
## condition IF
number = 5000
verified = true
#=> simple version
if number>2500 && verified
puts "Huge number!"
end
#=> one line version
puts "Huge Number!" if number>2500 && verified
## UNLESS condition
x = 8
#=> simple version
unless x>10
puts "x in NOT greate... | true |
046f8477999089c711fc0e8e25814fe582e23fb8 | Ruby | catherineemond/challenges | /advent-of-code/advent_of_code_2018/day_2/checksum.rb | UTF-8 | 976 | 3.96875 | 4 | [] | no_license | input = File.read('./input.txt')
def parse(input)
input.split("\n")
end
# - loop over all the box ids
# - if a char appears twice, increment the twice_count by one
# - if a char appears thrice, increment the thrice_count by one
# - special rule:
# - if there is twice a twice count, it counts only once
# - i... | true |
3122f906f497fc4a443c3cd9e0b73af7a84a3d23 | Ruby | costagavras/ruby-fundamentals-methods | /ex2.rb | UTF-8 | 323 | 4.15625 | 4 | [] | no_license | # Define a method called negative? that accepts a number as an argument and returns a boolean (true/false) indicating whether that number is negative or not.
def negative?(my_number)
if my_number < 0
return true
else
return false
end
end
a_num = 3.458930
test_negative = negative?(a_num)
puts test_negati... | true |
cce60ab5a97dbe6d3890665f628936642d308054 | Ruby | sohyunc1990/programming-univbasics-4-simple-looping-lab-atx01-seng-ft-071320 | /lib/simple_loops.rb | UTF-8 | 448 | 3.5625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def loop_message_five_times(string)
i=0
while i < 5 do
puts string
i += 1
end
end
def loop_message_n_times(string, limit)
i=0
while i < limit do
puts string
i += 1
end
end
def output_array(array)
i=0
while i < array.length do
puts array[i]
i += 1
end
end
def return_string_ar... | true |
02ce58144bf4514fbe7a56c1f96f17cfa8dfab6f | Ruby | hrwilliams/ping_pong_ruby | /lib/ping_pong.rb | UTF-8 | 396 | 3.109375 | 3 | [] | no_license | class Fixnum
define_method(:ping_pong) do
result = []
(1..self).each() do |number|
if number == 0
result.push(number)
elsif number.%(15) == 0
result.push("pingpong")
elsif number.%(5) == 0
result.push("pong")
elsif number.%(3) == 0
result.push("ping")
... | true |
33652dbd75974699cfec748d2a38ff9a0a39a3e3 | Ruby | ViXP/design_patterns_ruby | /prototype/component.rb | UTF-8 | 968 | 2.828125 | 3 | [] | no_license | # CONCRETE COMPONENT
class MarketingCampaignPhase
attr_accessor :title, :goal
attr_reader :planned_costs, :actual_costs
def initialize(args = {})
@actual_costs = nil
@planned_costs = nil
@complete = nil
@goal = ''
@title = ''
define_properties args
end
def complete!(actual_costs = fa... | true |
8d6fd34ac8d13a5d9ea4b49eb8300083d2e90ad0 | Ruby | asoi567/bd_kr | /convert.rb | UTF-8 | 846 | 2.96875 | 3 | [] | no_license | require 'fileutils'
Encoding.default_external = 'CP866'
class Converter
attr_accessor :fio, :dir
def initialize(fio)
@fio = fio.strip[0, 3].upcase
@dir = File.join('converted/', @fio)
end
def perform
FileUtils.rm_r dir if Dir.exists? dir
Dir.mkdir dir
Dir.glob('ASB/*').each do |file_name... | true |
00127778c6c28272229079e2e77e0d8799ff8112 | Ruby | leonshimizu/prework | /Week_5_Prework/oop.rb | UTF-8 | 701 | 4.25 | 4 | [] | no_license | # Rewrite the two hashes to use a class instead. Also write the methods to retrieve the name and the color, and another method to redefine the color.:
boat1 = { "name" => "S. S. Minnow", "color" => "white", "price" => 20000 }
boat2 = { "name" => "Titanic", "color" => "black", "price" => 700000000 }
class Boat
def ... | true |
8a3141fcb10efd5cf7cd706d410210daeceaa434 | Ruby | medlib-v2/hosted | /scripts/ports.rb | UTF-8 | 1,704 | 2.6875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Configure custom ports
class Ports
# Default port forwarding
DEFAULT_PORTS = [
{guest: 80, host: 8000},
{guest: 443, host: 44300},
{guest: 3306, host: 33060},
{guest: 5432, host: 54320},
{guest: 8025, host: 8025},
{guest: 27017, host: 27017}
].freeze
attr_accessor :config,... | true |
613a60ddd773434961e56f4f609ab7c00bc3ab97 | Ruby | neworganizing/rails_vip | /tasks/rails_vip_tasks.rake | UTF-8 | 3,599 | 2.546875 | 3 | [
"MIT"
] | permissive | namespace :vip do
desc "Load in a new VIP source file. If VIP_FILE is set to a local file, this file will be imported and VIP_URL (if set) will be stored for reference. If VIP_URL is set and VIP_FILE is not, the file at the URL will be downloaded and then imported."
task :parse => :environment do
s = Source.new
... | true |
a009bbc28d389ab41d9b3cd89b6a3e84b328c973 | Ruby | AaronRohrbacher/anagrams | /lib/anagrams.rb | UTF-8 | 1,359 | 3.9375 | 4 | [] | no_license | # require('pry')
class Anagram
def initialize(word_array, phrase_input1, phrase_input2)
@phrase1 = word_array[0].upcase.gsub(/[^0-9A-Za-z]/, '')
@phrase2 = word_array[1].upcase.gsub(/[^0-9A-Za-z]/, '')
@phrase_input1 = phrase_input1
@phrase_input2 = phrase_input2
end
def anagram_check()
if @p... | true |
7fa4298377bf09537b10da589717ab478eb0aa90 | Ruby | gauravm31/VTAPP | /advance_ruby/object_store/lib/play.rb | UTF-8 | 270 | 2.59375 | 3 | [] | no_license | require_relative 'object_store'
class Play
include MyObjectStore
attr_accessor :age, :fname, :lname, :email
def validate
true
end
validate :email, uniqueness: true
def to_s
"name => #{fname} #{lname}, age => #{age}, email => #{email}"
end
end
| true |
a4d5dfc78ed03c11751f269302f77aae372877e7 | Ruby | AlecHFerguson/BetterMousetrap | /test/models/comment_test.rb | UTF-8 | 2,831 | 2.671875 | 3 | [] | no_license | require 'test_helper'
class CommentTest < ActiveSupport::TestCase
include CommentsHelper
setup do
@user = users(:one)
@gadget = gadgets(:one)
@comment_params = { user_id: @user.id, gadget_id: @gadget.id, title: 'Boolean Operator',
text: 'This is a good way to think logically', h... | true |
13c91d4518093e254af0d471557648b9ab5ac57c | Ruby | lukaszsliwa/adwords | /lib/adwords.rb | UTF-8 | 820 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
require "config"
module Adwords
VERSION = :v201109
# Sets Adwords configuration options.
#
# @examples
#
# Adwords.configure do |config|
# config.environment = 'sandbox'
# end
#
# @return [Config] The configuration
#
# @since 1.0.0
#
def self.configure
block_... | true |
73331b3910f43152e1ab12345d40ff1cae7b2c00 | Ruby | moioo/ffaker | /lib/ffaker/phone_number_se.rb | UTF-8 | 3,757 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
module Faker
# Format for swedish numbers, from here
# from http://sv.wikipedia.org/wiki/Telefonnummer
#
# All area codes are from this list
# http://sv.wikipedia.org/wiki/Lista_%C3%B6ver_svenska_riktnummer
#
# - Length 9
# 08-xxx xxx xx, 0xx-xxx xx xx, 0xxx-xx xx xx
# - Length 8... | true |
710adb31097aae5c599deb305aa331a72eca409c | Ruby | Argonus/codebook | /studies/algorithms-and-data-structures/labs/lib/exercise_3/solution.rb | UTF-8 | 680 | 3.5 | 4 | [] | no_license | # frozen_string_literal: true
# Implement Merge Sort
module Exercise3
class Solution
attr_reader :comparisons
def initialize(input)
@input = input
@comparisons = 0
end
def run
do_sort(@input)
end
private
def do_sort(input)
return input if input.length <= 1
... | true |
ef78b06878bc04399d0fdb7db181a3d8da8397d0 | Ruby | alexandradlg/bot_twitter | /bot.rb | UTF-8 | 1,079 | 2.546875 | 3 | [] | no_license |
require 'twitter'
require 'dotenv'
Dotenv.load
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_API_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_API_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_API_ACCESS_TOKEN']
config.access_token_... | true |
69da492a65922bc95a144ae6c82cc51d3544d3e1 | Ruby | JoseMPena/Command_line | /TODO_Sinatra/app.rb | UTF-8 | 945 | 2.625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
# We're going to need to require our class files
require_relative('lib/task.rb')
require_relative('lib/todo_list.rb')
require "pry"
todo_list = TodoList.new("Jose")
todo_list.load_tasks
tasks = todo_list.tasks
get "/" do
@user = todo_list.user
@tasks = todo_list.tasks
... | true |
1a02040646e23d7368495727da6c09174fef076e | Ruby | zdravkoandonov/ruby-fmi | /quine/quine.rb | UTF-8 | 208 | 3.015625 | 3 | [
"MIT"
] | permissive | def quine
a = "def quine\n"
b = ") + \"%p\" % c + b\nend\n\nquine"
puts a + (c = " a = \"def quine\\n\"\n b = \") + \\\"%p\\\" % c + b\\nend\\n\\nquine\"\n puts a + (c = ") + "%p" % c + b
end
quine
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.