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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1677405fcad0a521dd0e89b5dc44b5fd7510481d | Ruby | jonatas/fast | /examples/method_complexity.rb | UTF-8 | 1,103 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
$LOAD_PATH << File.expand_path('../lib', __dir__)
require 'fast'
def node_size(node)
return 1 unless node.respond_to?(:children)
children = node.children
return 1 if children.empty? || children.length == 1
nodes, syms = children.partition { |e| e.respond_to?(:children) }
1 + sy... | true |
2a413f53e9be09b6806e219fd9a963eaf4af909b | Ruby | yyoshiokasfdc/kadai-ruby-1 | /kadai-ruby-1/kadai-introduce.rb | UTF-8 | 138 | 2.890625 | 3 | [] | no_license | last_name = '吉岡'
first_name = '裕一ベイナード'
age = '23'
puts last_name + first_name + 'です。' + age.to_s + '歳です。' | true |
94ef27e7b312810d908cb853cd1c2fcdef5f4e3a | Ruby | patricewhite/Ruby | /Strings/include.rb | UTF-8 | 308 | 3.796875 | 4 | [] | no_license | # boolean method
# check if something exisit in another string
# case sensitive
name = 'Scooby Doo'
p name.include?('o')
# true
p name.include?('S')
# true
p name.include?('s')
# false
# normalizing string (don't have to worry about case)
p name.downcase.include?('s')
# true
p name.include?('Doo')
# true
| true |
46a6c41accaaae0ea7b6b0e2bc348c7487fe5328 | Ruby | MacBoyPro/wowza-rest | /spec/wowza_rest/core_ext/string_spec.rb | UTF-8 | 2,099 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe String do
describe '#underscore' do
context 'when given a camelCased word' do
context 'when it has capital first letter' do
it 'downcase the first letter' do
word = 'CamelCased'.underscore
expect(word).to eq('camel_cased')
end
e... | true |
2a1305ad696e96cea057cac46017b919bb33bc31 | Ruby | geisonfgf/text-marker | /lib/textmarker.rb | UTF-8 | 645 | 3.21875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "textmarker/version"
require "textmarker/tag"
module TextMarker
class Marker
attr_accessor :text
def initialize(text="")
@text = text
end
def mark_all_ocurrence_of(snippet_to_be_marked, tag=Tag.new)
@text.gsub(snippet_to_be_marked, build_marked_snippet(snippet_to_be_marked, tag)... | true |
f56aff6e95bab6a87c59758e6264492ed713718d | Ruby | mkmms/ecommerce-kalebr | /app/models/cart.rb | UTF-8 | 575 | 2.984375 | 3 | [] | no_license | class Cart
attr_accessor :cart_items
def initialize(cart_items = [])
@cart_items = cart_items
end
def is_cart_empty?
@cart_items.blank?
end
def add_item_to_cart(product)
cart_item = @cart_items.select { |item| item["id"] == product.id }.first
unless cart_item.present?
@cart_items <<... | true |
9dd651826b1cd9e5e5ae61e3c07a56d67c33ded4 | Ruby | MrJoy/surface_master | /lib/surface_master/launchpad/interaction.rb | UTF-8 | 2,064 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module SurfaceMaster
module Launchpad
# Higher-level interface to Novation Launchpad Mark 2, providing an input
# handling loop and event-hooks for input events.
class Interaction < SurfaceMaster::Interaction
def initialize(opts = nil)
@device_class = Device
super(opts)
end
... | true |
2ff28a9ff3d5ca3b3b2ab3d162a7abc06a0693b2 | Ruby | tompave/prime_numbers | /test/table_test.rb | UTF-8 | 566 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'minitest_helper'
class TableTest < Minitest::Test
def setup
@list = [2, 3, 5, 7]
@table = PrimeNumbers::Table.new(@list)
end
def test_attribute_primes
assert_equal @list, @table.primes
end
def test_attribute_size
assert_equal @list.length, @table.size
end
def test_attribut... | true |
5079aff7dd82c03b4984ce4b1786fea00dd52367 | Ruby | IceColdCoder/mspire | /spec/mspire/ident/peptide/db/creator_spec.rb | UTF-8 | 2,708 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
require 'yaml'
path = 'mspire/ident/peptide/db'
require path + "/creator"
describe 'creating a peptide centric database' do
subject { Mspire::Ident::Peptide::Db::Creator.new }
describe 'amino acid expansion' do
it 'can expand out wildcard amino acid combinations' do
array = subj... | true |
9bb712599055e23a4e268a102a090b1514ec9cb0 | Ruby | Ichiyo14/ruby-practices | /07.bowling_object/test/object_bowling_test.rb | UTF-8 | 1,155 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require './lib/shot'
require './lib/frame'
require './lib/game'
class ShotTest < Minitest::Test
def test_number_to_score
assert_equal 5, Shot.new('5').score
end
def test_x_to_score
assert_equal 10, Shot.new('X').score
end
end
class FrameTest <... | true |
bf8f6d474e614dbb15c5bf6139df61529df1d8e7 | Ruby | mgup/morpher | /lib/morpher.rb | UTF-8 | 552 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'httparty'
module Morpher
INFLECTIONS_COUNT = 6
class Inflection
include HTTParty
base_uri 'morpher.ru'
def get(text)
options = {}
options[:query] = { s: text }
self.class.get('/WebService.asmx/GetXml', options)
end
end
def self.inflections(word)
inflections = [... | true |
dcea659e9d3de3e0cdb2a66f4eb42d35069c19e1 | Ruby | ljg2gb/ruby-enumerables-cartoon-collections-lab-denver-web-033020 | /cartoon_collections.rb | UTF-8 | 698 | 3.328125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index{ |item,index| puts "#{index + 1}.#{item}" }
end
def summon_captain_planet(array)
array.map{ |call| "#{call.capitalize}!" }
end
def long_planeteer_calls(array)
array.any?{|call| call.length > 4 }
end
def find_the_cheese(array)
cheese_types = ["cheddar", "goud... | true |
d4bae163f20372fb0283307ada2f7ee6a02ebca9 | Ruby | charleshenriponiard/01-Food-Delivery | /app/views/meals_view.rb | UTF-8 | 329 | 3.0625 | 3 | [] | no_license | require 'pry-byebug'
class MealsView
def ask_user_name_meal
puts "Add a new meal"
return gets.chomp
end
def ask_user_price_meal
puts "which price ?"
return gets.chomp.to_i
end
def display(meals)
meals.each do |meal|
puts "#{meal.id}) #{meal.name} (#{meal.price} €)"
end
end
... | true |
d33c106688f300e765fce2f6c6a24eec7d095599 | Ruby | josephwilk/aocny | /bank_example/features/step_definitions/steps.rb | UTF-8 | 281 | 2.515625 | 3 | [] | no_license | Given /^I have a balance of (#{MONEY})$/ do |balance|
cash_machine.set_balance(balance)
end
When /^I withdraw (#{MONEY})$/ do |balance|
cash_machine.withdraw(balance)
end
Then /^I should have a balance of (#{MONEY})$/ do |balance|
cash_machine.balance.should == balance
end | true |
c4c98a2da7017c71a534a9ea79085c404dc02c89 | Ruby | maeda-seina/rubybook | /chapter4/4-6.rb | UTF-8 | 45 | 2.75 | 3 | [] | no_license | numbers = [2, 3]
numbers.unshift(1)
p numbers | true |
5b1abfe76da067b674c200901b4c6988983043a0 | Ruby | eggyy1224/ruby_basics | /methods/name.rb | UTF-8 | 103 | 2.9375 | 3 | [] | no_license | def assign_name name='Bob'
name
end
puts assign_name('Kevin') == 'Kevin'
puts assign_name == 'Bob' | true |
0c7167b94c5b9c11abdfa5d8d308460079a5cd7b | Ruby | CSC-440-Sp2017-NKU/team-project-i5s | /deliverables/iteration3/Iteration3Final/app/models/section.rb | UTF-8 | 1,047 | 2.5625 | 3 | [] | no_license | class Section < ApplicationRecord
belongs_to :semester
belongs_to :courses
belongs_to :users
has_many :student_sections
has_many :users, :through => :student_sections
has_many :courses, :through => :student_sections
has_one :users
#sections are taught by instructors
#return students enrolled in th... | true |
4c3b594df955a631fb6d33c6e430cf093126def9 | Ruby | willfowls/prepcourse | /ruby_books/intro_to_ruby/3rd_attempt_at_exercises/1.rb | UTF-8 | 145 | 3.296875 | 3 | [] | no_license | # add two strings together that when concatenated, return your first and last name as your full name in one string
puts "Will " + "Fowls"
#check | true |
33dfaec105941beb9f5b8c2aa26dec02ee7b1a29 | Ruby | escowles/tweetext | /tweetext.rb | UTF-8 | 3,860 | 2.984375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'highline'
require 'inifile'
require 'rbconfig'
require 'rest-client'
def config
@config ||= IniFile.load(config_file)
end
def main_config
config['twtxt'] || {}
end
def tweetfile
main_config['twtfile']
end
def timeline_limit
main_config['limit_timeline'] || 20
end
def timeline_... | true |
7caba0b75e588f3eff9f026d86e65ac650eb55f1 | Ruby | dominathan/clarlegal | /app/models/staff.rb | UTF-8 | 1,663 | 2.65625 | 3 | [] | no_license | class Staff < ActiveRecord::Base
belongs_to :case
belongs_to :staffing
validates :staffing_id, presence: true
def self.case_total_hours_actual(case_id)
hours_actual = 0
staff_ids = Staff.where(case_id: case_id).collect(&:staffing_id).uniq
for id in staff_ids
if Staff.where(case_id: case_id,... | true |
be094acd35910e6c8e4e685aba13ea875be47bb7 | Ruby | OneEyedEagle/EAGLE-RGSS3 | /Event System/【废弃】/显示动画扩展.rb | UTF-8 | 10,986 | 2.59375 | 3 | [
"MIT"
] | permissive | #==============================================================================
# ■ 显示动画扩展 by 老鹰(http://oneeyedeagle.lofter.com/)
#==============================================================================
$imported ||= {}
$imported["EAGLE-AnimEX"] = true
#===========================================================... | true |
6a91e1de8f01347d0056b7331ed7c13b944f0852 | Ruby | natstar93/learn_to_program | /ch13-creating-new-classes/orange_tree.rb | UTF-8 | 746 | 3.84375 | 4 | [] | no_license | class OrangeTree
def initialize
@age = 0
@height = 0.0
@oranges = 0
end
def height
return @height
end
def one_year_passes
@age += 1
@height = @height.round(1) + 0.4
if @age == 60
tree_dies
end
if @age > 2
@oranges = (@height * 15 - 25).to_i
end
re... | true |
1fc54853bc9ba92b73457fe5cb29fd0a0be7ca26 | Ruby | yakataN/ProgrammingCompetition | /Atcorder/abc/ABC103/question_d/main00.rb | UTF-8 | 359 | 3.421875 | 3 | [] | no_license | n,m = gets.chomp.split.map(&:to_i)
ary = []
m.times do
ary << gets.chomp.split.map(&:to_i)
end
def asyuku_youbou(ary,n)
ary.sort_by!{|item| item[1]}
last = -1
count = 0
ary.each do |item|
if item[0] >= last
count += 1
last = item[1]
end
end
return count
end
ans_ary... | true |
ef542018ccf177b85cf9f62c61f70da37ab7f97c | Ruby | radu-constantin/small-problems | /easy3/palindrome2.rb | UTF-8 | 401 | 3.609375 | 4 | [] | no_license | def palindrome? (string)
string == string.reverse
end
def real_palindrome?(string)
palindrome?(string.casecmp)
end
puts real_palindrome?('madam') == true
puts real_palindrome?('Madam') == true # (case does not matter)
puts real_palindrome?("Madam, I'm Adam")
puts real_palindrome?('356653') == true
put... | true |
63c2831e561e1f67bb997b80ace81146c4c22bbd | Ruby | lhz/mazes | /lib/hunt_and_kill.rb | UTF-8 | 716 | 3.171875 | 3 | [] | no_license | require 'algorithm'
class HuntAndKill < Algorithm
def run
puts "Running #{self.class} algorithm." if $debug
current = grid.random_cell
while current
unvisited_neighbors = current.unvisited_neighbors
if unvisited_neighbors.any?
neighbor = unvisited_neighbors.sample
current.li... | true |
094426750af419f20b541e4092d2e84fd3d00890 | Ruby | Ty-Zeta/selected-pairs | /rando_names.rb | UTF-8 | 457 | 3.109375 | 3 | [] | no_license | def pairing(name)
pairs = name.shuffle.each_slice(2).to_a
if name.length % 2 == 0
else
last_one = pairs.pop
last_one = last_one[0]
pairs[0] << last_one
end
pairs
# teams = ""
# pairs.each do |value|
# if value.include? (value[2])
# teams << value[0] + "," + valu... | true |
1ff396e25ac0c4c2554039090b0603f535e48f65 | Ruby | ryanj/brite-banana-client.rb | /spec/eventbrite/api_object_collection_spec.rb | UTF-8 | 2,622 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Eventbrite::ApiObjectCollection do
before(:all) do
@b = Eventbrite::BananaBunch.new(false, [{"banana" => {:val => 1}}, {"banana" => {:val => 2}}])
end
context "collection functions" do
it "should pass through standard Array met... | true |
559a832e45b70f88b48a70248389fea56d08bf21 | Ruby | ho-tonym/collections_practice_vol_2-nyc-web-051418 | /collections_practice.rb | UTF-8 | 1,868 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def begins_with_r(array)
array.all? do |element|
element.start_with?("r")
end
end
def contain_a(array)
new_array = Array.new
array.select do |element|
if element.include?("a") == true
new_array << element
end
end
return new_array
end
def first_wa(array)
array.find do |element|
... | true |
76cc87c12d1a89a98658e29fa0fadabbea437333 | Ruby | digitalnatives/fron-ui | /opal/fron-ui/behaviors/loop.rb | UTF-8 | 999 | 2.78125 | 3 | [] | no_license | module UI
module Behaviors
module Loop
# Update / Render Loop
def self.included(base)
base.register self, [:act]
end
def data
@data ||= {}
end
def update!(type, *args)
if type.is_a?(Array)
type.each { |item| update_act(*item) }
else
... | true |
25dea9cd48726ca78240b1898b125de63d2e3506 | Ruby | saasbook/rate-my-pup | /app/models/email_template.rb | UTF-8 | 856 | 2.6875 | 3 | [
"MIT"
] | permissive | class EmailTemplate < ActiveRecord::Base
#Iter3-2 restricted assignment (By Gung Hiu Ho)
attr_accessible :title
attr_accessible :body
attr_accessible :created_at
attr_accessible :updated_at
attr_accessible :marked
#private
def EmailTemplate.all_emails
return EmailTemplate.select('... | true |
7b89219a64da7f9742aa58f1761edf8d9285db01 | Ruby | GitHiroki/Ruby | /study/11/hash_each.rb | UTF-8 | 213 | 3.171875 | 3 | [] | no_license | sum = 0
outcome = {"参加費"=>1000, "ストラップ"=>1000, "懇親会会費"=>4000}
outcome.each do |pair|
sum += pair[1] #値を指定している
puts pair[0] #キー値出力
end
puts "合計 : #{sum}"
| true |
604d357befba8e68e7904d38bb29f8a658d4f3d8 | Ruby | kellywerks/AddressBookRuby | /lib/address.rb | UTF-8 | 217 | 3.09375 | 3 | [] | no_license | class Address
attr_accessor :street, :city, :state, :zip, :type
def initialize(street, city, state, zip, type)
@street = street
@city = city
@state = state
@zip = zip
@type = type
end
end
| true |
69b45a54b167f2fc320a635ef021e0da74ea5f3e | Ruby | devincloudkelly/ruby-enumerables-cartoon-collections-lab-seattle-web-102819 | /cartoon_collections.rb | UTF-8 | 725 | 3.640625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(dwarves)# code an argument here
# Your code here
numbered_dwarves = []
i = 0
while i < dwarves.length
numbered_dwarves.push("#{i +1}. #{dwarves[i]}")
i += 1
end
puts numbered_dwarves
end
def summon_captain_planet(array)# code an argument here
# Your code here
array.collect { |ca... | true |
89c190e9c0dab90bf22dac9d5191033f800abcbc | Ruby | jcgq/PDOO_Ugr | /Ruby/civitas/lib/dado.rb | UTF-8 | 1,002 | 3.078125 | 3 | [
"MIT"
] | permissive | #encoding: utf8
require_relative 'diario'
module Civitas
class Dado
attr_accessor :ultimo_resultado
@@SalidaCarcel=5
def initialize()
@random=Random.new()
@ultimo_resultado=0
@debug=true
end
def tirar()
if(@debug == true)
@ultimo_resultado=1
r... | true |
a4057c6da1cfb41709f9ad73fc4deca27d1058cb | Ruby | rails/rails-docs-server | /lib/generators/main.rb | UTF-8 | 1,037 | 2.578125 | 3 | [] | no_license | require 'find'
require 'fileutils'
require 'generators/base'
require 'generators/config/main'
module Generators
class Main < Base
include Config::Main
def generate_api
start = Time.now
rake 'rdoc', 'EDGE' => '1', 'ALL' => '1'
delete_orphan_files_in_api(start)
end
def generate_guid... | true |
b8d9a5d161eeb7e5a47e9370726ca30a1ff22993 | Ruby | SamJT2021/chitter-challenge-apprenticeships | /lib/peep.rb | UTF-8 | 1,102 | 3.171875 | 3 | [] | no_license | require_relative 'database_connection'
class Peep
attr_reader :id, :message, :username, :date
def initialize(id, message, username, date)
@id = id
@message = message
@username = username
@date = date
end
def self.all
result = DatabaseConnection.query('SELECT * FROM peeps ORDER BY id DESC'... | true |
c0c779c29c87acaad0c95adbbad536a966b2ab55 | Ruby | samjefferson/tralobo | /test/models/user_test.rb | UTF-8 | 2,439 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(username: "example123", email: "admin@example.com",
password: "jeffo50", password_confirmation: "jeffo50")
end
test "should be valid" do
assert @user.valid?
end
test "username presence" do
@user.user... | true |
877d6d8792b200b9df0091723d1db8b400d54448 | Ruby | LessonPlanet/emaildirect-ruby | /lib/emaildirect/image_folder.rb | UTF-8 | 1,143 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'emaildirect'
require 'json'
module EmailDirect
# Represents a image folder and associated functionality
class ImageFolder
class << self
def all(options = {})
response = EmailDirect.get uri, :query => options
Hashie::Mash.new(response)
end
def create(name, folder_path... | true |
ede0c1482324931f9159c6e84e60096884fa1a05 | Ruby | denis-adobe/crawler-1 | /bin/crawler | UTF-8 | 888 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | #! /usr/bin/ruby
$LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
require 'rubygems'
require 'crawler'
require 'optparse'
options = {}
logfile = ""
optparser = OptionParser.new do |opts|
opts.on("-t", "--timeout X", Integer, "Timemout limit in seconds") { |x| options[:timeout] = x}
opts.on("-x", "--exc... | true |
9a1596d7d7fb49315b055001a0b563ed4f1c7b4b | Ruby | DOV3D/W2D1 | /david_velazquez_bootcamp_project/lib/bootcamp.rb | UTF-8 | 1,065 | 3.75 | 4 | [] | no_license | class Bootcamp
def initialize(name, slogan, student_capacity)
@name = name
@slogan = slogan
@student_capacity = student_capacity
@teachers = []
@students = []
@grades = Hash.new {|hash, k| hash[k] = []}
end
def name
@name
end
def slogan
@slogan
end
def teachers
@teachers
end
... | true |
25cba0bf42aad2037129fd8c73fb7673b19a2e89 | Ruby | sonshi/NewMon-Ruby | /test2/test2-5.rb | UTF-8 | 168 | 3.203125 | 3 | [] | no_license | puts("こんにちは\nお元気ですか")
puts('こんにちは\nお元気ですか')
puts("こんにちは\"山田\"さん")
puts('こんにちは\'山田\'さん')
| true |
7b23fe0d84ac7e41e60a64040e19b6a1fa5b2673 | Ruby | Meyanis95/tests-ruby | /lib/05_timer.rb | UTF-8 | 115 | 2.921875 | 3 | [] | no_license | def time_string(num)
return [num / 3600, num / 60 % 60, num % 60].map{|t| t.to_s.rjust(2,'0')}.join(':')
end
| true |
a390dc0495ff5c262527b088228ffc7672f9de20 | Ruby | joerg/wright | /lib/wright/cli.rb | UTF-8 | 1,975 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'optparse'
require 'wright'
module Wright
# Wright command-line interface.
class CLI
def initialize(main)
@commands = []
@main = main
set_up_parser
end
# Runs a wright script with the supplied arguments.
#
# @param argv [Array<String>] the arguments passed to bin/wrig... | true |
29ddb74ee36c993d79fba2aa0e560c1d6e95f604 | Ruby | chiku/RubyScratch | /attr_accessor_with_default_test.rb | UTF-8 | 1,850 | 2.796875 | 3 | [] | no_license | require 'minitest/autorun'
require File.expand_path('../attr_accessor_with_default', __FILE__)
class TestOne
attr_accessor_with_default :foo, 100
attr_accessor_with_default :bar, 200
end
class TestTwo
attr_accessor_with_default :foo, 1000
attr_accessor_with_default :bar, 2000
end
describe "attr_accessor_wit... | true |
7656577a3be5b804c1dcd6f0f4dd38ae803abb71 | Ruby | balaji-kmty/intro-to-programming-ls | /hashes/two.rb | UTF-8 | 422 | 4.25 | 4 | [] | no_license | # Look at Ruby's merge method. Notice that it has two versions. What is the difference between merge and merge!? Write a program that uses both and illustrate the differences.
# merge returns a new hash that contains the merged contents of two hashes
# merge! combines a hash with another and overwrites the calling Has... | true |
cf271d0f0df80fa881898365d5c6f4e954a98e30 | Ruby | ahmetefeoglu/My-Back-End-track | /Programming_Backend/Ruby_Foundations/lesson_1/reduce.rb | UTF-8 | 267 | 3.359375 | 3 | [] | no_license | require 'pry'
def reduce(array, default = 0)
counter = 0
total = default
while counter < array.size
total += array[counter] if yield(total, array[counter])
counter += 1
end
total
end
reduce([1,2,3,4,5], 10) { |acc, num| acc + num}
binding.pry
| true |
ce7e056b97a26d98ce3b14dcd966d0ac0efc4834 | Ruby | dvioletta/CC_Wk3_D5_Code_Clan_Cinema | /models/customers.rb | UTF-8 | 1,732 | 3.296875 | 3 | [] | no_license | require_relative("../db/sql_runner")
require_relative('tickets')
require_relative('films')
class Customers
attr_reader :id
attr_accessor :name, :funds
def initialize(options)
@id = options['id'].to_i if options['id']
@name = options['name']
@funds = options['funds'].to_i
end
def save() #Create... | true |
fd10893b995d380dbd518b9f379379ca51317017 | Ruby | guyroyse/cobplexity | /lib/cobplexity/runner.rb | UTF-8 | 771 | 2.8125 | 3 | [] | no_license | require 'optparse'
require 'cobplexity'
analyzer = Cobplexity::Analyzer.new
OptionParser.new do |opts|
opts.banner = "Usage: cobplexity [options]"
opts.on("-g", "--group NAME", String, "Top level categroy for select code, defaults to 'APPLICATION'") do |group|
analyzer.group = group
end
opts.on("-t", "--t... | true |
0e41b0e2b4184c24b633c6eae72a7c945b601d89 | Ruby | ZachBaird/dynamicdatastructures | /lib/bst/tree.rb | UTF-8 | 5,081 | 3.40625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'node'
# A balanced binary search tree
class Tree
attr_reader :root
def initialize(arr)
@root = build_tree arr
end
def build_tree(arr)
arr = arr.uniq
root = Node.new(arr.shift)
arr.each { |x| push_node(root, x) }
root
end
def pretty_p... | true |
6bb156ced7198821d5e27d355925dacd84f04f31 | Ruby | ericgj/s1-final | /lib/data_table/table.rb | UTF-8 | 10,063 | 3.015625 | 3 | [] | no_license |
module RMU
module Data
class IllegalFormatError < StandardError; end
class Table
extend ::Loadable
include ::Dumpable
attr_reader :data
attr_reader :headers
DEFAULT_OPTIONS = {:cache => true}
load_files_of_format(:yaml) do |input, opts|
require 'yaml'
yaml = YAML.load... | true |
b2782ea53ca494fa414f86be7d3661c558d8bbd8 | Ruby | tiagonbotelho/birthday-scheduler | /lib/birthday_bot.rb | UTF-8 | 1,907 | 3.3125 | 3 | [] | no_license | require 'httparty'
require 'rufus-scheduler'
require 'file_control'
class SlackBot
#it initializes the bot with the url of slack and the path of the file
def initialize(url, path, user, channel)
@url = url
Birthday.filepath = path
if Birthday.file_exists?
puts "Found aniversary file"
elsif ... | true |
9d2894ac939056f20c58632c63e460ed118c6046 | Ruby | dbalatero/scout_rails_instrumentation | /install.rb | UTF-8 | 916 | 2.734375 | 3 | [] | no_license | # This file is executed when the plugin is installed. It sets up the
# configuration file and provides next steps to put the plugin to use.
RAILS_ROOT = File.join(File.dirname(__FILE__), '..', '..', '..') unless defined?(RAILS_ROOT)
# template
config_file_name = 'scout.yml'
template_path = File.join(File.dirname(__F... | true |
4f950c66f79e5898b3da5d1e5f283162688fe169 | Ruby | wlbr/Fibonacci | /fibonacci.rb | UTF-8 | 261 | 3.953125 | 4 | [] | no_license | class Fibonacci
def initialize
@array = [1, 1]
end
def sum
while @array[-1] < 1000 do
@array << @array[-2] + @array[-1]
end
@array.delete_at(-1)
end
def print
p @array.join(' ')
end
end
f = Fibonacci.new()
f.sum
f.print
| true |
1839f2ff1374a041fca9ec99b6ae1f4658db54ef | Ruby | whistler/active-tracker | /lib/active_tracker/tracker.rb | UTF-8 | 1,216 | 2.828125 | 3 | [
"MIT"
] | permissive | module ActiveTracker
class Tracker
include Singleton
# Hold information on what to track
attr_accessor :hits
attr_accessor :changes
attr_accessor :creates
# Stores blocks called when an event is triggered
attr_accessor :tracker_blocks
attr_accessor :tracker_names
... | true |
2b60866949af918b934a61ae2966b168557406f0 | Ruby | ETBassist/adopt_dont_shop_paired | /spec/features/shelters/show_spec.rb | UTF-8 | 4,118 | 2.609375 | 3 | [] | no_license | require 'rails_helper'
describe 'As a visitor' do
describe 'When I visit /shelters/:id' do
before(:each) do
@shelter = Shelter.create!(
name: "Will's Pet Shelter",
address: "123 Main St",
city: "Boulder",
state: "CO",
zip: "80309"
)
@user = User.create!(... | true |
ee75fbce850636f4ca9a467f43e7de0f8eb64089 | Ruby | PacificRebel/game-of-dice | /lib/game-of-dice_lib.rb | UTF-8 | 254 | 3.40625 | 3 | [] | no_license | class GameOfDice
def initialize(sides = 6)
@sides = sides
end
def sides
@sides
end
def roll(number_dice = 1)
roll_result = Array.new
number_dice.times do
roll_result << rand(1..@sides)
end
roll_result
end
end
| true |
fc3c5b67ac74d092b6c1176c174c3086e26cf99a | Ruby | ljercha/testowanie-w-ruby | /zad2/szyfrowanie/szyfrowanieBiblioteka.rb | UTF-8 | 592 | 2.78125 | 3 | [] | no_license | require 'openssl'
class Szyfrowanie
def self.zakoduj string, key
cipher = OpenSSL::Cipher.new('DES');
cipher.encrypt
salt = OpenSSL::Random.random_bytes(16)
cipher.key = OpenSSL::PKCS5.pbkdf2_hmac_sha1(key, salt, 20000, 32)
iv = cipher.random_iv
Marshal.dump([salt, iv, cipher.update(string) <<... | true |
a02d6e83c0182f370bff603e383c53e681f932a8 | Ruby | SlowKingV/oop-tictactoe | /lib/board.rb | UTF-8 | 1,551 | 3.234375 | 3 | [
"MIT"
] | permissive | WIN_CASES = [
'^(?:[B\-]{6}|[B\-]{3})?AAA(?:[B\-]{6}|[B\-]{3})?$', # Win case for HORIZONTAL line (e.g. OOO XXX OOO)
'^[B\-]{0,2}(?:A[B\-]{2}){2}A[B\-]{0,2}$', # Win case for VERTICAL line (e.g. OXO OXO OXO)
'^[B\-]{2}(?:A[B\-]){3}[B\-]$', # Win case for FORWARD DIAGONAL line (e.g. OOX OXO XOO)
'^(?:A[B\-]{3}){... | true |
027dc163e2ec1b371579c07739bef06240b5c46c | Ruby | gersonnascimento/lita_chatbot | /lita-teste/lib/lita/handlers/teste.rb | UTF-8 | 761 | 2.609375 | 3 | [] | no_license | module Lita
module Handlers
class Teste < Handler
route(/tudo bem\?/, :resp_tudo_bem)
route(/seu nome\?/, :resp_nome)
route(/categorias/, :categories) #teste com api de categorias do mercado livre
def resp_tudo_bem(response)
response.reply('Tudo ótimo, e você?')
end
... | true |
4b12bfcb6dec1fc1fead8399508bbcebf9376eb5 | Ruby | champgm/workflow_shell | /src/WorkflowShell/misc/ConvertDags.rb | UTF-8 | 908 | 2.96875 | 3 | [] | no_license | require_relative '../models/Command'
class ConvertDags < Command
@command_string
@command_description
@command_usage
def initialize
@command_string = 'dags'
@command_description = 'Converts all *.dot files to PNG files.'
@command_usage = @command_string
end
DOT_FILE_EXTENSION = '.dot'
PNG_F... | true |
a73a29c9d23f0dedd8bb34cdd030aa6f8ceba13e | Ruby | gh0std4ncer/intrigue-core | /tasks/twitter_gather_following.rb | UTF-8 | 2,173 | 2.6875 | 3 | [] | no_license | require 'twitter'
class TwitterGatherFriends < BaseTask
def metadata
{ :version => "1.0",
:name => "twitter_gather_friends",
:pretty_name => "Twitter Gather Friends",
:authors => ["jcran"],
:description => "Gather twitter accounts the provided user is following",
:references => [],
... | true |
42434e343c607b866e34665433799f3b1d6ac329 | Ruby | daleathan/geddiff | /lib/place.rb | UTF-8 | 171 | 2.6875 | 3 | [] | no_license | #place.rb
#License: LGPLv2.1 or later
#Copyright: Josh Hansen
class Place
attr_accessor :name
def initialize
@name = nil
end
def initialize(name)
@name = name
end
end | true |
04a8bc71a7e3964e8229b5a0fc8bf0d0a1513ff9 | Ruby | greck2908/MISR-Toolkit | /wrappers/ruby/src/test/mtk_coordinate_test.rb | UTF-8 | 328 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
require "mtk_file"
require "test/unit"
class MtkCoordinateTest < Test::Unit::TestCase
def test_block_to_lat_lon
lat, lon = MtkCoordinate.block_to_lat_lon(23, 1100, 10, 0, 0)
assert_in_delta lat, 76.833, 0.001
assert_in_delta lon, 63.097, 0.001
... | true |
deba8c46597ec800fda49d318caba6f7c7884f67 | Ruby | petrosliu/Mentor-Matching-System | /features/support/paths.rb | UTF-8 | 1,996 | 2.609375 | 3 | [] | no_license | # TL;DR: YOU SHOULD DELETE THIS FILE
#
# This file is used by web_steps.rb, which you should also delete
#
# You have been warned
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case p... | true |
3dca1559f237676427c4dd4edc97d8cf044c0d7d | Ruby | ccedacero/programming-univbasics-4-finding-the-minimum-value-in-an-array-lab-nyc04-seng-ft-041920 | /lib/find_the_minimum_value.rb | UTF-8 | 196 | 3.40625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_min_value(array)
i = 1
min_value = array[0]
while i < array.length do
if(min_value > array[i])
min_value = array[i]
end
i +=1
end
return min_value
end
| true |
fe21073b510117bef1b0be96d70d24a996b1c495 | Ruby | Warshavski/booky-api | /app/queries/application_query.rb | UTF-8 | 790 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
# ApplicationQuery
#
# Used as base class for all queries and contains common logic
# (sorting and common filtration flow)
#
class ApplicationQuery
include Sortable
include Filterable
class << self
attr_reader :default_scope
def options(options)
@default_scope ... | true |
18a8bfa194421f29e4c42501743904e65ea0205d | Ruby | Megumi-0712/Ruby_practice-part2 | /hello_with_default.rb | UTF-8 | 187 | 3.375 | 3 | [] | no_license | def hello(name="Ruby")
puts "Hello, #{name}." #ここに引数を予め指定する
end
hello() #引数を省略して呼び出す
Hello("Newbie") #引数をしていて | true |
c8f88bca8457e7b006c01958df004aec3f26d35f | Ruby | Mcheyo/sinatra-mvc-lab-dc-web-120919 | /models/piglatinizer.rb | UTF-8 | 564 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(string)
input = string.split(" ")
pig_input_array = pig_latinizer(input)
pig_input_array.join(" ")
end
def pig_latinizer(array)
array.map do |letter|
l = letter
if l.start_with?("a", "e", "i", "o", "u", "A", "E", "I", "O", "U")
l + "way"
else
... | true |
a2a3f95694a165c7a55bd96b3281cf6c2f35ed46 | Ruby | natenorberg/monstercheckout_rails | /app/modules/conflict_checker.rb | UTF-8 | 2,210 | 2.96875 | 3 | [] | no_license | module ConflictChecker
# TODO: Get tests around this
# TODO: Complex method
def conflicts(params)
# Get the other reservations to check agains
# TODO: Be more selective here
if params[:id]
other_reservations = Reservation.where.not(id: params[:id])
else
other_reservations = Reservatio... | true |
89d38cee3ab5d48a0c3768ce294b34349b0b4565 | Ruby | erikbenton/AppAcademyFullStackOnline | /Ruby/LRU/notes.rb | UTF-8 | 2,085 | 3.6875 | 4 | [] | no_license | # Sets
# Set Ints
# Resizing Int Set
# Approaching O(1)
# How a Hash is formed
# ========
# Hashes
# ========
# Deterministic
# Uniform
# Highly-sensitive
# Ideally non reverse-engineerable
# Types of functions
# Fast hashing fns
# Cityhash
# CRC32
# Mumurhash
# Cryptographic
# MD5 - Bad
... | true |
bf233365669168d03e93988e5f4ab949cfca9f3b | Ruby | goodjobbin85/cartoon-collections-online-web-pt-120919 | /cartoon_collections.rb | UTF-8 | 535 | 3.4375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(elf_set)
# Your code here
elf_set.each_with_index do |elf, index|
puts "#{index + 1}. #{elf}"
end
end
def summon_captain_planet(hero_call)
# Your code here
hero_call.collect do |name|
"#{name.capitalize}!"
end
end
def long_planeteer_calls(set)
# Your code here
set.a... | true |
1fabe92da0de0f76cf1a1781ca9dfe97f4aed5f1 | Ruby | Catsuko/birthday-greetings-kata | /lib/people/from_hash.rb | UTF-8 | 410 | 3.1875 | 3 | [] | no_license | module People
class FromHash
STRING_FORMAT = "<Person %s>"
def initialize(details = {})
@details = details
end
def fill_out
yield self, @details
end
def to_s
STRING_FORMAT % @details
end
def ==(other)
other.is_a?(self.class) && other.fill_out { |_p, details|... | true |
b8a441c4db7885c6c2e8b0863db6615293fd1922 | Ruby | Repep/inrubing | /03/better_calc.rb | UTF-8 | 295 | 3.1875 | 3 | [] | no_license | a = gets.chomp.to_f
oper = gets.chomp
b = gets.chomp.to_f
case oper
when "+"
result = a + b
when "-"
result = a - b
when "*"
result = a * b
when "/"
result = a / b
else
puts "Неверная операция"
end
puts "#{a} #{oper} #{b} = #{result}" if result | true |
4beb35d873e76b53f7398d0ea1a92e435e95e0b8 | Ruby | macald/Ruby-Class1 | /hashes.rb | UTF-8 | 443 | 4.09375 | 4 | [] | no_license | # OPTION 1
# ========================
# my_hash = {"jan" => "January", "feb" => "February"}
# my_hash["mar"] = "March"
# my_hash.each do |key, val|
# puts "#{key} and #{val}"
# end
# puts my_hash["jan"]
# puts my_hash.length
# OPTION 2
# ========================
my_hash = {:jan => "January", :feb => "February"}
... | true |
943ba072c2ca6aa46faaba8bca05c31b306e503c | Ruby | bhemingway/Analytics1 | /app/helpers/reports_helper.rb | UTF-8 | 2,164 | 2.78125 | 3 | [] | no_license | module ReportsHelper
# GenRept is a simple dispatch routine, calling report generation based on ID
def GenRept(report)
# parameter is a report job description
rproc_id = report.report
period_name = report.period
# expand period name into parameters
period = Hash.new()
@periods.each do |tmp... | true |
8266957ec746ed1f5f66e6092cca66ba83d3bc5c | Ruby | jbarreneche/Ploc | /lib/ploc/semantic_context.rb | UTF-8 | 3,271 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'ploc/address'
require 'ploc/constant'
require 'ploc/procedure'
require 'ploc/scope'
require 'ploc/variable'
require "forwardable"
module Ploc
class SemanticContext
attr_reader :scope
attr_accessor :source_code
extend Forwardable
def_delegators :@scope, :constants, :variables, :procedures
... | true |
f2d57c0bf34e993a2c369565d4b38376bf61a923 | Ruby | nerab/manbook | /bin/manbook | UTF-8 | 2,458 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
help = <<HELP
The manbook command can be used to produce an eBook from one or more man pages.
Author: Nicolas E. Rabenau nerab@gmx.at
Homepage: http://rubydoc.info/gems/manbook/file/README.md
Basic Usage:
manbook <MANPAGE>
manboo... | true |
642c02d9867bc0006892ec4ff64371d13e011765 | Ruby | anilktechie/rb2py | /fixes/upto.rb | UTF-8 | 438 | 2.75 | 3 | [
"Zlib"
] | permissive | # x.upto(y) {|i| b}
# ==>
# for i in range(x, y + 1):
# b
class UptoNode < BlockFixNode
alias from first_child
alias to second_child
alias statements third_child
def initialize(block)
super(block)
assign_children [block.target, block.send_node.arguments[0], block.statements]
@argument_na... | true |
8c80a43c9500858b7e1c1df772f9b183dd363d92 | Ruby | CaptainSpectacular/black_thursday | /lib/customer_repository.rb | UTF-8 | 1,117 | 3.234375 | 3 | [] | no_license | require_relative 'customer'
require_relative 'data_analyst'
# This is the CustomerRepository class
class CustomerRepository
attr_reader :customers, :parent
def initialize(csv, parent)
@customers = []
@parent = parent
DataAnalyst.find_attributes(csv).each do |attribute|
@customers << Customer.new(i... | true |
4ed5c13a80a8850714dd32d547461fd370fe9db8 | Ruby | Idayat8703/square_array-v-000 | /square_array.rb | UTF-8 | 117 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
arra = []
array.each do |number|
arra.push(number * number)
end
return arra
end
| true |
723b37d9bd39d6c2593979779400f6b5b4a422fb | Ruby | cymen/ttt-ruby | /spec/negamax_spec.rb | UTF-8 | 2,889 | 2.984375 | 3 | [] | no_license | require 'negamax'
require 'rspec/expectations'
RSpec::Matchers.define :have_optimal_move_of do |expected|
match do |actual|
(actual.max_by {|_, value| value }).first == expected and actual.values.count(actual.values.max) == 1
end
failure_message_for_should do |actual|
"expected that #{actual.to_s} max va... | true |
e9e2a1fc4a1f046746b4a5a00bac1c895c69e873 | Ruby | pecavalheiro/bowling | /app/services/bonus_processor.rb | UTF-8 | 1,277 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
class BonusProcessor < ApplicationService
attr_reader :current_frame, :current_player, :pending_bonuses
def initialize(frame)
@current_frame = frame
@current_player = frame.player_id
@pending_bonuses = \
Bonus.where('player_id = ? AND game_id =? AND throws_to_sum > ... | true |
a8df931e2ef6178ac069ec050348e52ce039464e | Ruby | lukemelia/rake-pipeline-web-filters | /lib/rake-pipeline-web-filters/chained_filter.rb | UTF-8 | 1,443 | 2.546875 | 3 | [] | no_license | module Rake::Pipeline::Web::Filters
class MemoryFileWrapper < Struct.new(:root, :path, :encoding, :body)
def with_encoding(new_encoding)
self.class.new(root, path, new_encoding, body)
end
def fullpath
File.join(root, path)
end
def create
self.body = ""
yield
end
... | true |
f126ab63de40727ffa20ab9defc423cb5336c2f5 | Ruby | ryancurtin/data_structures | /ruby/binary_tree.rb | UTF-8 | 476 | 3.46875 | 3 | [] | no_license | class Tree
attr_accessor :left, :right, :value
def initialize(l, r, v)
@left = l
@right = r
@value = v
end
end
bt = Tree.new(Tree.new(Tree.new(Tree.new(nil, nil, 4), nil, 6), nil, 8), Tree.new(nil, Tree.new(nil, Tree.new(nil, nil, 16), 14), 12), 10)
def tree_depth(tree)
if tree.nil?
return ... | true |
8ca800e5e2849ccfd755c2bd1010f85eec01ba42 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/etl/715a698ebf2c4016b305756a2ed80e07.rb | UTF-8 | 164 | 3 | 3 | [] | no_license | class ETL
def self.transform(hash)
result = Hash.new
hash.each do |key,value|
value.each do |v|
result[v.downcase] = key
end
end
result
end
end
| true |
c290f04f56b79a3f4348436aec617e2f0eb9f56d | Ruby | yisin2015/CanvasGames | /codegen.rb | UTF-8 | 1,050 | 3.109375 | 3 | [
"MIT"
] | permissive | def get_file_names(dir)
files = []
Dir.entries(dir).each do |entry|
if entry == '.' or entry == '..' or entry == ".DS_Store"
next
end
path = File.join(dir, entry)
if File.file? path
files << entry
end
end
files
end
def gen_image_load(game_name)
images = get_file_names("#{game_... | true |
868ba0f816a38d55e307c37a0d76478e3fb25d76 | Ruby | Catherina87/practice | /ruby/deck_of_cards.rb | UTF-8 | 539 | 4.53125 | 5 | [] | no_license | # Create a deck of cards with attributes like suit and value.
# Shuffle the deck of cards. (can't use .shuffle)
def create_deck
suits = ["Hearts", "Diamonds", "Spades", "Clubs"]
values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Ace', 'Jack', 'Queen', 'King']
deck = []
suits.each do |suit|
values.... | true |
960dcda8cb5e989d3ec89f9e115ca086fa3ad478 | Ruby | ichiro101/I18n-utils | /bin/lcount | UTF-8 | 1,342 | 3.71875 | 4 | [
"BSD-2-Clause-Views"
] | permissive | #!/usr/bin/env ruby
require 'yaml'
module LCount
def print_help
puts "lcount - Locale Word Count Utility"
puts ""
puts "lcount will help count the number of words in a locale file"
puts "Usage: lcount [path to a yml file]"
end
def lcount(file_string)
puts "Attemting to count #{file_string}"
begin
... | true |
3d69d9f11abf844b37e652f3238f9ff3f38ced17 | Ruby | pattilouhoo/skillcrush-repository1 | /blog.rb | UTF-8 | 2,382 | 4.3125 | 4 | [] | no_license | # simple blog - challenge from 104 lesson 14
# create a class that will be a blueprint for each "BlogPost" object. Requires title, content, publish date and author.
# do this by modifying the initialize method or create a custom method
# use logic to create a prompt saying "do you want to create another blog post? [Y/... | true |
601e69b6abade78d68e368c15b53628295c55be1 | Ruby | Kreyren/benchmarks | /json/test.rb | UTF-8 | 690 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'json'
require 'socket'
def notify(msg)
begin
Socket.tcp('localhost', 9001) { |s|
s.puts msg
}
rescue
# standalone usage
end
end
engine = "#{RUBY_ENGINE}"
if engine == "truffleruby"
desc = "#{RUBY_DESCRIPTION}"
if desc.include?('Native')
engine = "TruffleRuby Native"
elsif de... | true |
20f18508ae80962bbacf3f2bf77970c3b2ec3d15 | Ruby | calblueprint/veterans360-web | /db/seeds.rb | UTF-8 | 2,362 | 2.578125 | 3 | [
"MIT"
] | permissive | # Create Veterans
def create_veterans
veterans = []
rng = Random.new(934857239324211115710)
num_roles = Veteran::ROLE_KEYS.count
# Create 10 Veterans with random names and some random roles
10.times do |i|
veteran = Veteran.create(
first_name: FFaker::Name.first_name,
last_name: FFaker::Name.... | true |
6df912b2ce5b2c12112ad0c9588ec759a79cd2c2 | Ruby | boychamhoctoanlyanh/ruby-ex | /array/ex8.rb | UTF-8 | 261 | 3.46875 | 3 | [] | no_license | puts "Nhap mang: "
array=Array.new
i=0
until(i==-1)
i=gets.to_i
if(i>=0)
array.push i
end
end
puts array.inspect
puts "Nhap x:"
x=gets.to_i
puts "Nhap k:"
k=gets.to_i
if(k>array.length)
puts "Nhap sai"
else
array.insert(k-1,x)
end
puts array.inspect
| true |
b01e876229307c95a79d47b035a9debfd9ee866e | Ruby | Sayuki-co/connect | /app/helpers/companies_helper.rb | UTF-8 | 443 | 2.5625 | 3 | [] | no_license | module CompaniesHelper
def occupation(status)
if status == "stay"
return "今あるのもを活かす!"
elsif status == "create"
return "これから作り出す!"
elsif status == "future"
return "現状を知って未来を作る!"
elsif status == "etc"
return "その他"
else
... | true |
28e2173df7bd2a221fbd21ac8772d599fc9979b2 | Ruby | xeger/mime-message | /lib/mime/message.rb | UTF-8 | 5,734 | 3.4375 | 3 | [] | no_license | module MIME
# A MIME message, consisting of headers (stored as a Hash) and a body (array of lines in the
# message).
#
module Message
# Matches any potential CR/LF-like sequence. This is more tolerant than RFC822, but useful in
# cases where someone has run a message through a non-CRLF operating system.... | true |
966387f10e9db8d2f74ec3eae36342f25c2fa9f9 | Ruby | quarter-spiral/facebook-client | /lib/facebook-client/authenticated.rb | UTF-8 | 400 | 2.703125 | 3 | [] | no_license | module Facebook
class Client
class Authenticated
attr_reader :client, :access_token
def initialize(client, access_token)
@client = client
@access_token = access_token
end
def friends_of(user_id)
client.adapter.friends_of(user_id, access_token)
end
def... | true |
346a8ccff1fd3082a7c7e1bb10f654d3e8f7c727 | Ruby | wisdom-apps/sufi | /data/en.rb | UTF-8 | 566 | 3.203125 | 3 | [] | no_license | # 5-24 - " - escape
file_in = "en.txt"
file_out = "info.en.js"
p "read file: #{file_in}"
f = File.open(file_in).read
f2 = File.open(file_out, 'w')
f2 << 'items["en"] = [' << "\n"
# 'm-d': '1-2'},
# 1-1:
# text
#
row = {}
f.each_line.each do |line|
line.chop!
if line.end_with?(':')
row = {}
row[:da... | true |
4cfed6e7581dc57922dd8556eeaad406156461f2 | Ruby | StrongMind/canvas_shim | /spec/services/alerts_service/alert_spec.rb | UTF-8 | 1,410 | 2.59375 | 3 | [
"MIT"
] | permissive | class TestAlert < AlertsService::Alert
ALERT_ATTRIBUTES = [:teacher_id]
def type
'test_alert'
end
def description
'my description'
end
def detail
'my detail'
end
end
describe AlertsService::Alert do
subject { TestAlert.new(teacher_id: 1) }
let(:attributes) { { alert: { teacher_id: 1... | true |
a9016a5353b0971b10aa5972760a5ba4f908645e | Ruby | HungOm/11JuneExercises | /dog_project/lib/dog.rb | UTF-8 | 797 | 3.734375 | 4 | [] | no_license |
class Dog
def initialize (name,breed,age,bark,favorite_foods)
@name = name
@breed = breed
@age = age
@bark = bark
@favorite_foods = favorite_foods
end
def name
@name
end
def breed
@breed
end
def age
@age
end
... | true |
292f85a75c326f5c7c61eb94af5d4522fcf2355d | Ruby | jliu9/git-timeofday | /git-timeofday | UTF-8 | 5,367 | 2.890625 | 3 | [] | no_license | #! /usr/bin/env ruby
begin
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
rescue LoadError
raise 'You must gem install win32console to use color on Windows'
end
def main
results = {}
max_count = 0
args = ARGV
if args.size > 0
@authors = authors = args
else
authors = get_authors
end
... | true |
4b50eaa3f61ef411956bb6b05849a2e4beb7ae4a | Ruby | dino-dna/brewbase | /api/services/webhook_processor.rb | UTF-8 | 1,304 | 2.546875 | 3 | [] | no_license | require 'digest'
require 'date'
require 'json'
require File.expand_path '../../models/datum.rb', __FILE__
require File.expand_path '../../models/device.rb', __FILE__
class WebhookProcessor
attr_reader :webhook_data, :processor
def initialize(webhook_data, processor: Particle)
@webhook_data = webhook_data
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.