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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4916e18874c2659fbd727f3b650a961e6973391e | Ruby | DevRajeev4522/Ruby | /loop.rb | UTF-8 | 284 | 3.578125 | 4 | [] | no_license | #more loop in ruby
#times loop
# 8.times do puts "#{"hello"}" end
# 3.upto(7) do |i| puts "hello #{i}" end
# "a".upto("j").each do |x| puts x end
# Down to
#downti will not work on string
7.downto(2) do |y| puts y end
#step mathod
5.step(30,5) do |i| puts "#{i}" end | true |
08205d749a557e2d11cd346e710b35bde9595364 | Ruby | YaponEran/ruby_second | /mont_day_count.rb | UTF-8 | 508 | 3.578125 | 4 | [] | no_license | months = {
0 => 31,
1 => 28,
2 => 31,
3 => 30,
4 => 31,
5 => 30,
6 => 31,
7 => 31,
8 => 30,
9 => 31,
10 => 30,
11 => 31
}
puts "Please type a year: "
year = gets.chomp.to_i
puts "Please type a month: "
month = gets.chomp.to_i
puts "Please type a day: "
day = gets.chomp... | true |
aab996fe6e844b019666b141011293ce3438f6a9 | Ruby | andrewtdinh/RubyPractice | /timeToEat.rb | UTF-8 | 204 | 2.9375 | 3 | [] | no_license | require 'time'
File.open(ARGV[0]).each_line do |line|
phrases = line.split(' ').each do |timeStr|
Time.parse(timeStr)
end
phrases.sort! {|a, b| b <=> a}
puts phrases.join(' ')
end
| true |
61f79ed1460e447adc84962fa7db4f5857990ddb | Ruby | estevao2012/defRefactorRuby | /refactor/types/move_class.rb | UTF-8 | 669 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | module Refactor
class MoveClass < BaseRefactor
def run
@first_klasses.each do |klass_v1|
@second_klasses.each do |klass_v2|
if filter klass_v1, klass_v2
puts "Refactor MoveClass #{klass_v1.name} to #{klass_v2.name}"
@counter+=1
end
end
e... | true |
cf7fe940e0c7d1b535a24479b516cbffb6c8acc5 | Ruby | einarmn/job_finder | /job_finder.1.rb | UTF-8 | 897 | 2.875 | 3 | [] | no_license | require "httparty"
require "nokogiri"
def list(field)
link = "https://miami.craigslist.org/search/#{field}"
response = HTTParty.get("#{link}")
dom = Nokogiri::HTML(response.body)
job_titles = []
dom.css('a.hdrlnk').each_with_index do |e,i|
job_titles << (i+1).to_s + "- " + e.content + "\n" + "\t" + e["href"]
en... | true |
2224c7b18b3be54920b6821e4c7351a82a493c21 | Ruby | empjustine/imageologia | /lib/dicom-send-client.rb | UTF-8 | 426 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'dicom'
# DICOM Client
# ============
if ARGV[0][/dicom_client\.rb/]
ARGV.shift
ARGV.shift
end
host = ARGV.shift
ARGV.each do |examination|
examination_object = DICOM::DObject.read(examination)
unless examination_object.read?
puts "Invalid DICOM @ #{examination}"
next
... | true |
0665105812a599ad1ca9b6aab60cd07a8c100eab | Ruby | brightbox/isitruby19 | /vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb | UTF-8 | 890 | 2.875 | 3 | [
"MIT"
] | permissive | module Spec
module Matchers
class << self
attr_accessor :last_matcher, :last_should
def clear_generated_description
self.last_matcher = nil
self.last_should = nil
end
def generated_description
return nil if last_should.nil?
"#{last_should} #{last_descripti... | true |
70b53f05ae08d24481974f4ad5585f082e888c0f | Ruby | vsanta/Tripapalooza | /spec/models/traveler_spec.rb | UTF-8 | 3,299 | 2.5625 | 3 | [] | no_license | require "spec_helper"
describe Traveler do
before(:each) do
@traveler = Factory(:traveler)
@traveler.should have(:no).errors
end
describe "authenticate method" do
it "should return nil on email/password mismatch" do
wrong_password_traveler = Traveler.authenticate(@traveler[:nick], "wrong... | true |
c7881855d7776d9e2dbd9cd6e60686053b2f003e | Ruby | Katie-McDonagh/oysercard_pc | /lib/oystercard.rb | UTF-8 | 1,008 | 3.40625 | 3 | [] | no_license | require_relative 'journey'
class OysterCard
MINBALANCE = 1
MAXBALANCE = 90
MINCHARGE = 1
attr_reader :balance, :journeys, :current_journey
def initialize(current_journey = Journey.new)
@balance = 0
@journeys = []
@current_journey = current_journey
end
def top_up(number)
raise "Exceeds... | true |
44cc1f46fc1c0f64aeb6b109bad5fc49c55313fa | Ruby | vjoel/cgen | /examples/cshadow-point.rb | UTF-8 | 1,113 | 2.59375 | 3 | [
"Ruby"
] | permissive | #!/usr/env/bin ruby
require 'cgen/cshadow'
class Point
include CShadow
###
shadow_attr_accessor\
:i => "int ii",
:d => "double d"
shadow_attr_reader :obj => Object
end
class SubTest < Test
shadow_attr :hidden_array => Array
shadow_attr_accessor\
:foo => "char *foo",
:bar => Symbol,
... | true |
60f4992a5f94bd33d21802c7c19870c1866613bd | Ruby | reidjs/leet | /climbing_stairs.rb | UTF-8 | 303 | 3.40625 | 3 | [] | no_license | #Cheated!
def climb_stairs(n)
memoized = Hash.new(0)
solve(0, n, memoized)
end
def solve(i, n, memoized)
return 0 if i > n
return 1 if i === n
return memoized[i] if memoized[i] > 0
memoized[i] = solve(i + 1, n, memoized) + solve(i + 2, n, memoized)
memoized[i]
end
p climb_stairs(4) | true |
cbd7dfdd0c896609ed7a90c2766ff029b4d7152d | Ruby | poncheeto/basic-ruby-projects | /stock_picker.rb | UTF-8 | 640 | 4.03125 | 4 | [] | no_license | # frozen_string_literal: true
def stock_picker(array)
return unless array.index(buy(array)) > array.index(sell(array)) # Check if buy index greater than sell index
buy = array.min(2).last
profit = array.index(buy), array.index(sell(array))
p profit
end
def sell(array)
if array.first == array.max # Check if... | true |
c9a1306a39fe2a2f55c1332e2ae3aea3335b97e7 | Ruby | thebkbuffalo/simple_thread_test | /reimburse_me.rb | UTF-8 | 5,984 | 3.0625 | 3 | [] | no_license | require 'date'
require 'pry'
@sets = [
[
{project: 1, cost: 'low', sd: '9/1/15', ed: '9/1/15'}
],
[
{proj: 1, cost: 'low', sd: '9/1/15', ed: '9/1/15'},
{proj: 2, cost: 'high', sd: '9/2/15', ed: '9/6/15'},
{proj: 3, cost: 'low', sd: '9/6/15', ed: '9/8/15'}
],
[
{proj: 1, cost: 'low', sd: '... | true |
de5edd98a7ecab2435b9033489fb645213d1bbe9 | Ruby | zshnr/FAAST | /lib/station.rb | UTF-8 | 684 | 3.484375 | 3 | [] | no_license | class Station
attr_accessor :trains, :passengers
def initialize
@passengers = []
@trains = []
end
def passengers_count
@passengers.count
end
def touch_in(passenger)
if @passengers.include? passenger
fail 'Youve already touched in!'
elsif passenger.balance < 2
fail 'You do ... | true |
1721c2f8fe7724a373b0a164666ea28254d3be03 | Ruby | aeakett/ArchiveBot | /cogs/archive_url_discovery/ia_url_generator.rb | UTF-8 | 3,631 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'json'
require 'net/http/persistent'
require 'uri'
require 'zlib'
module ArchiveUrlDiscovery
##
# Finds URLs for ArchiveBot-generated WARCs on archive.org.
#
#
# Theory of operation
# -------------------
#
# This crawler is fairly elaborate. It downloads the first 32 kB of a
# gzip-compresse... | true |
def0c4d98bc64e9e0998d3ace97d8a911e6fddca | Ruby | ytjmt/at_coder | /abc/abc151/c/logic.rb | UTF-8 | 554 | 3.125 | 3 | [] | no_license | N, M = gets.chomp.split(' ').map(&:to_i)
if M == 0
puts ('0 0')
exit
end
hash = {}
M.times do
pi, si = gets.chomp.split(' ')
if hash.has_key?(pi)
if si == 'AC' || hash[pi][:ac]
hash[pi][:ac] = true
else
hash[pi][:wa_count] += 1
end
else
if si == 'AC'
hash[pi] = { ac: true, ... | true |
71f23ea4728cee5977d295152e27d45ef6877a11 | Ruby | fransiti/quran-android | /scripts/fetch_trans.rb | UTF-8 | 2,407 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'sqlite3'
require 'json'
require 'uri'
def fix(line)
orig = line.dup
if line.include? '11|82|82|'
line.sub! '82|82', '82'
elsif line.include? '要|见'
line.sub! '要|见', '要见'
elsif line.include? '"|'
line.sub! '"|', '"'
elsif line.incl... | true |
735f88906980f5d12bb7d51209a595d66d61e026 | Ruby | soroz30/codewars | /easyline.rb~ | UTF-8 | 423 | 3.453125 | 3 | [] | no_license | def easyline(n)
if n == 0
return 0
elsif n == 1
return 1
end
a = [[1, 1]]
(0...n-1).each do |i|
a[i+1] = []
a[i].each.with_index {|ele, index| index == 0 ? a[i+1][index] = 1 : a[i+1][index] = ele + a[i][index-1]}
a[i+1].push(1)
end
p a.last
p a.last.map {|ele| ele * ele}.inject(:+)
... | true |
316e74e1e8da38d043d633943e6cb33ab56ae565 | Ruby | shanti-uva/ffi-icu | /spec/locale_spec.rb | UTF-8 | 9,036 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: UTF-8
require 'spec_helper'
module ICU
describe Locale do
describe 'the available locales' do
subject { Locale.available }
it { expect(subject).to be_an Array }
it { expect(subject).not_to be_empty }
it { expect(subject.first).to be_a Locale }
end
describe 'the avai... | true |
50fbd008712e5f714b1e84ad85c4be258627e4da | Ruby | dwightdegroff/sample_app | /exercise4.6.2.rb | UTF-8 | 167 | 3.40625 | 3 | [] | no_license | # Exercise 4.6.2
# Dwight DeGroff
# IS698
class String
def shuffle
self.split('').shuffle().join()
end
end
# Example of String shuffle method
puts "foobar".shuffle
| true |
f3c7e0e7cfb604345ac1a6d66ce7c7e697fa837a | Ruby | srishtinath/ruby-oo-relationships-practice-art-gallery-exercise-nyc01-seng-ft-042020 | /app/models/artist.rb | UTF-8 | 961 | 3.25 | 3 | [] | no_license | class Artist
attr_reader :name, :years_experience
@@all = []
def initialize(name, years_experience)
@name = name
@years_experience = years_experience
Artist.all << self
end
def self.all
@@all
end
def paintings
Painting.all.select {|painting| painting.artist == self}
end
def gal... | true |
a27be0ae7d4bb2dd85fce82b5975c506a1465e78 | Ruby | miwarin/hyuki-designpattern-multithread | /05 Producer-Consumer/Producer-Consumer.rb | UTF-8 | 2,823 | 3.359375 | 3 | [] | no_license | # coding: utf-8
#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
#
# Producer-Consumer - わたしが作り、あなたが使う
#
require 'thread'
require 'monitor'
class Table
def initialize(count)
@buffer = Array.new(count)
@head = 0
@tail = 0
@count = 0
@lock = Monitor.new()
@cond = @lock... | true |
a179c685207e0cdac8327961b6275c5cf6a9e5ef | Ruby | troygnichols/exercism | /ruby/isogram/isogram.rb | UTF-8 | 146 | 3.375 | 3 | [] | no_license | class Isogram
def self.isogram?(input)
input.downcase.scan(/\w/).then {|letters|
letters.count == letters.uniq.count
}
end
end
| true |
5208ce5f9a7fd73944f3a80e2030058c29587857 | Ruby | Carmer/Linked_List | /recursive_linked_list.rb | UTF-8 | 845 | 3.34375 | 3 | [] | no_license | class LinkedList
attr_reader :head
def count(node = head)
if node.nil?
0
else
1 + count(node.next_node)
end
end
def push(data, node = head)
if node.nil?
@head = Node.new(data)
else
if node.next_node.nil?
node.next_node = Node.new(data)
else
pu... | true |
82c079f78a908c9c9fbf3f116f5e8ddf30520120 | Ruby | ahirata/flight_aggregator | /lib/flight_aggregator.rb | UTF-8 | 2,418 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'date'
require 'erb'
require 'money'
require 'money/bank/google_currency'
module FlightAggregator
class Settings
attr_accessor :trip, :mail, :sites
def initialize
Money.default_bank = Money::Bank::GoogleCurrency.new
Money.default_currency = Money::Currency.new("BRL")
Money.use_i18n... | true |
946a2a3bf4c027627185417d2e9d76fce8bbf2dd | Ruby | yvoloshin/Coding-challenges | /is_obstructed2.rb | UTF-8 | 1,891 | 4 | 4 | [] | no_license | # Function accepts location of piece 1, desired new location (destination) of piece 1,
# and location of piece 2. Returns true if the path between piece 1 and destination
# is a straight line and is obstructed by piece 2.
# Locations are shown using x/y 0-7 notation.
def is_obstructed?(piece1_loc, destination)
#... | true |
1d5faaf96b2d7dffc707e46d655c8fbcdadba0f4 | Ruby | therezajs/CodingDojo | /Rails/basic_assignment_2.rb | UTF-8 | 3,125 | 3.5 | 4 | [] | no_license | # Rails - Basic assignment 2
#
# Start a new project (the name of the project should be 'dojo_ninjas')
# Create appropriate tables/models using "rails generate model", "rake db:create", and "rake db:migrate"
# Using ruby console
# Create 3 dojos (insert some blank entries just to make sure it's allowing you to insert ... | true |
af21e19303e331745932640e97e8f909080afc4c | Ruby | PladEnt/country_holiday_list | /lib/country_holiday_list/cli.rb | UTF-8 | 2,269 | 3.796875 | 4 | [
"MIT"
] | permissive |
class CLI
attr_accessor :user
def initialize(user)
@user = user
end
def welcome
puts "|Welcome to Country Holiday List|"
puts "|-------------------------------|"
puts "|Please enter the countrys code |"
puts "|you want to know about. |"
puts "|-------------------------------|"
... | true |
5ca4c2f4100cd479b3bc54939514de98e5e87657 | Ruby | cyantis/programming_languages-online-web-prework | /programming_languages.rb | UTF-8 | 797 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
languages = {
:oo => {
:ruby => {
:type => "interpreted"
},
:javascript => {
:type => "interpreted"
},
:python => {
:type => "interpreted"
},
:java => {
:type => "compiled"
}
},
:functional => {
:clojure => {
:type => "compiled"
... | true |
989ced5b97aa7889b9e9cc4e4f63e57df957c537 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/9b741c40b7ee4185a8f12d783b629c79.rb | UTF-8 | 305 | 3.109375 | 3 | [] | no_license | class Hamming
def self.compute(strandA, strandB)
length = [strandA, strandB].min.length - 1
data = strandA.split('')[0..length].zip(strandB.split('')[0..length])
differences = data.collect do |point|
1 if point[0] != point[1]
end
differences.compact.reduce(0,:+)
end
end
| true |
242000f05c912dda5ebc6f3ab7d9a4113097c69d | Ruby | cnmillar/animal_inheritance | /bat.rb | UTF-8 | 674 | 3.234375 | 3 | [] | no_license | require './bat.rb'
require './fly_module.rb'
class Bat < Mammal
include Flight
def initialize(num_legs, bat_type, common_name, scientific_name, weight, avg_length, color)
super(num_legs, common_name, scientific_name, weight, avg_length, color)
@bat_type = bat_type
end
def hunt
if @bat_type.downcase =... | true |
a4f111ea76347ee358b775b6de51d63abbe5c6ad | Ruby | pulibrary/figgy | /app/jobs/ingest_intermediate_file_job.rb | UTF-8 | 4,040 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Class for jobs which ingest files as intermediate files and append them todo
# an existing resource
class IngestIntermediateFileJob < ApplicationJob
# Execute the job
# @param [String] file_path the path to the file being ingested
# @param [String] file_set_id the ID of the reso... | true |
8bc64263e99b4cb81e3eb77799877679957bf7b4 | Ruby | BernH4/ruby-programming | /07_mastermind.rb | UTF-8 | 3,301 | 4.28125 | 4 | [] | no_license | "
Level: Easy
- Set an array ['R', 'G', 'B', 'Y', 'O', 'W', 'V', 'P'] which represents 8 colours
- The computer picks 4 random colours (no duplicate colours)
- The player gets 10 chances to guess the correct number
- The program evaluates the player's guess:
- 1 point is given if the colours exist on the computer ... | true |
8ade2875eddc5f1a931847e0fd7cac907b7bb5ff | Ruby | eashiyer/Code-Spectra | /lib/tasks/update_fieldstr.rake | UTF-8 | 2,057 | 2.578125 | 3 | [] | no_license | namespace :database do
desc "Rake task to to convert array to hash in field_str field"
task :update_fieldstr => :environment do
ActiveRecord::Base.transaction do
puts "Updating database field"
update_fieldstr
puts "\nUpdating Done"
end
end
end
def update_fieldstr
records = DataSource.all
i = 0
j =... | true |
914339e8d0fc58c2811be18050300645962a0284 | Ruby | scottcsims/SeleniumFury | /lib/selenium_fury/selenium_web_driver/page_object_components.rb | UTF-8 | 5,274 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #/* Copyright (c) 2010 HomeAway, Inc.
# * All rights reserved. http://www.homeaway.com
# *
# * Licensed under the Apache License, Version 2.0 (the "License");
# * you may not use this file except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.apache.org/licenses/LIC... | true |
e0862fcbe074b57393faed49a877447079cee24f | Ruby | anders-larsson/puppet-nonrootlib | /lib/puppet/parser/functions/is_url_valid.rb | UTF-8 | 605 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | require 'uri'
module Puppet::Parser::Functions
# is_url? returns a boolean if the url is valid
newfunction(:is_url_valid, :type => :rvalue) do |args|
raise(Puppet::ParseError, "is_url_valid(): Wrong number of arguments " +
"given (#{args.size} for 1)") if args.size < 1
url = args[0]
# this mon... | true |
ac32e62fae42c76b54744212e35e1842970d4420 | Ruby | maissimples/maily | /lib/maily/email.rb | UTF-8 | 2,282 | 2.75 | 3 | [
"MIT"
] | permissive | module Maily
class Email
attr_accessor :name, :mailer, :arguments, :template_path, :description
def initialize(name, mailer)
self.name = name.to_s
self.mailer = mailer
self.arguments = nil
self.template_path = mailer
self.description = nil
end
def ... | true |
e306e5e9308cf2b5ed9ef2ea4b297d06333e99f8 | Ruby | datafirm/can_has_auth_core | /lib/can_has_auth_core/auth_model.rb | UTF-8 | 3,165 | 2.578125 | 3 | [
"MIT"
] | permissive | module AuthModel
def self.included(base)
base.send(:include, InstanceMethods)
base.send(:extend, ClassMethods)
end
module InstanceMethods
def authenticated?(password)
crypted_password == encrypt(password)
end
# before filter
def encrypt_password
return if passwor... | true |
a67517ef4e41ae2fe9bcf13bd6a57e1aca1a5df4 | Ruby | lolapolly/traveltetris | /db/seeds.rb | UTF-8 | 3,296 | 2.71875 | 3 | [] | no_license | require 'time'
require 'open-uri'
require 'json'
puts "cleaning"
Flight.destroy_all
City.destroy_all
puts "seeding"
# cities = ["Amsterdam", "Bali", "Barcelona", "Belo Horizonte", "Berlin", "Bordeaux", "Brussels", "Buenos Aires", "Cali", "Casablanca","Chengdu","Copenhagen","Kyoto","Lausanne","Lille","Lisbon","London"... | true |
6e1f582b67b423849437d09b7f5a6f5c6d601382 | Ruby | oephi/simpsons_death_match | /models/simpsons_death_match.rb | UTF-8 | 2,112 | 3.5 | 4 | [] | no_license | require 'faker'
require 'espeak'
require 'rainbow'
require_relative 'models/character'
# require_relative 'logic'
@simpsons_character = Character.new(10, Faker::Simpsons.character)
@player = Character.new(10)
def speak(input)
speech = ESpeak::Speech.new("#{input}", speed: 120)
speech.speak
end
def hit... | true |
a810c0548b1f4ca191343ad2eebd528295c806df | Ruby | cha63506/vnctools | /spec/vnctools/server_pool_spec.rb | UTF-8 | 2,119 | 2.546875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path("../../spec_helper", __FILE__)
module VncTools
describe ServerPool do
let(:server) { double(Server, :start => nil, :stop => nil, :dead? => false) }
let(:fake_server_class) { double(:new => server)}
let(:pool) { ServerPool.new(3, fake_server_class) }
it "creates 3 instances ... | true |
a75671a62983af6a1de4348614742ae01b829a25 | Ruby | showma0734/atcoder_beginner154 | /B.rb | UTF-8 | 600 | 3.53125 | 4 | [] | no_license | #問題: https://atcoder.jp/contests/abc154/tasks/abc154_b
def valid?(s)
return false unless s.is_a?(String)
return false if s.downcase != s
return false if s.downcase == s.upcase
return false if s.length < 1 || s.length > 100
true
end
def miss_you(s)
return nil unless valid?(s)
s.gsub(/[a-z]/,... | true |
855b94e81a509dbcf1fb8e23d14aa35be5d74765 | Ruby | MuseumAPI/museum_provenance-1 | /test/parsers/sale_data_parser_test.rb | UTF-8 | 3,581 | 3 | 3 | [
"MIT"
] | permissive | require_relative "../test_helper.rb"
describe Parsers::SaleDataParser do
let(:p) {Parsers::SaleDataParser.new}
it "generically works" do
begin
results = p.parse("(stock no. 1, for $100)")
results[:stock_number].must_equal "stock no. 1"
results[:purchase][:currency_symbol].must_equal "$"
... | true |
d31e0ed47f5ec74d23f01060f600ced13dfcd08c | Ruby | if1live/happy-birthday-waifu | /spec/lib/anime-character-db-crawler/character_spec.rb | UTF-8 | 5,756 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'anime-character-db-crawler'
def get_filepath(filename)
html_dir = File.join(
File.dirname(__FILE__),
'..',
'..',
'testdata',
'animecharacterdatabase')
file_path = File.join(html_dir, filename)
return file_path
end
describe AnimeCharacterDB::CharacterData do
# 구현은 다른 클래스에 분리되어있기 떄문... | true |
3cf982c8ddb5efecd945bb88a63f204d8184c786 | Ruby | klu-aislenet/tts_ruby | /movie.rb | UTF-8 | 420 | 3.4375 | 3 | [] | no_license | class Movie
def initialize (name, year, director, rating)
@name, @year, @director, @rating = name, year,director,rating
end
def name
@name
end
def year
@year
end
def director
@director
end
def rating
@rating
end
end
newmovie = Movie.new('godfather', 'xxxx','diector_who',5)
puts "#{newmovie.n... | true |
a05e28c00413adf16588fc0ce546508147881eb8 | Ruby | unagiootoro/RGSS_MZ | /rgss/scripts/src/Scene_Name.rb | UTF-8 | 3,417 | 2.921875 | 3 | [] | no_license | #==============================================================================
# ■ Scene_Name
#------------------------------------------------------------------------------
# 名前入力画面の処理を行うクラスです。
#==============================================================================
class Scene_Name
#---------------... | true |
73739511df0c03b0aab26bdcc3302bf361c33e30 | Ruby | wojkly/ruby-exercises | /project-substrings/lib/substrings.rb | UTF-8 | 551 | 3.6875 | 4 | [
"MIT"
] | permissive | class Substrings
def get_substrings(word, dict)
res = {}
dict.each do |substring|
count = 0
0.upto(word.length - substring.length) do |start_index|
if word[start_index, substring.length].upcase == substring.upcase
p word[start_index, substr... | true |
a0f5c67a612d1fd3ed193bd73ab8d935c30dee85 | Ruby | chrisadames/101_programming_foundations | /small_problems/easy_8/get_the_middle.rb | UTF-8 | 623 | 4.3125 | 4 | [] | no_license | =begin
Write a method that takes a non-empty string argument, and returns the middle
character or characters of the argument. If the argument has an odd length, you
should return exactly one character. If the argument has an even length, you
should return exactly two characters.
=end
def center_of(string)
stri... | true |
2c58f9be05f4f3f91682eb73f1f341c1da0e83e1 | Ruby | MrRadish/salama | /lib/virtual/instructions/set.rb | UTF-8 | 459 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Virtual
# class for Set instructions, A set is basically a mem move.
# to and from are indexes into the known objects(frame,message,self and new_message),
# these are represented as slots (see there)
# from may be a Constant (Object,Integer,String,Class)
class Set < Instruction
def initialize fro... | true |
b6c02d818a613ea7494e1fbab1648815631381cd | Ruby | jakeb4shelby/LearnRuby | /Exercises/greeting_through_methods_p2.rb | UTF-8 | 105 | 2.84375 | 3 | [] | no_license | def hello
"Hello"
end
def world
" world!"
end
def greeting
hello + world
end
puts greeting | true |
2327a7fe8041fa75e3c96fac54e6dd54532f287c | Ruby | Yuebai0724/compiler-simulator | /function.rb | UTF-8 | 578 | 3.171875 | 3 | [] | no_license |
class Function
attr_accessor :code, :num_vars, :num_labels, :symtab
def initialize
@code= ""
@num_vars= 0
@num_labels= 0
@symtab= {}
end
def new_var
@num_vars+=1
return "local["+@num_vars.to_s+"]"
end
def new_label
@num_labels+=1
return "L"+... | true |
ed21a9bc242ebb8ca84f0c65e48533269b4c5821 | Ruby | ifyouseewendy/artichoke | /mruby-sys/vendor/mruby-bc7c5d3/discount.rb | UTF-8 | 3,362 | 2.828125 | 3 | [
"MIT",
"MPL-2.0"
] | permissive | # The TS version is here
# https://github.com/Shopify/runtime-assembly-scripts/blob/ffc92afed871d7c9b82f6fa7999a2efc5fc35a91/src/discounts-extension/new-vape.ts
ALL_TAGS = ['bulknaked', 'BULKSALTE', 'BULKGFALLS', 'BULKANML', 'BULKBAR', 'BULKBEARD']
class Pair
attr_reader :first, :second
def initialize(first, second... | true |
1fa6dcbafaed96a1397a3d8d0e59abf125f3f6e8 | Ruby | OpenLEAD/bundles-rosa | /test/scripts/test_autoscan_state_machine.rb | UTF-8 | 7,716 | 2.53125 | 3 | [] | no_license | require 'Qt4'
require './scripts/autoscan_state_machine'
require 'minitest/autorun'
require 'minitest/spec'
require 'flexmock/test_unit'
class Minitest::Test
include FlexMock::ArgumentTypes
include FlexMock::MockContainer
end
describe AutoscanStateMachine do
attr_reader :pan_range, :tilt_range, :machine
... | true |
89ac60b6d31c765917424744ec22cafa67c8986c | Ruby | calandula/eSenior-Backend | /app/controllers/pleasure_controller.rb | UTF-8 | 1,901 | 2.703125 | 3 | [] | no_license | class PleasureController < ApplicationController
def createGusto
if Pleasure.where(:title => params[:title]).exists?
render json: {status: 'ERROR', message: 'Pleasure already exist'}, status: :unprocessable_entity
else
Pleasure.create({
:title => params[:title]
... | true |
7dae28f4e3b076a29b95369a361db1cca545ac86 | Ruby | groman-me/airbrake-explorer | /spec/airbrake_explorer/core_ext/hash_spec.rb | UTF-8 | 1,148 | 2.75 | 3 | [] | no_license | require './spec/spec_helper'
describe 'Hash' do
describe '#filter!' do
subject do
{
white: :val, black: :val,
nested: { white: :val, black: :val,
deep_nested: { white: :val, black: :val } }
}
end
let(:filter) do
{ white: true, nested: { white: :yes, de... | true |
4af0f5e9b75900f1a16fe9bbb02ee9382e51d01e | Ruby | adrienbourgeois/eatme | /spec/lib/instagram_listener_spec.rb | UTF-8 | 1,662 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
require 'instagram_listener'
include InstagramListener
# TODO: refactor
describe "InstagramListener" do
let(:google_result) { {
vicinity: "3 Square st",
name: "Chez Adrien",
types: "[\"Restaurant\"]",
latitude: '-34.0',
longitude: '151.0',
google_id: 100,
city_cod... | true |
cd586d2252edec1d8d2ab856f78698b89f10b7ea | Ruby | betodute/badges-and-schedules-dumbo-web-060319 | /conference_badges.rb | UTF-8 | 709 | 3.765625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(attendees)
string_storage = []
attendees.each do |name|
string = "Hello, my name is #{name}."
string_storage.push(string)
end
return string_storage
end
def assign_rooms(attendees)
string_stora... | true |
53cf4326a254b08171775b4aa4e47bf92dc83d8b | Ruby | RottenRoost3r/pizza-app | /pizza_app.rb | UTF-8 | 4,661 | 3.34375 | 3 | [] | no_license | def size()
size = ["small", "medium", "large"]
size[0..2]
end
def meats ()
meats = ["pepperoni", "sausage" ,"ham", "bacon"]
meats[0..3]
end
def crust ()
crust = ["normal", "thin", "stuffed", "deep dish"]
crust[0..3]
end
def sauce()
sauces = ["marinara", "spicy", "ranch"]
sauces[0..2]
end... | true |
98995737ca6d17401b86a240ebcadc759a36305e | Ruby | LoboNeves/TreinamentoIN-ProjetoFinal | /app/models/product.rb | UTF-8 | 668 | 2.703125 | 3 | [] | no_license | class Product < ApplicationRecord
#Metodo para pesquisar produto específico
validates :name, :price, :description, :category, presence: true
#scope :search, ->(query) { where("name LIKE ?", "%#{query}%")} Outro jeito de fazer, mas priferi o de baixo por achar mais compreensível
def self.search(search) #... | true |
3053a36743b528b24b496beee482c6add6265750 | Ruby | relteq/simx | /dpool/lib/pems-daily.rb | UTF-8 | 2,296 | 2.84375 | 3 | [] | no_license | require 'dpool/base'
class DataPool
# PeMS data from yesterday is at the URL:
#
# http://pems.dot.ca.gov/dbx/station_5min_summary_YYYY_MM_DD.txt.bz2
#
# where YYYY is year, MM - month, DD - day. For example,
#
# http://pems.dot.ca.gov/dbx/station_5min_summary_2011_09_19.txt.bz2
#
# These files ... | true |
ffaaf1cf6b2cde260ac8b0a81cd7e885541132d4 | Ruby | houston/attentive | /test/duration_test.rb | UTF-8 | 1,697 | 2.84375 | 3 | [
"MIT"
] | permissive | require "test_helper"
class DurationTest < Minitest::Test
context "#after" do
should "work" do
assert_equal date(2017, 3, 15), duration(years: 1).after(date(2016, 3, 15))
assert_equal date(2016, 4, 15), duration(months: 1).after(date(2016, 3, 15))
assert_equal date(2016, 3, 16), duration(days... | true |
28a081877e4b41a48d6330b3ec8ad8bd81708902 | Ruby | lachlan/sprinkle | /lib/sprinkle/verifiers/environment.rb | UTF-8 | 1,672 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | module Sprinkle
module Verifiers
# = Environment Verifier
#
# Contains a verifier to check environment variables
#
# == Example Usage
#
# verify { has_environment_variable "PATH" }
# verify { has_environment_variable "ProgramFiles", "C:\\Program Files" }
#
module Environmen... | true |
f91caa89f2046f386bb05dc6f27e7916c65270d9 | Ruby | fguillen/RubioDeMarzo | /test/unit/initializers/string_test.rb | UTF-8 | 402 | 2.734375 | 3 | [] | no_license | # coding: utf-8
require "test_helper"
class StringTest < ActiveSupport::TestCase
def test_to_md
assert_equal("<p>wadus <strong>wadus</strong></p>", "wadus **wadus**".to_md)
end
def test_sanitize
assert_equal("AEIOU aeiou Nn 12", "ÁÉÍÓÚ áéíóú Ññ 12".sanitize)
end
def test_to_url
assert_equal("a... | true |
16d8963a9745f9e80c1c5d6da54177464d66d598 | Ruby | Nalipp/udacity_nanodegree | /rbnd-survivr-part2/lib/tribe.rb | UTF-8 | 324 | 3.171875 | 3 | [] | no_license | class Tribe
attr_reader :name, :members
def initialize(opts={})
@name = opts[:name]
@members = opts[:members]
puts "The '#{name}' tribe has been created."
end
def tribal_council(opts={})
@members.reject! { |member| member == opts[:immune] }
@members.sample
end
def to_s
name
end
... | true |
17cb685f28eba1397e563ee5e605a9bb321a63ce | Ruby | piyush8/ruby-basics | /object_type.rb | UTF-8 | 85 | 3.171875 | 3 | [] | no_license | puts 1.class
puts 1111111111111111111111111111111.class
puts "a".class
puts 1.5.class | true |
43aae36cd5b77951528c27fd69533b2c11d3555f | Ruby | ryu2129/paiza | /スキルチェック見本/jyanken.rb | UTF-8 | 388 | 3.109375 | 3 | [] | no_license | input = gets.split(" ")
n = input[0].to_i
m = input[1].to_i
s = gets
pmax = s.count("G")
cmax = s.count("P")
gmax = s.count("C")
win_max = 0
for pp in 0..n
for cc in 0..(n - pp)
gg = n - pp - cc
fingers = pp * 5 + cc * 2
if fingers == m then
win = [pp, pmax].min +[cc, cmax].min + [gg, gmax].mi... | true |
9a8c986e5fe70666bf6e7f23b08a79045f6aa6d5 | Ruby | Shoroh/csv_viewer | /lib/csv_viewer/table/cell.rb | UTF-8 | 359 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module CsvViewer
class Table
class Cell
attr_reader :lines, :align
def initialize(value:, align:)
@align = align
@lines = value.to_s.split("\n")
end
def content_width
lines.map(&:size).max
end
def content_height
... | true |
7d665f1137d06fa69569f6bc2a094251ead89b7c | Ruby | xuanming/xuanming | /lib/xuanming/tangram.rb | UTF-8 | 301 | 3.109375 | 3 | [
"MIT"
] | permissive | module Xuanming
class TangramPool
def initialize(name)
@tangrams = {}
end
def [](name)
@@tangrams[name]
rescue KeyError => e
raise ArgumentError, "Tangram \"#{name}\" not found"
end
def []=(name, tangram)
@tangrams[name] = tangram
end
end
end
| true |
7660cc0977aad329285323baa5f58245a342ab91 | Ruby | timfel/rubymirrors | /lib/abstract_reflection/compiler_mirror.rb | UTF-8 | 986 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | module AbstractReflection
# Reflecting on the compiler, both in a general sense (to just
# compile things) and in specific states. It should be possible to
# get a compiler instance and associated state from e.g. the
# execution of a thread.
#
# This class should also allow access to information about JIT,... | true |
902bfc56bcc9b68cbb52c49277aa48510dc57082 | Ruby | nryn/lrthw | /lrthw/chap37/ex1.rb | UTF-8 | 585 | 3.1875 | 3 | [] | no_license | BEGIN { puts "\"firing up!\"" }
END { puts "\vwinding \vdown!\\\\" }
def function_a(x)
puts "function_a is alive! #{x}!!!!"
end
def function_b
puts "function_b r00lz."
defined? self == "self"
end
alias alias_a function_a
puts "ready" and "to rock"
def function_c(); puts "function_c is it!" end
i=[1, 3, "spo... | true |
f269b8489b67e97bd5105489f337575cf2940835 | Ruby | antoinemor/rails-longest-word-game | /app/controllers/word_grids_controller.rb | UTF-8 | 1,791 | 2.984375 | 3 | [] | no_license | require 'json'
require 'open-uri'
class WordGridsController < ApplicationController
def game
@grid = generate_grid(9)
@start_time = Time.now
end
def score
@result = run_game(params[:guess], params[:grid].split(''), params[:start_time].to_i, Time.now.to_i)
# session[:played_games] += 1
# sess... | true |
49e4350c79dbf2cb2001dfdca60ee0a820de627d | Ruby | mmacedo/euler | /ruby/007.rb | UTF-8 | 195 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby
# http://projecteuler.net/problem=7
require File.expand_path('./primes.rb', File.dirname(__FILE__))
def nth_prime(n)
primes.drop(n.pred).first
end
puts nth_prime(10001)
| true |
a008ba94711d527b514a0e6e80bed7a13b416ee0 | Ruby | aplarson/w2d5 | /spec/deck_spec.rb | UTF-8 | 891 | 3.296875 | 3 | [] | no_license | require 'deck.rb'
describe "Deck" do
subject(:deck) {Deck.new}
it "contains cards" do
expect(deck.cards.all?{ |card| card.is_a?(Card) }).to be_true
end
it "begins with 52 cards" do # May also want to test for uniqueness
expect(deck.cards.length).to eq(52)
end
it "does not contain duplicate cards" d... | true |
796940839484204a9dacf412edc953c729468cd1 | Ruby | sonchez/programming_exercises | /flow_control/exercise_2.rb | UTF-8 | 237 | 4.1875 | 4 | [] | no_license | # capitalize if 10 or more characters method
def cap(word)
if word.length > 10
puts word.upcase
else
puts "No Bueno! At least 10 characters please!"
end
end
puts 'Hey tell me something!'
response = gets.chomp
cap(response) | true |
cdbc86aad9fc31c89e02cb8e0cb0672f646c76d2 | Ruby | brownman/divinity | /builtin/app/models/events/keyboard_events/key_event.rb | UTF-8 | 1,175 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #SDL::Event2::KeyDown
# This event occurs when a key is pressed.
#
# SDL::Event2::KeyDown#press - Returns true.
# SDL::Event2::KeyDown#sym - Returns the pressed key such as SDL::Key::ESCAPE.
# SDL::Event2::KeyDown#mod - Same as SDL::Key.modState.
# SDL::Event2::KeyDown#unicode - Returns key inp... | true |
22c009d2cc95f432278f182adcc0ed7055f28b97 | Ruby | dongarry/AcademicRuby | /Code/TC_Noddy_Pile.rb | UTF-8 | 923 | 3.3125 | 3 | [] | no_license | require "test/unit"
require_relative 'noddy_pile.rb'
require_relative 'player.rb'
class TC_Pile < Test::Unit::TestCase
def setup
@pile = NoddyPile.new
end
def test_initialisation
assert_equal(0, @pile.no_of_cards)
end
def test_winner
# create pile with entire pack of cards
... | true |
8b669a084d598019ff6694cfe9a30ec3b3ce6acd | Ruby | grayyeargin/restaurant_project | /models/food.rb | UTF-8 | 368 | 2.96875 | 3 | [] | no_license | class Food < ActiveRecord::Base
validates :name, uniqueness: true
has_many(:orders)
has_many(:parties, :through => :orders)
def is_spicy
if self.spicy == true
"spicyness"
else
"nospicy"
end
end
def food_capitalize
name_array = self.name.split(" ")
capitals = name_array.map {|word| word.capitaliz... | true |
302f21ca63482e2f839f65f9bd262249b262e27f | Ruby | peterdk/adventofcode2016 | /day11_part1.rb | UTF-8 | 7,597 | 3.1875 | 3 | [] | no_license | #microchips fry if not with RTG when other RTG is there
#elevator requires 1 RTG or microchip to function
class ElementalItem
attr_reader :element
def initialize(element)
@element = element
end
def compatible(item)
@element == item.element
end
def dup
ElementalItem.new(@element)
end
d... | true |
b23e01130aafcf7dc71c35c71fa456ad04c5c858 | Ruby | sh19910711/daily-contribs | /script/find_new_commits.rb | UTF-8 | 861 | 2.515625 | 3 | [] | no_license | require 'octokit'
require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => :sqlite3, :database => 'tmp/db.sqlite3')
require_relative '../app/models'
class Client
attr_reader :client
def initialize(token)
@client = Octokit::Client.new(access_token: token)
end
def commits(user)
clien... | true |
18e65765acdb31cd8f29a9382a6d11b5d62e9555 | Ruby | nitanshu/ruby-cracker | /Hackerearth/birthday_party.rb | UTF-8 | 158 | 3.078125 | 3 | [] | no_license | t=gets.chomp.to_i
inputs = []
t.times { inputs << gets.chomp.split(' ').map(&:to_i) }
inputs.each {|input| puts input.last%input.first == 0 ? 'Yes' : 'No' }
| true |
4c1b53a6990c893e8af0ecdaade8a356bf8f3e23 | Ruby | jeffrafter/fates | /lib/analysis/whitespace_analyzer.rb | UTF-8 | 822 | 2.96875 | 3 | [] | no_license | # See README for Copyright and License information
require 'strscan'
require 'analysis/analyzer'
module FateSearch # :nodoc:
module Analysis # :nodoc:
# Basic text analysis. Attempts to split a section of text based on
# basic whitespace rules. See +append_suffixes+ for more information
class Whit... | true |
f28d433d1f998403d9eb33dc378e08b56dd93682 | Ruby | guyanbiao/qunatitative-trading-borker | /app/services/batch_trade_service.rb | UTF-8 | 617 | 2.515625 | 3 | [] | no_license | class BatchTradeService
attr_reader :trader, :currency, :direction
def initialize(trader:, currency:, direction:)
@trader = trader
@currency = currency
@direction = direction
end
def execute
trader.users.enable.each do |user|
exchange = user.exchange_class.new(trader, currency)
orde... | true |
41e505ab6aaeae0f958ad9ceb7743da3154950ea | Ruby | rrrene/vedeu | /lib/vedeu/support/menu.rb | UTF-8 | 1,908 | 3.09375 | 3 | [
"MIT"
] | permissive | module Vedeu
class Menu
def initialize(collection)
@collection = collection
@current = 0
@selected = nil
@events = events
end
def events
@_events ||= Vedeu.events.add(self) do
event(:menu_next) { next_item }
event(:menu_prev) { prev_item ... | true |
568a208f5d669e229a3482f7bcdd5c30b5dd8093 | Ruby | machpich/ruby-book | /test/fizz_buzz_test.rb | UTF-8 | 274 | 2.78125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../lib/fizz_buzz'
class SampleTest < Minitest::Test
def test_fizz_buzz
assert_equal 'FizzBuzz',fizzbuzz(15)
assert_equal 'Fizz',fizzbuzz(5)
assert_equal 'Buzz',fizzbuzz(3)
assert_equal '2',fizzbuzz(2)
end
end | true |
318e6012bbccf2707ce7f316ea69eb1e2bc951b6 | Ruby | Xorlev/cleangist | /lib/cleangist/github_api.rb | UTF-8 | 451 | 2.796875 | 3 | [
"MIT"
] | permissive | require "httparty"
class GithubApi
include HTTParty
base_uri 'https://api.github.com'
def initialize(token)
self.class.headers 'Authorization' => "token #{token}"
end
def gists()
self.class.get('/gists')
end
def get_gist(gist_url)
self.class.get(gist_url)
end
def delete_gist(gist_id)
... | true |
11d7280fab806d0bdd577ba902a5264b156ca99e | Ruby | eduardofinotti/test-api-rest-base | /features/support/generic_steps.rb | UTF-8 | 685 | 2.578125 | 3 | [] | no_license | # Generic method to get actual rote
Given("I have the rote {string}") do |rote|
@url_token = rote
end
# Generic method to valid the return response code of requests
Then("return a response with a {string} response code") do |code|
expect(@result.response.code).to eq code
end
# Generic method to valid return NOT E... | true |
bd42599b8c4f87954f98f36ef91c6fd6c94efca4 | Ruby | kypsy/website | /spec/lib/kypsy_html_spec.rb | UTF-8 | 1,912 | 2.875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | require 'spec_helper'
describe KypsyHTML do
describe "@usernames" do
it "turns @username into a link" do
expect(Redcarpet::Markdown.new(KypsyHTML).render("@username")).to include "<p><a href='/@username'>@username</a>"
end
it "wraps text around it" do
expect(Redcarpet::Markdown.new(KypsyHTML... | true |
48be684a836ca8d7e4a95fce5da08bac12c1371b | Ruby | RuslanKLESK/black_jack | /players.rb | UTF-8 | 1,912 | 3.546875 | 4 | [] | no_license | # frozen_string_literal: true
# Players Class
class Players
attr_accessor :amount, :cards, :points, :issused_cards
CARDS = ['2','3','4','5','6','7','8','9','10','В','Д','К','Т']
TYPE = ["<>", "<3", "+", "^"]
@@issused_cards = []
def initialize
@amount = 100
@cards = {}
@points ... | true |
aff0c68638810ac7c9055cd32ee49642ee992b8a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/edc023f6c56a4028a32696ea0a2da045.rb | UTF-8 | 542 | 3.203125 | 3 | [] | no_license | class Complement
@conversion_map = { 'G' => 'C',
'C' => 'G',
'T' => 'A',
'A' => 'U'
}
def self.of_dna(dna_strand)
@rna_strand = String.new
dna_strand.chars.each_with_index do |d|
@rna_strand << @conversion_map[d]
end
@rna_str... | true |
0f61e7fda927be93684c2e158b62f7c7b1b026d9 | Ruby | gyde-tv/bitybit | /lib/bitybit/features/feature_extractor.rb | UTF-8 | 607 | 2.53125 | 3 | [
"MIT"
] | permissive | module Bitybit
module Features
class FeatureExtractor
include Bitybit::Features::Util
attr_reader :object
def initialize(object)
@object = object
end
def generate_features(object)
raise NotImplementedError.new("Please implement #{self.class.name}#generate_features(... | true |
9cf25790467fbf77a690bf0e51e360a88c0fb266 | Ruby | joccreng/Ruby_Test | /otros_bloques.rb | UTF-8 | 117 | 3.0625 | 3 | [] | no_license | def hola
yield if block_given?
end
hola {puts "Hola Mundo"}
#def hola
# yield
#end
#hola {puts "Hola Jose"} | true |
e32c38a6dd61d62236bec99ba89fe4959e656a84 | Ruby | yingziz/zendesk-ticket-viewer | /lib/gateways/ticket_gateway.rb | UTF-8 | 983 | 2.890625 | 3 | [] | no_license | require 'net/http'
require 'json'
class TicketGateway
def initialize(email, token)
@email = email
@token = token
@prompt = TTY::Prompt.new
end
def fetch(url)
uri = URI.parse(url)
request = Net::HTTP::Get.new(uri)
request.basic_auth("#{@email}/token", @token)
req_options = {
us... | true |
f5a544749bc65d6ec04076bab8f7f0b02c8cba54 | Ruby | rmderfler/allergies | /lib/allergies.rb | UTF-8 | 844 | 4.0625 | 4 | [] | no_license | # eggs =1
# peanuts =2
# shellfish =4
# strawberries = 8
# tomatoes =16
# chocolate =32
# pollen =64
# cats =128
#input = gets.chomp
def allergies (number)
result = []
while number>0
if number>=128
result.push('cats')
number=number-128
elsif number>=64
... | true |
6f2bd0a1b3afcab6e8ca1183114b832fccfc87c4 | Ruby | maxlvl/LS | /learn to program/extend_built_in_classes.rb | UTF-8 | 94 | 3.234375 | 3 | [] | no_license | class Array
def shuffle
sort_by{rand}
end
end
print [1,2,3,4,5,6,7,8,9,10].shuffle
| true |
ea9439a5927d034cf02f2e2716c4acb101c11aca | Ruby | mattpeleti/apis-and-iteration-web-0916 | /lib/api_communicator.rb | UTF-8 | 1,017 | 3.3125 | 3 | [] | no_license | require 'rest-client'
require 'JSON'
require 'pry'
def character_hash
all_characters = RestClient.get('http://www.swapi.co/api/people/')
JSON.parse(all_characters)
end
def find_character(character)
character_hash.values.last.find do |character_hash_element|
character_hash_element["name"].downcase == char... | true |
0f9dc90c15215d29373ff3560123cb4aa965db57 | Ruby | Tatuno10/movie-review | /app/models/review.rb | UTF-8 | 546 | 2.515625 | 3 | [] | no_license | class Review < ApplicationRecord
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :genre
belongs_to :movie
belongs_to :user
with_options presence: {message: 'は空で入力しないでください。'} do
validates :title
validates :review
validates :point
validates :genre_id
end
def... | true |
42fa87432d069a79f4feb2e1783457f36c06dc1e | Ruby | imahungrypanda/Car-Wash | /app/models/vehicle.rb | UTF-8 | 1,264 | 2.671875 | 3 | [] | no_license | # == Schema Information
#
# Table name: vehicles
#
# id :integer not null, primary key
# vehicle_type :string not null
# license_plate :string not null
# created_at :datetime not null
# updated_at :datetime not null
# visit_count :integer d... | true |
bbfd680101b19a80ea4a0e5fd42d244706ef53e3 | Ruby | Christiansantoss/Depotbookstore | /db/seeds.rb | UTF-8 | 34,492 | 2.890625 | 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 rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
642cdf5873769eb277d5c3c5377182b33dca8043 | Ruby | clyeager/oop | /lesson_5/oop_ttt.rb | UTF-8 | 9,037 | 3.671875 | 4 | [] | no_license | class Board
attr_accessor :squares
WINNING_LINES = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] +
[[1, 4, 7], [2, 5, 8], [3, 6, 9]] +
[[1, 5, 9], [3, 5, 7]]
def initialize
@squares = {}
reset
end
def reset
(1..9).each { |key| squares[key] = Square.new }
end
def []=... | true |
bd57d3b984fbf6bcb01fe391d22ec996c50dd191 | Ruby | GiancarloZ/reddit_now | /lib/reddit_now/posts.rb | UTF-8 | 868 | 2.75 | 3 | [
"MIT"
] | permissive | class RedditNow::Posts
attr_accessor :title, :upvote, :user, :url, :rank, :subreddit
def self.now
self.scraped
end
def self.scraped
frontpage = self.scraped_frontpage
end
def self.scraped_frontpage
list = []
page = Nokogiri::HTML(open("https://old.reddit.com/r/all/", '... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.