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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e25470b55a093b8106814fb132279e53a403c13b | Ruby | stek29/bmstu-prog | /Sem3/lr7/p2/test_int_num.rb | UTF-8 | 761 | 2.75 | 3 | [
"Unlicense"
] | permissive | require 'minitest/autorun'
require_relative 'int_num'
# IntNum tests
class TestIntNum < Minitest::Test
POSITIVE = 42
NEGATIVE = -228
def setup
@int_num_positive = IntNum.new POSITIVE
@int_num_negative = IntNum.new NEGATIVE
end
def test_n_digits
assert_equal 2, @int_num_positive.int_n_digits
... | true |
1a9c69225d1e85634ef6960c9a38a0ae3f9b6007 | Ruby | Gazer/rbbcode | /lib/rbbcode/tree_maker.rb | UTF-8 | 12,679 | 3.171875 | 3 | [
"MIT"
] | permissive | require 'pp'
module RbbCode
module CharCodes
CR_CODE = 13
LF_CODE = 10
L_BRACK_CODE = 91
R_BRACK_CODE = 93
SLASH_CODE = 47
LOWER_A_CODE = 97
LOWER_Z_CODE = 122
UPPER_A_CODE = 65
UPPER_Z_CODE = 90
end
class Node
def << (child)
@children << child
end
attr_accessor :children
... | true |
9f6ef32bcb364aed9e7ab3ee3ca27357b18c27e9 | Ruby | pschlatt/westeros | /app/models/house.rb | UTF-8 | 304 | 3 | 3 | [] | no_license | class House
attr_reader :houses, :name, :id
def initialize(data = "")
@houses = [
['Stark', 'stark'],
['Lannister', 'lannister'],
['Targaryen', 'targaryen'],
['Tyrell', 'tyrell'],
['Greyjoy', 'greyjoy']
]
@name = data["name"]
@id = data["id"]
end
end
| true |
176a96f54de57fa69875c355cfb2e34b8bab0ce0 | Ruby | captainmarkos/tealeaf | /intro_to_programming/easy_questions/quiz1_1.rb | UTF-8 | 162 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby -w
numbers = [1, 2, 2, 3];
numbers.uniq
puts "--> numbers: #{numbers}" # [1, 2, 2, 3]
puts "--> numbers.uniq: #{numbers.uniq}" # [1, 2, 3]
| true |
ccf053adafab34dadac8e6dff4ae0ca248bc4599 | Ruby | susanaAlcala/desafio_hashes | /desafio_hashes/d_2-4.rb | UTF-8 | 198 | 3.390625 | 3 | [] | no_license | #2.4. Convertir el hash en un array y guardarlo en una nueva variable
productos = {'bebida' => 850, 'chocolate' => 1200, 'galletas' => 900, 'leche' => 750}
arr = []
arr = productos.to_a
print arr | true |
95be47701257c38b2700ed4597b0a83f453ddced | Ruby | MarkBorcherding/programming-exercises | /markov-chain/markov.rb | UTF-8 | 877 | 3.578125 | 4 | [] | no_license | #
class Markov
attr_accessor :map
def initialize
self.map = {}
end
def train(words)
words.each_cons(2) do |pair|
if pair[0] =~ /[\.\?!]$/
transition pair[0], :end
transition :start, pair[1]
else
transition *pair
end
end
end
def transition(from, to)
... | true |
7c4408905dd3e87e859f9fe9a041abeb419520ee | Ruby | eric-johnson/slack-bot | /bot.rb | UTF-8 | 816 | 2.640625 | 3 | [] | no_license | $LOAD_PATH.unshift( File.dirname(__FILE__) )
require "slack-ruby-bot"
require "pry"
require "blink_stick_controller"
class PongBot < SlackRubyBot::Bot
def self.stick
@stick ||= BlinkStickController.new
end
command "ping" do |_client, data, _match|
client.say(text: "pong", channel: data.channel)
end
... | true |
15b15901ee6d5a3d0a0d716c37a0a9d221e75c0c | Ruby | alemosie/earthdata-search | /app/presenters/facets_presenter.rb | UTF-8 | 2,864 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class FacetsPresenter
# Order matters in SCIENCE_KEYWORDS
SCIENCE_KEYWORDS = ['topic', 'term', 'variable_level_1', 'variable_level_2', 'variable_level_3']
KEYWORD_CHILD = {
'topic' => 'term',
'term' => 'variable_level_1',
'variable_level_1' => 'variable_level_2',
'variable_level_2' => 'variable_le... | true |
8d735dc5c3c78cb058a77e69608dc3aa0cd6730e | Ruby | morganmiller/goober | /db/seeds.rb | UTF-8 | 1,458 | 2.6875 | 3 | [] | no_license | class Seed
def initialize
create_riders
create_drivers
create_rides
end
def create_riders
@rider = User.create(name: "Morgan",
email: "mm@gmail.com",
phone_number: "7274216505",
password: "password",
password_confirmation: "password")... | true |
0819534efc8c8d91e90010737e5f722cd4b54295 | Ruby | Archaela7255/upperline-basic-sinatra-template | /app/models/sample_model.rb | UTF-8 | 21,767 | 2.828125 | 3 | [] | no_license | def life_help(q1, q2)
if q1 == "shelter" && q2 == "healthcare"
"Here are some tips for when you're seeking shelter and basic amenities:
<br>
-Get a membership at your local gym and use their shower and bathrooms, they usually have free wifi as well and might even offer discounts for ... | true |
f64e63f8ae084093646c19575cb964ab55046503 | Ruby | mcary/campfire-bot | /plugins/weather.rb | UTF-8 | 689 | 2.96875 | 3 | [] | no_license | require 'yahoo-weather'
class Weather < CampfireBot::Plugin
on_command 'weather', :weather
def weather(msg)
city = {
'adelaide' => 'ASXX0001',
'brisbane' => 'ASXX0016',
'canberra' => 'ASXX0023',
'darwin' => 'ASXX0032',
'hobart' => 'ASXX0057',
'melbourne' => 'ASXX... | true |
bdd7b3907741e1ba3c9694f938e42ff9ee3e3c4d | Ruby | vweythman/omnible | /app/models/prejudice.rb | UTF-8 | 2,185 | 2.53125 | 3 | [] | no_license | # Prejudice
# ================================================================================
# subpart of characters
#
# Table Variables
# --------------------------------------------------------------------------------
# variable | type | about
# -------------------------------------------------------... | true |
7788ce720783a557611284ab091b602bfb876b2b | Ruby | bbensky/launch_school | /launch_school_lessons/120/120_small_problems/medium_1/10_poker.rb | UTF-8 | 4,718 | 4.15625 | 4 | [] | no_license | require 'pry'
class Card
include Comparable
RANKINGS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace'].freeze
attr_reader :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def <=>(other_card)
RANKINGS.index(@rank) <=> RANKINGS.index(other_card.rank)
end
... | true |
632b5c5bfdbd2ef882fc0cfa530d2e52bc16102b | Ruby | dpholbrook/ruby_small_problems | /small_problems/debugging/5.rb | UTF-8 | 1,963 | 4.40625 | 4 | [] | no_license | =begin
We get a type error because when we call sum on remaining_cards we are trying
to add numbers and symbols.
We can fix this be saving the return value of the call to map which will give
us an array of the values of the remaining cards.
The sum is lower than it should be because every time we deal, we are popping... | true |
9890323a266562e3c73693e9a451c56f0b9ad0f2 | Ruby | Willardgmoore/practice | /5.rb | UTF-8 | 413 | 3.75 | 4 | [] | no_license | #2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
#
#What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
result = 0
divisible_thru = 25
idx = divisible_thru
idx1 = 1
while idx1 < (divisible_thru + 1)
if idx % i... | true |
b0226a4204d7ffa6089536ccac8d6149868d7be9 | Ruby | sekine126/crawling | /src/scraping_infoseek_source.rb | UTF-8 | 893 | 2.75 | 3 | [] | no_license | require './src/object/anemone_crawl.rb'
require 'optparse'
require 'bundler'
Bundler.require
params = ARGV.getopts('d:')
if params["d"] == nil
puts "Error: Please set -d date option."
exit(1)
end
if params["d"] != nil && params["d"].size != 8
puts "Error: -d is date. e.g. 20150214"
exit(1)
end
my_crawl = Ane... | true |
1ab8a442d227e33e28408e84bf3472588cef2d43 | Ruby | geko727/Learn_to_Program | /14/profiler.rb | UTF-8 | 214 | 2.890625 | 3 | [] | no_license | def profile block_description, &block
profiling_on = false
if profiling_on
start_time = Time.new
block.call
duration = Time.new - start_time
puts "#{block_description}: #{duration} seconds"
else
block.call
end
end | true |
a0a4a3d8356637f65a4023523481326fbcee51d0 | Ruby | ajosepha/command_line_classmates | /lib/student.rb | UTF-8 | 257 | 2.578125 | 3 | [] | no_license | class Student
attr_accessor :name, :twitter, :blog
def initialize(name, twitter, blog)
@name = name
@twitter = twitter
@blog = blog
end
end
#hunger_games = Student.new("Katniss", "@dist12", "ihartzgale") | true |
a094cd9a19548980c3cd39b0c2c0bd86a2777ed1 | Ruby | NawarYossef/launch_school | /coding_challenges/permutation_step.rb | UTF-8 | 681 | 4.4375 | 4 | [] | no_license | # Challenge :
# Using the Ruby language, have the function PermutationStep(num) take the num parameter being passed and return the next number greater than num using the same digits.
# For example: if num is 123 return 132, if it's 12453 return 12534.
# If a number has no greater permutations, return -1 (ie. 999).
... | true |
3c1b3fada1831081001164d0095bb9bc426d64bf | Ruby | bibikhadiza/school-domain-wdf-000 | /lib/school.rb | UTF-8 | 320 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_reader :roster
def initialize(school)
@school = school
@roster = {}
end
def add_student(student, grade)
if !@roster[grade]
@roster[grade] = []
end
@roster[grade]<< student
end
def grade(grade)
@roster[grade]
end
def sort
@roster.each {|grade, student| student.sort!}
end
end
| true |
651a0647e9578355d80d4f50381b09a5bbd69a8d | Ruby | dwijendraparashartech/robottestingat12nov | /app/models/robot.rb | UTF-8 | 2,925 | 3.046875 | 3 | [] | no_license | class Robot
include ActiveModel::Model
attr_accessor :size_grid, :max_x, :max_y, :x, :y, :f, :commands, :report
def initialize(params={})
@x = params[:x].try(:to_i)
@y = params[:y].try(:to_i)
@f = params[:f] || ""
@size_grid = sanitize_size(params[:size_grid])
@max_x, @max_y = @size_grid.spl... | true |
1e1245190d2ed8f2ac46df3a66f3470584b7bc5d | Ruby | danott/aces | /test/aces_test.rb | UTF-8 | 4,452 | 2.65625 | 3 | [
"MIT"
] | permissive | require "test_helper"
require "pry"
class AcesTest < Minitest::Test
class SuccessService
include Aces::Service
attr_reader :value
def initialize(value)
@value = value
end
def call
success value: value
end
end
class FailureService
include Aces::Service
attr_reader ... | true |
a917c959aa181fbbf8f19b8230a9b43b9ec4f0e6 | Ruby | avk513/LaunchSchool | /hashes/ex_5.rb | UTF-8 | 298 | 3.640625 | 4 | [] | no_license |
#my solution
=begin
person = {name: 'Bob', occupation: 'web developer', hobbies: 'painting'}
puts person.has_value?('Bob')
=end
#launchschool
opposites = {positive: "negative", up: "down", right: "left"}
#has_value?
if opposites.has_value?("negative")
puts "Got it!"
else
puts "Nope!"
end | true |
5da133de35ba2c5788c11b15f11899f1984e860b | Ruby | hillstew/mastermind | /mastermind.rb | UTF-8 | 621 | 3.1875 | 3 | [] | no_license | require './lib/game'
require './lib/sequence'
puts "Welcome to Mastermind"
puts "Would you like to (p)lay, read the (i)nstructions, or (q)uit?"
print ">"
response = gets.chomp
sequence = Sequence.new
@game = Game.new(sequence) if response == "p"
# require 'pry'; binding.pry
loop do
puts @game.sequence.code
puts "... | true |
89f1d16d3b18722e7daff475591d23f6ea1ec774 | Ruby | potapovDim/full | /ruby/po/editor/shared-tab/background/sub-menu.rb | UTF-8 | 1,252 | 2.625 | 3 | [] | no_license | class SubMenu
def initialize (browser)
@browser = browser
@color_tab = '[data-test="page-settings-tab-color"]'
@image_tab = '[data-test="page-settings-tab-image"]'
@gradient_tab = '[data-test="page-settings-tab-gradient"]'
@acti... | true |
ffd7fb34bbdd1005d8acec14f62fc82d17ce7a71 | Ruby | dianawhalen/archived_black_thursday | /lib/customer_repository.rb | UTF-8 | 834 | 2.90625 | 3 | [] | no_license | class CustomerRepository
attr_reader :path,
:engine
def initialize(path, engine)
@path = path
@engine = engine
end
def csv
@csv ||= CSV.open(path, headers: true, header_converters: :symbol)
end
def all
@all ||= csv.map do |row|
Customer.new(row, self)
end
end
... | true |
1da147cd8aa58ee8666ea740a45bc0f91642652a | Ruby | DGaffney/DonaldSentiment | /lib/report.rb | UTF-8 | 14,214 | 2.703125 | 3 | [] | no_license | class Fixnum
def nan?
return false
end
def finite?
return true
end
end
class Report
attr_accessor :raw_data
def self.prev_month_query(time)
{"$or" => TimeDistances.same_time_in_previous_month(time).collect{|x| {"time" => Hash[["$lte", "$gte"].zip(x)]}}}
end
def self.prev_days_query(time... | true |
c56d6bf6ece3e5961a7d05cbfc0b6b7123c0668b | Ruby | EDalSanto/dkvs | /lib/load_balancer.rb | UTF-8 | 1,822 | 2.890625 | 3 | [] | no_license | # frozen_string_literal: true
require "socket"
require_relative "server"
# accepts connections from clients for access to one of managed servers
# distributes requests to a server using round robin
class LoadBalancer
LISTENING_SOCKET_PATH = "/tmp/dkvs_lb.sock"
PRIMARY_SERVER_SOCKET_PATH = "/tmp/dkvs-primary-serve... | true |
eac1d9cce24bdad63e554ff8f46f9fcecd23c79a | Ruby | mralexsatur/boris-bikes-2 | /lib/docking_station.rb | UTF-8 | 1,633 | 3.375 | 3 | [] | no_license | require './lib/bike'
require './lib/van'
class DockingStation
DEFAULT_CAPACITY = 10
attr_accessor :bikes
def initialize(capacity = DEFAULT_CAPACITY)
@bikes = []
@broken_bikes = []
@capacity = capacity
end
def working_bikes
@bikes
end
def broken_bikes
@broken_bikes
end
def re... | true |
ae5cef7d94de9ada69649ba8a79e73e81176c536 | Ruby | VIP-eDemocracy/elmo | /app/helpers/language_helper.rb | UTF-8 | 483 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | module LanguageHelper
# finds the english name of the language with the given code (e.g. 'French' for 'fr')
# tries to use the translated locale name if it exists, otherwise use english language name from the iso639 gem
# returns code itself if code not found
def language_name(code)
if configatron.full_loca... | true |
5150e7ff2961cda872d7e99660eacc45d350debd | Ruby | pangland/PARC | /lib/associatable.rb | UTF-8 | 2,885 | 2.625 | 3 | [] | no_license | require_relative 'searchable'
require 'active_support/inflector'
require 'byebug'
class AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
@class_name.to_s.constantize
end
def table_name
@class_name.to_s.constantize.table_name
end
end
class BelongsT... | true |
e97352c96f7d8c09a024a51affbb97f449b1d316 | Ruby | Nashmeyah/school-domain-onl01-seng-ft-032320 | /lib/school.rb | UTF-8 | 465 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
#defines only the getter
attr_reader :roster, :school
# Create empty roster
def initialize(school)
@roster = {}
@school = school
end
def add_student(student_name, grade)
if !@roster[grade].is_a?(Array)
@roster[grade] = []
end
@roster[grade] << student_name
end
de... | true |
19a02d1bd26d6d98168f12345d013e6a2d044372 | Ruby | luvalladares/tasks_app | /app/models/task.rb | UTF-8 | 353 | 2.59375 | 3 | [] | no_license | class Task < ActiveRecord::Base
attr_accessible :description, :priority
validates_presence_of :description
validates :priority, numericality: {greather_than:0}
validates_uniqueness_of :description
before_validation :clean_description
private
def clean_description
if self.description.present?
self.description.... | true |
21b732082f4abe21b10ebcce7c42cbedc11f70a4 | Ruby | AdManteza/ContactListApp | /contact_list.rb | UTF-8 | 2,291 | 3.6875 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative 'contact'
require 'pry'
# Interfaces between a user and their contact list. Reads from and writes to standard I/O.
class ContactList
# TODO: Implement user interaction. This should be the only file where you use `puts` and `gets`.
def initialize
self.display_menu if ARGV.s... | true |
d53cfb5e536b5e2b504a536c39b9a6f41d14de72 | Ruby | abuhabuh/healthProj | /app/models/surgical_profile.rb | UTF-8 | 6,872 | 2.546875 | 3 | [] | no_license | ##
# Surgical Profile
#
# Enumerated fields
# - fields are: patient_status, elective_surgery_option, origin_status,
# anesthesia_technique
# - represented as integers [0 to n-1] in database and mapped to strings
#
# DB Table
# - Encrypted Fields
# - hospital_admission_date
# - operation_date
##
class SurgicalP... | true |
2491726b2a0006c57755fefa7034f9350d10023d | Ruby | markmcspadden/the_perfect_ruby_code_sample | /test_me_maybe?/test_me_maybe?.rb | UTF-8 | 1,219 | 3.078125 | 3 | [] | no_license | class BaseTest
def self.tests
@tests ||= []
end
def self.output
end
end
@test_class = nil
def hey!(class_name=Object)
fork do
`afplay "#{File.dirname(__FILE__)}/song.m4a"`
end
puts "Testing #{class_name}"
puts "Hey!"
test_class_name = "#{class_name}Test"
@test_class = Object.const_set... | true |
8148ad2c7e0f5e0eb9ef471ba82fbe38e8148cc4 | Ruby | brownmike/project-euler | /24.rb | UTF-8 | 3,345 | 4.1875 | 4 | [] | no_license | # Lexicographic permutations
# Problem 24
# A permutation is an ordered arrangement of objects. For example, 3124 is one
# possible permutation of the digits 1, 2, 3 and 4. If all of the permutations
# are listed numerically or alphabetically, we call it lexicographic order. The
# lexicographic permutations of 0, 1 an... | true |
3b427c1ad30a9c43b05988b31f4ce46ebadb0498 | Ruby | ijdickinson/jena-jruby | /lib/jena_jruby/namespace.rb | UTF-8 | 1,134 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | module Jena
module Vocab
# A namespace is an object for resolving identifiers in scope denoted
# by a base URI to a full URI. For example,
#
# rdfs = Namespace.new( "http://www.w3.org/2000/01/rdf-schema#" )
# rdfs.comment # => "http://www.w3.org/2000/01/rdf-schema#comment"
#
# There... | true |
71420e217df5ceecfc22f1ffc594d138caf9af3c | Ruby | thblckjkr/homework | /scripting_sockets/ruby/Addressbook_server.rb | UTF-8 | 955 | 2.9375 | 3 | [
"MIT"
] | permissive | # Import of libraries
require 'socket' # Import main socket library
require_relative "Utils" # General program utilities
require_relative "Database"
class Socket
def initialize(port, db, pr, ui)
@@ui = ui
@@db = db
@@pr = pr
ui.show("Opening port")
@@server = TCPServer.new port # Server ... | true |
6bb79ee83043595c5004e0ada8e1562a072112f4 | Ruby | israelb/pragmatic-ruby | /playlist.rb | UTF-8 | 2,186 | 3.5625 | 4 | [] | no_license | require_relative 'movie'
require_relative 'waldorf_and_statler'
require_relative 'snak_bar'
require "colorize"
module Flicks
class Playlist
def initialize(name)
@name = name
@movies = []
@config = {space: 50, symbol: '*'}
end
def load(from_file)
File.readlines(from_file).each do ... | true |
85e1540973216b9c07573a20eb92edd70d3388ac | Ruby | ohpauleez/research | /p2pusenet/extra/scripting-examples/DetailedExample/example2.rb | UTF-8 | 769 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
#Note: I say this is ruby, but it's truthfully JRuby,
#You can change the path env to JRuby if you desire.
#
print "Starting the second script\n"
require "java"
print "trying to include all of java.\n"
print "This will cause name conflicts with things like 'String'\n"
print "\t...so we will put... | true |
8ed501a7ccc615b1341b1a7252e3ecf493ab6583 | Ruby | michaelpmattson/funny_2107 | /spec/open_mic_spec.rb | UTF-8 | 1,861 | 3.1875 | 3 | [] | no_license | require './lib/open_mic'
require './lib/user'
require './lib/joke'
RSpec.describe OpenMic do
context '#initialize' do
it 'exists' do
open_mic = OpenMic.new({location: "Comedy Works", date: "11-20-18"})
expect(open_mic).to be_instance_of(OpenMic)
end
it 'has a location' do
open_mic = O... | true |
98e757347f3909b55d869202719c766d50966a15 | Ruby | MrWorld/stronghold | /test/unit/lib/open_stack_object_test.rb | UTF-8 | 1,272 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require_relative '../../support/open_stack_mocks'
class TestOpenStackObject < CleanTest
def setup
@foo = Foo.new(Mock.new)
end
def test_object_has_attributes_and_methods
[:foo, :bar, :baz].each do |sym|
assert @foo.respond_to? sym
end
end
def test_object_delegates_ca... | true |
77b86c7480ad90d02fd998cd2cb3ed9f51277674 | Ruby | yasmineezequiel/Vanilla_Ruby | /Section_5_Ruby_Methods1/The_Ternary_Operator.rb | UTF-8 | 929 | 4.8125 | 5 | [] | no_license | # The ternary operator, it takes 3 things as per the name. It's a shorter syntax than an if statement.
if 'yes' == 'yes'
p "They are the same"
else
p "They are not the same"
end
# ternary operator:
p 'yes' == 'yes' ? "They are the same" : "They are not the same"
def even_odd_number(num)
num.even? ? "The numbe... | true |
359c44a8a435929c732aaca5ddd17941ea324faf | Ruby | amgencjana/magic_matrix | /lib/magic_matrix/matrix.rb | UTF-8 | 575 | 2.859375 | 3 | [
"MIT"
] | permissive | module Magic
class Matrix
# Magic::Matrix class
# recives as an attribute path the the yaml file
#
# = response to only one public method magic_hash
attr_accessor :matrix
# returns hash read from the the given yaml file
# each inner hash will be wrapped with the Magic::Hash class... | true |
3320cd06016b5eae789dbf4ffe94484e8a24159f | Ruby | shanahagood/phase-0-tracks | /ruby/santa.rb | UTF-8 | 2,516 | 3.84375 | 4 | [] | no_license | class Santa
#makes a (getter) method readable.
# attr_reader :age, :ethnicity
#makesa method readable and writeable.
attr_accessor :age, :ethnicity, :gender
def initialize(gender, ethnicity)
puts "Initializing Santa instance...!"
@reindeer_ranking = ["Rudolph", "Dasher", "Dancer", "Prancer",
"Vixe... | true |
4d5521ffa56f33096aa81c5ae87a01d13af45171 | Ruby | twill14/launchschool-practice-exercises | /exercise_two/exercises_two.rb | UTF-8 | 1,060 | 4.125 | 4 | [] | no_license | # Exercise One
first_name = "Thomas"
last_name = "Williams"
full_name = first_name + " " + last_name
# OR
"Thomas " + "Williams"
# Exercise Two
6342 / 1000 # = 6
6342 % 1000 / 100 # = 3
6342 % 1000 % 100 / 10 # = 4
6342 % 1000 % 100 % 10 # = 2
#Exercise Three
#movie_years = {:one => 1975, :two => 2004, :... | true |
e4942d99b70be21b80da1854d0ff16fc5c5f9f31 | Ruby | dannykim1997/Phase-4-challenge-practice | /app/models/destination.rb | UTF-8 | 344 | 2.703125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Destination < ApplicationRecord
has_many :posts
has_many :bloggers, through: :posts
def most_recent_posts
posts.last(5)
end
def popular_post
posts.max_by{|post|post.likes}
end
def avg_blogger_age
total = bloggers.uniq.sum{|b| b.age}
total.to_f/blogger... | true |
25c8f85963054d21298afcc925b90cd12306c9e8 | Ruby | ejatkin/lrthw | /ex29.rb | UTF-8 | 633 | 4.03125 | 4 | [] | no_license | people = 20
cats = 30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed!"
end
if people > cats
puts "Not many cats! The world is saved!"
end
if people < dogs
puts "The world is drooled on!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if people >= dogs
puts "People are greater t... | true |
8dfbe5ff67188174db3d258d87fd7fdf9f8551ef | Ruby | martenlienen/vldt | /lib/vldt/each.rb | UTF-8 | 631 | 2.6875 | 3 | [
"MIT"
] | permissive | module Vldt
# Validates each object of an enumerable
class Each < Validation
def initialize (validation)
@validation = validation
@array_validation = Vldt::Array.array
end
def call (object)
errors = Vldt::Array.array.call(object)
if errors
errors
else
erro... | true |
5de4ddbcf5da7b3eb9a824ac520ca3e174fbe1ff | Ruby | skunitomo/heroku01 | /app/controllers/people_controller.rb | UTF-8 | 671 | 2.59375 | 3 | [] | no_license | class PeopleController < ApplicationController
def index
end
def sample
render "index"
end
def json
personal = {'name' => 'Yamada', 'age' => 28}
render :json => personal
end
def xml
personal = {'name' => 'Yamada', 'age' => 28}
render :xml => personal
end
def inputParames
render :text => "upper ... | true |
fe1385468b3fc960e0544b1f4fe8be8d264fb4bd | Ruby | elliotte/borisbikes | /spec/docking_station_spec.rb | UTF-8 | 2,254 | 3.109375 | 3 | [] | no_license | require 'docking_station'
describe DockingStation do
let(:station) { DockingStation.new [], 20 }
let(:bike) { double :bike, broken?: false }
let(:broken_bike) { double :broken_bike, broken?: true }
let(:broken_bike2) { double :broken_bike, broken?: true }
let(:broken_bike3) { double :broken_bike, broken?: true ... | true |
c29905f92fd3b1fd7abb9852e470ad4160d3aeb1 | Ruby | abhishekg785/Getting-started-with-Ruby | /array.rb | UTF-8 | 880 | 4.28125 | 4 | [] | no_license | def testing()
arr = Array.new(6) # Declares the a new Array of size
hash_arr = Array.new(2) { Hash.new } # => [ {} {} ]
# creating a 2d array
two_d_array = Array.new(2) { Array.new(2) } # [ [], [] ]
# Accessing the array elements
a = [ 'a', 'b', 'c', 'd', 'e']
puts a[0]
puts a.at(0)
#puts a.fetch(... | true |
568c4975a6c0b2d90cc191d343b57add61ae7fb7 | Ruby | trinityseal/poison | /lib/poison.rb | UTF-8 | 817 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
trap('INT') do
perror('You killed me :(')
end
# Standard libs
require 'optparse'
require 'ostruct'
require 'uri'
require 'net/http'
# Custom libs
require 'puf/version'
require 'puf/scanner'
require 'puf/prettyp'
# String class with color methods
String.class_eval do
include Poison::P... | true |
2de983a98f48f982379eabd06d310987f206f6cb | Ruby | Sufl0wer/summer-2019 | /3493/2/lib/file_methods.rb | UTF-8 | 941 | 2.671875 | 3 | [] | no_license | class FileMethods
API_URL = 'https://api.telegram.org/'.freeze
def self.request_file_path(file_id, person_number, folder_name)
uri = URI("#{API_URL}bot#{ENV['TOKEN']}/getFile?file_id=#{file_id}")
json_response = JSON.parse(Net::HTTP.get(uri))
new.save_photo_from_uri(json_response['result']['file_path']... | true |
f7ca51aa2de1beecfa595659578907c4d54dc9b4 | Ruby | soutaro/unification_assertion | /lib/unification_assertion.rb | UTF-8 | 5,485 | 3.1875 | 3 | [
"MIT"
] | permissive | require "unification_assertion/version"
module UnificationAssertion
if defined? Test::Unit
include Test::Unit::Assertions
else
require 'minitest/autorun'
include MiniTest::Assertions
end
module_function
@@comparators = {}
@@comparators[Array] = lambda {|a, b, eqs, unifier, path, block|
... | true |
b03154fb17b3d448b8061d2c9170f5c3de13c9a1 | Ruby | shraddhap23/basic_ruby | /basic_ruby.rb | UTF-8 | 740 | 3.9375 | 4 | [] | no_license | #1A
def add_phrase(phrase)
phrase + "Only in America!"
end
puts add_phrase("Donald Trump and Ted Cruz are viable Presidential candidates...")
#1B
def max(array)
max = array[0]
for i in 0..array.length - 1
if array[i] > max
max = array[i]
end
end
puts max
end
max ([12, 37... | true |
83850d14a0723acba3cf086b2bb3513bbcb2fd92 | Ruby | kontez/PM1-PT1 | /Aufgabe4/teil4/Life.rb | UTF-8 | 1,288 | 2.921875 | 3 | [] | no_license | require "Zelle"
require "Point"
class Life
def initialize(n,muster_index)
end
# Initialisiert das Spielfeld mit Objekten der Klasse Zelle
# Die Position einer Zelle ist definiert durch die obere linke Ecke des Gitternetzes
# und die Zeile / Spalte, in der die Zelle steht.
# Die Zelle berechnet eigenstän... | true |
5290fa3439495fafb35458d707296e3a8b87be96 | Ruby | jeroeningen/logius_test | /case_b/app/models/user.rb | UTF-8 | 3,435 | 2.625 | 3 | [] | no_license | class User < ActiveRecord::Base
has_one :bankaccount
has_many :transactions, through: :bankaccount
validates :bankaccount, presence: true
validates :firstname, presence: true
validates :lastname, presence: true
validates :email, presence: true, uniqueness: true
# Code used: http://stackoverflow.com/quest... | true |
29582955c05fe539191285683c33e164e7af5981 | Ruby | ElizabethNicholas14/TTSRubyPractice | /activity_today.rb | UTF-8 | 944 | 3.875 | 4 | [] | no_license | puts "What is today's temperature"
todays_temperature = gets.chomp.to_i
case todays_temperature
when 80..100
puts "Let's go swimming"
when 50...80
puts "Let's go hiking"
when 40...50
puts "Let's stay inside and read"
when 0...40
puts "Let's cozy up by the fire"
else
puts "What planet is that?"
end
if todays... | true |
de433ac6e75bbc64a0364c76dee94e9a91db8111 | Ruby | epeters95/sage_one | /lib/sage_one/client/contacts.rb | UTF-8 | 647 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module SageOne
class Client
module Contacts
# Get a contact record by ID
# @param [Integer] id Contact ID
# @return [Hashie::Mash] Contact record
# @example Get a contact:
# SageOne.contact(12345)
def contact(id)
get("contacts/#{id}")
end
# List all conta... | true |
fd8ea5387b1560a26ca5c1d42e4849c9180dad50 | Ruby | rsupak/tc-challenges | /Address_Book_Complete/spec/entry.rb | UTF-8 | 318 | 3.234375 | 3 | [] | no_license | # Base entry class for address book
class Entry
attr_accessor :name, :phone, :email
def initialize(name = nil, phone = nil, email = nil)
@name = name
@phone = phone
@email = email
end
# display entry information
def display_entry
"Name: #{name}\nPhone: #{phone}\nEmail: #{email}"
end
end
| true |
3b89d07d4b62817343ca5d14180ac13346d6c2cc | Ruby | Brightcoders-Bootcamps/kata-07-pacman-team_07 | /app/classes/pacman.rb | UTF-8 | 1,639 | 3.46875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'rules'
# frozen_string_literal: true
#
# Class used to control a Pacman
class Pacman
attr_reader :position_x, :position_y, :rotation
def initialize(position_x, position_y, limit)
@position_x = position_x
@position_y = position_y
@rotation = :up
@l... | true |
289391928cbe8adbc1e227ef45925aa1234d450f | Ruby | nidhishah13/Todo-API | /app/controllers/v1/items_controller.rb | UTF-8 | 2,152 | 2.640625 | 3 | [] | no_license | module V1
class ItemsController < ApplicationController
before_action :set_todo
before_action :set_todo_item, only: [:show, :update, :destroy]
def_param_group :todo_item do
param :todo_id, String, :desc => "Todo_id of the item", :required => true
param :id, String, :desc => "Item_id", :requir... | true |
41feded645945978b8f1489a4aee5b9583ff2bd7 | Ruby | smartlogic/hobostove | /spec/line_spec.rb | UTF-8 | 670 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Hobostove::Line do
specify "taking the first n characters of the line" do
line = Hobostove::Line.new.tap do |line|
line.add(:cyan, "Eric: ")
line.add(:white, "howdy")
end
expect(line.first(3).to_s).to eq("Eri")
expect(line.first(8).to_s).to eq("Eric: ho")
... | true |
f29774e4bb36e81700a3b4588d983553b36588cd | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/rubocop-0.93.1/lib/rubocop/cop/style/numeric_predicate.rb | UTF-8 | 3,689 | 2.765625 | 3 | [
"Apache-2.0",
"CC-BY-NC-4.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen_string_literal: true
module RuboCop
module Cop
module Style
# This cop checks for usage of comparison operators (`==`,
# `>`, `<`) to test numbers as zero, positive, or negative.
# These can be replaced by their respective predicate methods.
# The cop can also be configured to do... | true |
9dd397c7718bbde47b9f10acbfb3dd2d57179ce5 | Ruby | LNewsome/gladiator | /lib/gladiator.rb | UTF-8 | 258 | 2.8125 | 3 | [] | no_license | class Gladiator
attr_accessor :name, :weapon
def initialize (name, weapon)
@name = name
@weapon = weapon
end
#
# def gladiator (@name, weapon)
#
# end
# def weapon.allow =
# [Spear, Club, Trident, Sword, Chains]
#
#
# end
end
| true |
6aa33048020bea52ca81754e4714037dea6a9bb7 | Ruby | jstoja/aoc | /2018/7/2.rb | UTF-8 | 1,700 | 3.078125 | 3 | [
"Unlicense"
] | permissive | def get_tree(filename)
data = {}
re = 'Step\ (.)\ .*\ step\ (.)\ can\ begin'
File.foreach(filename) do |line|
matches = line.chomp.match(re).to_a
parent = matches[1]
children = matches[2]
data[parent] = {parents: [], children: [], solved: false, started: -1} if data[parent].nil?
data[children]... | true |
22e0ba1e748b17658b3eca995a78539759179def | Ruby | railsfactory-pavani/mp1 | /pattern/pattern.rb | UTF-8 | 242 | 3.265625 | 3 | [] | no_license | puts "Enter the number of rows in pyramid of stars you wish to see "
n=gets.chomp.to_i
temp = n
for row in 1..n
for c in 1..temp
printf " "
end
temp = temp - 1
for i in 1..(2 * row-1)
printf "*"
end
printf "\n"
end
| true |
6d0f42ef6699096ec54a5bf2f4759d32654ab8e8 | Ruby | whtqqq/dosca-js | /lib/logwrite2.rb | UTF-8 | 1,513 | 2.640625 | 3 | [] | no_license | #!/usr/bin/ruby
class LogWrite2
@log = $stdout
def initialize( logfile=nil, num=2, size=1000000 )
if(logfile == nil)
logfile = File.basename(__FILE__) + ".log"
end
logfile_rename(logfile, num, size)
@log = open(logfile,"a")
@log.puts "***** Logging start at #{nowtime} pid=#{$$} *****"
... | true |
3ba66c0cdec43f9018cac889f5d31d51b16bcd50 | Ruby | conchyliculture/ruby-party | /lib/db.rb | UTF-8 | 1,937 | 2.53125 | 3 | [
"WTFPL"
] | permissive | # encoding: UTF-8
class PartyDB
require "sequel"
require "logger"
if not Object.const_defined?(:DB)
DB = Sequel.sqlite 'party.sqlite', :loggers => [Logger.new($stderr)]
end
Sequel::Model.plugin :force_encoding, 'UTF-8'
unless DB.table_exists?(:infos)
DB.create_table :infos do
... | true |
07780f3b6891f9c7fe5434f40fe6fee6cc2eb2ed | Ruby | Magmusacy/chess_v2 | /lib/pieces/king.rb | UTF-8 | 1,493 | 3.375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'piece'
require_relative '../modules/castling'
# Contains logic for King movement
class King < Piece
include Castling
def possible_moves(board)
moves = [horizontal_move(board, 1), horizontal_move(board, -1),
vertical_move(board, 1), vertical_move(bo... | true |
4bde2d7a2f35f26e33a0e4c6e74bd56fd3b6d99f | Ruby | mjamei/resemblance | /export_to_ggobi.rb | UTF-8 | 764 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'cgi'
records = []
STDIN.each do |line|
line =~ /(.*)"(.*)"/
records << { :points => $1.split(' '), :label => $2.strip }
end
puts <<EOF
<?xml version="1.0"?>
<!DOCTYPE ggobidata SYSTEM "ggobi.dtd">
<ggobidata count="1">
<data>
EOF
number_dimensions = records.first[:points].size
... | true |
f0878e6cb2c6f92b594784003949a20c7184ae29 | Ruby | jaredeh/jareds-web-player | /tests/features/step_definitions/host_steps.rb | UTF-8 | 1,429 | 2.984375 | 3 | [] | no_license | require File.join(File.dirname(__FILE__),'..','..','..','src','host.rb')
Given /^I create a new Host object with the hostname "([^\"]*)" the first parameter/ do |input|
@host = Host.new(input)
end
When /^I read from the .hostname parameter/ do
@hostname = @host.hostname
end
Then /^It should return a hostname of ... | true |
6cff41b19894ecab2d3652325001e78115e98714 | Ruby | tulioti/ruby-super-pry | /sandbox.rb | UTF-8 | 762 | 3.640625 | 4 | [] | no_license | require 'pry'
#when using binding.pry
# type 'c' or 'exit' to continue script execution
# type 's' to step into next line
# type 'p :line_num' to play a certain line
#i.e. to execute line 8, type p 8
# type 'exit!' to shut down pry.
# ENTER SANDBOX CODE BELOW:
# THEN EXECUTE IN TERMINAL: ruby sandbox.rb... | true |
e578c14a9af780779d02efdf7a3b96b989b25721 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/a12b4ec572f04d868e1ffb1388b07e84.rb | UTF-8 | 557 | 3.59375 | 4 | [] | no_license | class Anagram
def initialize input
@input = input.downcase
end
def match potentials
potentials.each.with_object([]) do |potential, matches|
matches << potential if anagram? potential
end
end
private
def anagram? potential
hashed_word == hashify(potential.downcase) && input != potent... | true |
daed7bbe7f3e61cdd98d918c7785498be8c55455 | Ruby | jonbrandenburg/BraveZealot | /lib/obstacle.rb | UTF-8 | 527 | 2.875 | 3 | [] | no_license | bzrequire 'lib/coord'
bzrequire 'lib/rect_methods'
module BraveZealot
class Obstacle
attr_accessor :coords
include RectMethods
def initialize(coords)
@coords = coords
end
def to_pdf(pdf = nil, options = {})
return if pdf.nil?
pdf.stroke_color Color::RGB::Red
... | true |
fef4f330c48126d07ed258c8def44c771f846a18 | Ruby | andrewkfiedler/ruby_stock_picker | /lib/stock_picker.rb | UTF-8 | 1,676 | 3.703125 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
# analyze a list of stock prices (in order of days) and find best days to buy / sell
# my thought is to just build a matrix of buy / sell and then find the max (parts will be nil since you can't sell in the past)
module StockPicker
# @param [Array<Integer>]
# @return [Array<Array<Inte... | true |
1b75495e2a00e2597ed8495740e58036106446f2 | Ruby | hdm/ruby-mtbl | /bin/rmtbl_create | UTF-8 | 2,373 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'mtbl'
require 'csv'
compression_types = {
'none': MTBL::COMPRESSION_NONE,
'snappy': MTBL::COMPRESSION_SNAPPY,
'zlib': MTBL::COMPRESSION_ZLIB,
'lz4': MTBL::COMPRESSION_LZ4,
'lz4hc': MTBL::COMPRESSION_LZ4HC
}
options = OpenStruct.new
... | true |
4f2b1f7cf60c34d6344b84680ad6006531834fe4 | Ruby | pcarmody/colt | /hamlet/threshold/dsl.rb | UTF-8 | 3,264 | 2.984375 | 3 | [] | no_license | class DSL
def initialize(&block)
instance_eval &block if block_given?
end
def self.attr_init *vals
vals.each { |val| class_eval "def #{val} init; @#{val} = init; end" }
out_string = '#{@' + vals.join('},#{@') + '}'
class_eval 'def to_s; "' + out_string + '"; end'
end
def self.attr_dsl name
... | true |
61d1e710693f6ddaa06d00d0f12ab3d5a73cf4ae | Ruby | victor1cs/programacao-ruby | /conceitos/06-estruturas_condicionais.rb | UTF-8 | 696 | 4.1875 | 4 | [] | no_license | #puts "Digite um número:"
#v1 = gets.chomp.to_i
#Condicional SE / IF
=begin
if v1 > 10 then
puts "O valor digitado é maior que 10!"
elsif v1 >= 5
puts "O valor é maior ou igual a 5(entre 5 e 10)"
else
puts "O valor digitado é menor que 5"
end
=end
=begin
unless v1 > 10
puts "O número digitado é menor ou igual a 10... | true |
1be230eda16f9ad0a0c1fbf9b282276f3aa6af85 | Ruby | criteo/consul-templaterb | /lib/consul/async/consul_template_render.rb | UTF-8 | 4,014 | 2.671875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'consul/async/utilities'
require 'em-http'
require 'erb'
module Consul
module Async
# Result of the rendering of a template
# .ready? will tell if rendering is full or partial
class ConsulTemplateRenderedResult
attr_reader :template_file, :output_file, :hot_reloaded, :ready, :modified, :last... | true |
e78f2216b6af4d8acae811279ecc48513f5752e9 | Ruby | dorkusprime/ruby-benchmarks | /string_concatenation.rb | UTF-8 | 455 | 2.9375 | 3 | [] | no_license | require 'benchmark'
n = 5000000
Benchmark.bmbm do |x|
a = 'string1 '
b = 'string2 '
c = 'string3 '
d = 'string4 '
e = 'string5 '
f = nil
x.report('+') {
n.times do
f = nil
f = a + b + c + d + e
end
}
x.report('+=') {
n.times do
f = nil
f = a
f += b
f += c
... | true |
11f6225b5b14d5a9dc51cde5c017b191511e03f2 | Ruby | tishchungoora/acceso-backend | /db/seeds.rb | UTF-8 | 1,829 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'csv'
# Clean up old seed data
BoardCard.destroy_all
Board.destroy_all
Card.destroy_all
Category.destroy_all
Behaviour.destroy_all
User.destroy_all
puts "Pre-existing data cleared"
# Load cards with categories. Assign corresponding parent categories
table = CSV.parse(File.read('./db/pecs.csv'), headers: tr... | true |
272b8983706db3826a590216ab16b11e67f47586 | Ruby | nixtrace/rmsg | /lib/rmsg/rabbit.rb | UTF-8 | 500 | 2.53125 | 3 | [
"MIT"
] | permissive | module Rmsg
class Rabbit
# @return [Bunny::Connection]
attr_reader :connection
# @return [Bunny::Channel]
attr_reader :channel
# On creation holds references to RabbitMQ via
# a Bunny connection and a Bunny channel.
def initialize
@connection = Bunny.new
@connection.start
... | true |
e09b895b6a07748a880220644747502b340cbbfc | Ruby | stef-codes/activerecord-tvland-online-web-ft-100719 | /app/models/actor.rb | UTF-8 | 495 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Actor < ActiveRecord::Base
has_many :characters
has_many :shows, through: :characters
has_many :networks
def full_name
"#{self.first_name} #{ self.last_name}"
end
def list_roles
#Output character_name - show_name
character_name = self.characters.collect { |character| character.name}
... | true |
45e82d6ff7485e557a95e3e6e7e32f944cde1416 | Ruby | Dwein9/project-euler-largest-prime-factor-web-1116 | /lib/oo_largest_prime_factor.rb | UTF-8 | 369 | 3.765625 | 4 | [] | no_license | # Enter your object-oriented solution here!
require 'prime'
class LargestPrimeFactor
def initialize(num)
@num = num
end
def number
factor = 2
prime_factor = 0
while factor <= @num
if @num % factor == 0 && Prime.prime?(factor)
@num /= factor
prime_factor = factor
end
... | true |
4706a8f85f6fe2029db8488980d44e946d0b1409 | Ruby | ppj/LearnRubyTheHardWay | /ex12.rb | UTF-8 | 228 | 2.546875 | 3 | [] | no_license | require 'open-uri'
open("http://ruby.learncodethehardway.org/book/ex12.html") do |f|
f.each_line {|line| puts line}
puts f.base_uri
puts f.content_type
puts f.charset
puts f.content_encoding
puts f.last_modified
end | true |
4db8cba8e0eeaf187b9d9ecde0e11badfb884a4f | Ruby | mcgraths7/TeamValor | /app/models/gym.rb | UTF-8 | 1,231 | 2.53125 | 3 | [] | no_license | class Gym < ApplicationRecord
has_many :users
has_many :user_pokemons, through: :users
has_many :pokemons, through: :user_pokemons
has_many :trainers, through: :users
has_many :user_pokemons, through: :users
has_many :pokemons, through: :user_pokemons
has_one :leader, through: :users # this association do... | true |
a3345dfd96fad6c2dfca13e2239e92d5de672b14 | Ruby | aldebaran2604/algorithms | /Burbuja/lib/main.rb | UTF-8 | 311 | 3.734375 | 4 | [] | no_license | def burbuja(array)
limit = (array.length-1)
while limit > 0
for i in 0..limit-1
if array[i] > array[i+1]
array[i],array[i+1] = array[i+1],array[i]
end
end
limit -= 1
end
array
end
arreglo = [10,5,4,30,3,2,1]
puts arreglo.to_s
arreglo = burbuja(arreglo)
puts arreglo.to_s | true |
80fea0331c48ead0f3911434f8dd56be540817a4 | Ruby | tcrane20/AdvanceWarsEngine | /Advance Wars Edit/Scripts/[160]CO_Kanbei.rb | UTF-8 | 1,605 | 2.890625 | 3 | [] | no_license | ################################################################################
# Class Kanbei
# Army: Yellow Comet Power Bar: x x x x X X X
#
# - 120/120 Units
# - 120% deployment costs
#
# Power: Morale Boost
# - 150/130 Units
# - 170/130 Units when counter attacking
#
# Super Power: Samurai Spirit
# - 1... | true |
63abf0c16cf86ba36751fbaf52468be39b4ead11 | Ruby | neutral2010/fB_ruby_iga | /ch_7/4.rb | UTF-8 | 1,787 | 3.828125 | 4 | [] | no_license | puts '問6'
def price(item:)
case item
when 'コーヒー'
puts 300
when 'カフェラテ'
puts 400
end
end
price(item: 'コーヒー')
price(item: 'カフェラテ')
puts "問6の別解答"
def price(item:)
items = { "コーヒー" => 300, "カフェラテ" => 400 }
items[item]
end
puts price(item: "コーヒー")
puts price(item: "カフェラテ")
puts "問6の別解答の別回答"
def p... | true |
9e400456f3798618a0ec71384bc2ba5fc0876e89 | Ruby | tatsuio/dialogue | /lib/dialogue/conversation.rb | UTF-8 | 1,813 | 2.640625 | 3 | [
"MIT"
] | permissive | require "dialogue/storable"
module Dialogue
class Conversation
include ConversationOptions
include Storable
attr_accessor :channel_id, :team_id, :user_id
attr_reader :message, :steps, :templates
def initialize(template=nil, message=nil, options={})
guard_options! options
@templates... | true |
eb4fd0422904736bf13e2103f700f114d69bc77f | Ruby | koray-eren/passwordGeneratorRuby | /passwordGenerator.rb | UTF-8 | 998 | 3.375 | 3 | [] | no_license | INTERACTIVE = false
passLength = 20
uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lowercase = uppercase.downcase
specials = "!@#$%^&*()_+-=';:,.<>/?[]{}"
numbers = "1234567890"
# get desired password length from user + validation
if INTERACTIVE
print "Enter a password length: "
passLength = ""
passLength = get... | true |
26211f2b3dc49023bf0943057834a1f260468889 | Ruby | ram535ii/exercism | /ruby/roman-numerals/roman_numerals.rb | UTF-8 | 1,014 | 3.34375 | 3 | [] | no_license | require "pry"
class Fixnum
VALUES = {
0 => {
1 => "I",
5 => "V",
10 => "X"
},
1 => {
1 => "X",
5 => "L",
10 => "C"
},
2 => {
1 => "C",
5 => "D",
10 => "M"
},
3 => {
1 => "M"
}
}.freeze
def to_roman
result = ""
dig... | true |
f707d085743aa3950974b1c6ca563ab6d0915ec0 | Ruby | ajignacio/exam | /word_cycler.rb | UTF-8 | 771 | 3.15625 | 3 | [] | no_license | class WordCycler
def cycle_sentence(word)
_word_split = word.split(' ')
_arry_word = []
(1.._word_split.length).each do |w|
_arry_word.push(_word_split.reject(&:empty?).join(' '))
_word_split.push(_word_split[0])
_word_split.shift(1)
end
_arry_word
end
def alpha_reverse... | true |
88c37e93ba65b843e80118d7c6bbbd26f0a1d1af | Ruby | dkremez/sp_ruby_app | /lib/log/printer.rb | UTF-8 | 726 | 2.765625 | 3 | [] | no_license | # frozen_string_literal: true
require 'terminal-table'
module Log
# Prints calculated page visits statistic
class Printer
def initialize(statistic, output: $stdout)
@statistic = statistic
@output = output
end
def call
puts visits_table
puts uniq_views_table
end
privat... | true |
6d99f086a32827e036acb2f34ec5e5076e784439 | Ruby | jakenbear/Sam_Ruby_Scripts | /152 - ASM_Window_CashBox.rb | UTF-8 | 2,361 | 2.78125 | 3 | [] | no_license | #==============================================================================
# ** Always Sometimes Monsters: Window_CashBox
#------------------------------------------------------------------------------
# This is the cash box for the main menu in ASM
#===============================================================... | true |
81a906a1f126a3f5e3fe7e85f1a39a1663ef3e54 | Ruby | jp-fsstudio/android-template | /scripts/find_version.rb | UTF-8 | 904 | 3.09375 | 3 | [] | no_license | # This script updates AndroidManifiest.xml file
# - Updates android:versionCode adding +1 to the version
# Reading arguments
if ARGV.length < 1
puts 'File as argument required'
exit
end
# Reading file
fileName = ARGV[0]
if File.exists?(fileName)
begin
# Read the file
manifiest = File.read(fileName)
... | true |
e8d797423d9445cb4d0e3799f20dd219649d4073 | Ruby | komattio/test | /sekisetu.rb | UTF-8 | 55 | 2.828125 | 3 | [] | no_license | h1 = gets.to_i
h2 = gets.to_i
ans = h1 - h2
puts ans
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.