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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dac1df608709c9fa1bdd8f0d3002bdadaf8361f4 | Ruby | ismglv/info-search-homeworks | /first_hw/app/services/lemmatizator.rb | UTF-8 | 613 | 3.421875 | 3 | [] | no_license | require 'pry'
require 'stemmify'
class Lemmatizator
def call
binding.pry
puts words
end
private
def read_stop_words
result = []
File.open("/Users/ismglv/dev/info-search-homeworks/stop-words.txt", "r") do |f|
f.each_line do |line|
result << line.strip
end
end
resul... | true |
b2e9b72ca19f8756c56e8c19195410e3dd3741bb | Ruby | hectorip/PolymerHackTests | /bower_components/miscelanea/ruby/Fibonacci.rb | UTF-8 | 134 | 3.609375 | 4 | [] | no_license | def fibonacci( n )
[ n ] if ( 0..1 ).include? n
( fibonacci( n - 1 ) + fibonacci( n - 2 ) ) if n > 1
end
puts fibonacci( 5 )
| true |
395f230cb0d51d96d26c5aba9560bea5c3c4b53b | Ruby | zachjamesgreen/food-midmod | /app/lib/foods.rb | UTF-8 | 231 | 3.09375 | 3 | [] | no_license | class Foods
attr_reader :total_hits
def initialize(foods)
@foods = foods['foods'].map do |food|
Food.new(food)
end
@total_hits = foods['totalHits']
end
def foods(num = 10)
@foods.first(num)
end
end | true |
04ea437b2d4a831708f7d516e142c139ea38c4b1 | Ruby | Solveug/Tutorial-Simdyanov | /chapter15/task5.rb | UTF-8 | 491 | 2.890625 | 3 | [] | no_license | str = 'Возьмите текст этого задания и извлеките из него все слова, которые начинаются с символа "и".
Сформируйте из них список уникальных слов и выведите их в порядке увеличения количества символов в слове.'
arr = str.downcase.split.select{|el| el.start_with? 'и'}.uniq.sort{|a, b| a.size <=> b.size}
arr.each{ |el| puts... | true |
6a822c072b7dd523e4348bea3cdc3389d50a15d1 | Ruby | pomyslowynick/top_master | /05_hangman/main.rb | UTF-8 | 2,550 | 3.703125 | 4 | [
"MIT"
] | permissive | class Hangman
require 'io/console'
require 'json'
def Hangman.random_word
word = File.readlines("5desk.txt")
rand_word = word[rand(61407)]
unless rand_word.length.between?(5, 12)
rand_word = word[rand(61407)]
end
rand_word
end
@@user_input = []
... | true |
bf1eff92725bfa5e4289dff573e9518b720a9345 | Ruby | cquiro/namoy | /spec/models/recipe_spec.rb | UTF-8 | 3,135 | 2.765625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Recipe, type: :model do
it "is valid with name, time_ready, quantity, flavor, ingredients, instructions and image" do
recipe = build(:lemon_recipe)
expect(recipe).to be_valid
end
it "is invalid without a name" do
recipe = build(:natural_recipe, name: nil)
re... | true |
b6b3d1a32b030865516f6b95ffba0ea8e7a12ff6 | Ruby | frescoraja/ruby_chess | /pieces/queen.rb | UTF-8 | 236 | 2.640625 | 3 | [] | no_license | require_relative 'piece'
require_relative 'slideable'
# Queen Class
class Queen < Piece
include Slideable
def symbols
{ white: '♕', black: '♛' }
end
protected
def directions
straightmoves + diagmoves
end
end
| true |
1febc4d233a29825c6b01d56132c6e18b36e5937 | Ruby | ingilniero/design_patterns_in_ruby | /lib/builder_pattern/board_builder.rb | UTF-8 | 503 | 3.015625 | 3 | [] | no_license | module Builder
class BoardBuilder
attr_reader :board
def initialize(width, height, difficulty)
@board = Builder::Board.new width: width, height: height, difficulty: difficulty
end
def add_tiles(type, number)
message = "create_#{type}_tiles"
@board.tiles = Builder::TileFactory.send(... | true |
81ffb3c03c744a342bde967ea609b229a6af6514 | Ruby | andreika58/askme | /app/models/question.rb | UTF-8 | 828 | 2.546875 | 3 | [] | no_license | class Question < ApplicationRecord
validates :text, length: { maximum: 255, too_long: "Max allowed lenght is 255" }
# Эта команда добавляет связь с моделью User на уровне объектов, она же
# добавляет метод .user к данному объекту.
#
# Когда мы вызываем метод user у экземпляра класса Question, рельсы
#... | true |
8d883f7c224ccb19b145759f8448c17c02a8b107 | Ruby | rogerbraun/wadoku-scripts | /kanatoroma.rb | UTF-8 | 2,402 | 2.609375 | 3 | [] | no_license | # coding: utf-8
HEPBURNTAB = "\
ぁ xa あ a ぃ xi い i ぅ xu
う u う゛ vu う゛ぁ va う゛ぃ vi う゛ぇ ve
う゛ぉ vo ぇ xe え e ぉ xo お o
か ka が ga き ki きゃ kya きゅ kyu
きょ kyo ぎ gi ぎゃ gya ぎゅ gyu ぎょ gyo
く ku ぐ gu け ke げ ge こ ko
ご go
さ sa ざ za し shi しゃ sha しゅ shu
しょ sho じ ji じゃ ja じゅ ju じょ jo
す su ず zu せ se ぜ ze そ so
ぞ zo
た ta だ da ち chi ち... | true |
a3ce055d14cb518b3f7c5ff6b93d4aae537c926b | Ruby | DanielJWagener/app-academy-exercises | /intro-to-programming/conditionals/longer_string.rb | UTF-8 | 254 | 3.609375 | 4 | [] | no_license | def longer_string(str1, str2)
if str1.length < str2.length
return str2
end
return str1
end
puts longer_string("app", "academy") # => "academy"
puts longer_string("summer", "fall") # => "summer"
puts longer_string("hello", "world") # => "hello" | true |
b276789675db5b0ed79a546c2ebf5971d5c40b0d | Ruby | balkian/SWCM | /ServidorConcurrente/servidor.rb | UTF-8 | 1,776 | 3.109375 | 3 | [] | no_license | # Concurrent Server
# Juan Fernando Sánchez Rada
# Sergio Díaz Bautista
# SWCM 2010/11
#
require 'socket'
numCon = 0
maxCon=10
port = 8080
if(ARGV.length>0)
port = ARGV[0].to_i #Extrae el puerto del primer argumento
end
if(ARGV.length>1)
if((c=ARGV[1].to_i)>0) then maxCon=c end #Cambia las conexiones si es
... | true |
3b8766e378965f3bf0837aa250e49e6814189758 | Ruby | chattermill/huginn | /app/models/agents/dropbox_file_url_agent.rb | UTF-8 | 2,573 | 2.578125 | 3 | [
"MIT"
] | permissive | module Agents
class DropboxFileUrlAgent < Agent
include DropboxConcern
cannot_be_scheduled!
no_bulk_receive!
description <<-MD
The _DropboxFileUrlAgent_ is used to work with Dropbox. It takes a file path (or multiple files paths) and emits events with either [temporary links](https://www.dropb... | true |
ba7003673935b170f6cb3f41536e486afe8efd2b | Ruby | ivanvrkic/rails-academy---rails-homework-ivanvrkic | /spec/domains/open_weather_map/city_spec.rb | UTF-8 | 3,713 | 2.8125 | 3 | [] | no_license | RSpec.describe OpenWeatherMap::City, :city do
it 'initialises values correctly' do
city = described_class.new(id: 2_172_797, lat: -16.92, lon: 145.77, name: 'Cairns',
temp_k: 300.15, weather: 'Sun')
expect(city.id).to eq(2_172_797)
expect(city.lat).to eq(-16.92)
expect(... | true |
5fa38ef228f54f231e7999c414c9ab8b1f99a74d | Ruby | liamhealy/silicon-valley-code-challenge-nyc-web-091619 | /app/models/startup.rb | UTF-8 | 1,829 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Startup
attr_accessor :name
attr_reader :founder, :domain
@@all = []
def initialize(name, domain, founder)
@name = name
@domain = domain
@founder = founder
@@all << self
end
def pivot(name, domain)
@name = name
@domain = domain
en... | true |
73b0710cfe1bb7b5a1f86aeb2b8bd6b92a617052 | Ruby | asb1512/oo-student-scraper-online-web-sp-000 | /lib/scraper.rb | UTF-8 | 2,159 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
# Makes HTTP requrest for required URL.
html = open(index_url)
# Parses webpage HTMl into a nested array of hashes.
webpage = Nokogiri::HTML(html)
students_array = []
... | true |
dbf513692f97a9d4216ee0bb232a5d82b66c5493 | Ruby | maurokobayashi/vivento | /app/helpers/date_helper.rb | UTF-8 | 482 | 2.765625 | 3 | [] | no_license | #encoding: utf-8
module DateHelper
def to_brazillian_date(date)
if !date.nil?
date.strftime('%d/%m/%Y')
else
nil
end
end
def to_brazillian_datetime(datetime)
if !datetime.nil?
datetime.strftime('%d/%m/%Y %H:%M:%S')
else
... | true |
1f817c8e7df17a20626225d70207d78876da3f4a | Ruby | Mandaryn/ordinalizatron | /spec/will_paginate_ordinalizatron_spec.rb | UTF-8 | 775 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'support/will_paginate/post'
describe Ordinalizatron do
before(:all) do
setup_database
i = 0
10.times { Post.create(value: "name#{i+=1}") }
end
after(:all) do
cleanup_database
end
describe "will_paginate array" do
let(:array) { Post.paginate(page: 2, per_pa... | true |
e52405d5fd1e2033b2db37ff3c813da3c3a88906 | Ruby | woodie/coding_challenges | /tableify.rb | UTF-8 | 431 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
list = %w(Adam Brett Cari Donna Ethan Fred Grok Han Izzy Jay)
columns = 3
def tableify(list, columns)
rows = (list.length.to_f / columns).ceil
result = Array.new(rows) {[]}
list.length.times do |i|
result[i % rows] << list[i]
end
result
end
puts tableify(list, columns).inspect.gsub... | true |
936d435946f429af2fefe718d427c4e8e528292e | Ruby | TeaganBriggs/exchange_wrapper_gem | /lib/exchange_wrapper/poloniex/utils.rb | UTF-8 | 3,418 | 2.6875 | 3 | [
"MIT"
] | permissive | # ::ExchangeWrapper::Poloniex::Utils
# https://poloniex.com/support/api/
module ExchangeWrapper
module Poloniex
class Utils
class << self
# def holdings(key, secret) # string, string
# raise ::Exceptions::InvalidInputError if key.nil? || secret.nil?
# holdings = {}
# :... | true |
773a2c5b6c96caefa4f6d588c97fbe87cf325edc | Ruby | Lucasquivron/lucasquivron | /07-Reboot/Calculette/interface.rb | UTF-8 | 420 | 3.546875 | 4 | [] | no_license | require_relative "calculate"
answer = "y"
while answer == "y"
puts "Entrez un premier chiffre"
x = gets.chomp.to_i
puts "Entrez un deuxième chiffre"
y = gets.chomp.to_i
puts "Entrez un opérateur (+,-,*)"
s = gets.chomp
if s == "+" || s == "-" || s =="*"
total = calculate(x,y,s)
else
puts "Erreu... | true |
c552ebf1eb30f12d79d294c7dc0537278c436df0 | Ruby | enrikacreates/bewd-hw | /hw01/mash.rb | UTF-8 | 2,533 | 3.40625 | 3 | [] | no_license | ### Enrika Greathouse- HW 2 - mash_api
require 'httparty'
url = "http://mashable.com/stories.json"
data = HTTParty.get(url)
channel_array = []
puts "Data from Mashable"
puts "-------------------\n\n\n"
puts"==========================="
puts"==========================="
puts" NEW ARTICLES "
puts"======... | true |
00719b29ab35aaea5427ab7b31ed8eecbed3c54c | Ruby | jmettraux/volute | /spec/filter_not_spec.rb | UTF-8 | 884 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
require File.join(File.dirname(__FILE__), 'spec_helper.rb')
describe 'a volute with a :not as first arg' do
before(:each) do
@item = Item.new
@invoice = Invoice.new
end
describe 'and classes as further args' do
before(:each) do
Volute.clear!
volute :not, Item do
object.com... | true |
e531d8fada8c77365f170e498cb8217fe0e777b4 | Ruby | jonwhuang/phase-0 | /week-5/pad-array/my_solution.rb | UTF-8 | 3,798 | 4.375 | 4 | [
"MIT"
] | permissive | # Pad an Array
# I worked on this challenge with Albert Hahn.
# I spent 1.5 hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input?
# What i... | true |
43e319ce874dce75f78415edf50e203fc62c2470 | Ruby | Sunstrike/Tossbot | /modules/FactoidBackend.rb | UTF-8 | 3,147 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -wKU
## Tossbot
## => Factoid backend
#
# Copyright (C) 2013 Sunstrike
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without l... | true |
5d45ee35f904b7c26fe5b20d1d672af98e081e13 | Ruby | songgz/wiz_med | /app/models/chapter.rb | UTF-8 | 967 | 2.578125 | 3 | [] | no_license | # encoding: utf-8
class Chapter
include Mongoid::Document
include Mongoid::Tree
field :title, type: String #标题
field :name, type: String #正式名
field :alias, type: Array #别名
field :summary, type: String #概要
field :content, type: String #内容
embeds_many :ingredients, class_name:'Ingredi... | true |
96ac7302d0386b19c5923a6f9b68b190e6c29f81 | Ruby | bdurand/simple_thread_pool | /lib/simple_thread_pool.rb | UTF-8 | 2,427 | 3.21875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'thread'
require 'set'
# Simple thread pool for executing blocks in parallel in a controlled manner.
# Threads are not re-used by the pool to prevent any thread local variables from
# leaking out.
class SimpleThreadPool
def initialize(max_threads)
@max_threads = max_thread... | true |
d8dd7a3f5413659db1c2344847db0659ac3b49e6 | Ruby | Yofel/pangea-tooling | /git-monitor/lib/semaphore.rb | UTF-8 | 3,886 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
#
# Copyright (C) 2014-2016 Harald Sitter <sitter@kde.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your... | true |
5c086b8225169e5abdb97da4463a7cb944e1f40a | Ruby | eugenmueller/rao | /rao-view_helper/app/view_helpers/rao/view_helper/base.rb | UTF-8 | 725 | 2.625 | 3 | [
"MIT"
] | permissive | module Rao
module ViewHelper
# Example:
#
# # app/view_helpers/unit_view_helper.rb
# class UnitViewHelper < ViewHelper::Base
# def cent_per_kwh(value)
# "#{value} ct/kWh"
# end
# end
#
# # app/controllers/application_controller.rb
# c... | true |
7474aeb238b88e42ad735e963e583e988c583f63 | Ruby | coalest-zz/launch_school | /exercises/watch_others_code/4_2.rb | UTF-8 | 1,776 | 4.25 | 4 | [] | no_license | =begin
-----------------------INSTRUCTIONS--------------------------------------
Write a function scramble(str1, str2) that returns true if a portion of
str1 characters can be rearranged to match str2, otherwise return false.
--------------------------PROBLEM----------------------------------------
Input: two strings... | true |
dc7912e6c08f1a8a5d3225fda9a8bbd09ebcdd74 | Ruby | weberjavi/ironhack | /week2/day1/sinatra_TODO/lib/todo.rb | UTF-8 | 684 | 2.984375 | 3 | [] | no_license | class Task
attr_reader :content, :id, :complete, :created_at, :updated_at
@@current_id = 1
def initialize(content, completed = false, created_at = Time.now)
@content = content
@id = @@current_id
@@current_id += 1
@completed = completed
@created_at = created_at
... | true |
3a5333faaddca88cce4170d62db417875156c064 | Ruby | BaptisteHamain/promo-2-challenges | /03-AR-Database/07-Hackernews-AR-basics/lib/interface.rb | UTF-8 | 1,030 | 3.78125 | 4 | [] | no_license | require_relative 'config/application'
require_relative 'models/post'
def ask_and_get(param)
puts "What is the #{param} of your piece of news?"
gets.chomp
end
while true
puts "Hey you, what do you want to do today? Enter <task_id>"
puts "1. Create a post"
puts "2. Read your posts"
puts "3. Delete all post... | true |
cd04d962046e961d33fcbd17438c0273710d470e | Ruby | handlez36/BlackJack | /app/models/user.rb | UTF-8 | 1,781 | 2.71875 | 3 | [] | no_license | class User < ActiveRecord::Base
belongs_to :game
has_many :cards
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
def card_count... | true |
3a444dbaa6e47a31284957ce565ea90dd5ebf765 | Ruby | shime/i_did_mean | /test/autocorrect/variable_name_autocorrect_test.rb | UTF-8 | 1,725 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "test_helper"
class VariableNameCheckTest < Minitest::Test
def test_autocorrects_method_typo
assert_autocorrects %(
def first_name; end
flrst_name
), %(
def first_name; end
first_name
)
end
def test_autocorrects_variable_typo
assert_... | true |
92e80da4811511590c50e83544e6a88df0fa983c | Ruby | LX-pro-dev/crazy_scrapper | /lib/deputies.rb | UTF-8 | 2,024 | 2.96875 | 3 | [] | no_license | require 'pry'
require 'dotenv'
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Return all the deputies' names from the website
def get_deputes_name
arr_deputies_name = []
# Register URL's website
url_deputies = "http://www2.assemblee-nationale.fr/deputes/liste/alphabetique"
deputy_page = Nokogiri:... | true |
3b8e07a1165dca8370afd17945dd021d2e7b7c5b | Ruby | wise-king-sullyman/chess | /spec/piece_spec.rb | UTF-8 | 8,843 | 3.15625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../lib/pieces/piece'
class DummyClass
include Piece
def possible_moves(row, column)
end
# this is to give an easy to find method name for testing #callers_include?
def foo(function_name_as_string)
callers_include?(function_name_as_string)
end
end
desc... | true |
75a5b2c846503900ab27ffe147895391c90a2ef6 | Ruby | anujpan/ruby-music-library-cli-online-web-pt-092418 | /lib/genre.rb | UTF-8 | 472 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
attr_accessor :name
attr_reader :songs
extend Concerns::Findable
@@all = []
def initialize(name)
@name = name
@songs = []
end
def self.all
@@all
end
def self.destroy_all
all.clear
end
def save
self.class.all.push(self)
end
def add_song(song_o... | true |
e64e635a73648ce28317aeb3aff29980880f6141 | Ruby | pawelduda/codeeval-ruby-solutions | /easy/166.rb | UTF-8 | 1,424 | 3.40625 | 3 | [] | no_license | # https://www.codeeval.com/browse/166/
def delta_time(time_1, time_2)
# separate hours, minutes, seconds
time1_separated = time_1.split(':').map(&:to_i)
time2_separated = time_2.split(':').map(&:to_i)
delta_time = []
# get time difference in seconds
time1_seconds = time1_separated[2] + time1_separated[1]... | true |
74844060b7b0dfe2bf6493316725f137625db30a | Ruby | abraxaslee/LeetCode | /817.rb | UTF-8 | 546 | 3.109375 | 3 | [
"MIT"
] | permissive | # 817. Linked List Components
# 57 / 57 test cases passed.
# Status: Accepted
# Runtime: 68 ms
require 'set'
# @param {ListNode} head
# @param {Integer[]} g
# @return {Integer}
def num_components(head, g)
targets = Set.new(g)
counter = 0
result = 0
cur = head
while cur != nil
... | true |
1cb74f650726bc3dd7130a584ca64ac2c2989149 | Ruby | sg45000/ruby-lesson | /lesson1.rb | UTF-8 | 1,580 | 4.0625 | 4 | [] | no_license | # FizzBuzz
require './fizzbuzz'
nums=1..100
nums.each do |num|
fizz_buzz num
end
=begin
コメントが長い場合はこのように書ける
=end
#変数名はスネークケースで書くこと
special_price = 200
#2つ以上の値を同時に代入できる
a,b=1,2
p a
p b
#シングルクオート、ダブルクオート
puts 'He said, "Don\'t speak."'
#数値の _ は無視される
p 1_000_000_000
#to_fメソッドでfloat化できる
n... | true |
080513208f579265fd562a309acd77f6b00b6c64 | Ruby | southpawgeek/perlweeklychallenge-club | /challenge-187/roger-bell-west/ruby/ch-1.rb | UTF-8 | 870 | 3.171875 | 3 | [] | no_license | #! /usr/bin/ruby
require 'test/unit'
require 'time'
def s2date(ds)
/^(\d+)\-(\d+)$/ =~ ds
return Time.new(2022, $2, $1, 0, 0, 0, "+0000")
end
def daystogether(a, b)
starts = [s2date(a[0]), s2date(b[0])].sort
ends = [s2date(a[1]), s2date(b[1])].sort
if ends[0] >= starts[1] then
return (ends[0]-starts[1... | true |
44684d198561a10d00710e8b2f8b032d40b04421 | Ruby | cielavenir/procon | /codeforces/tyama_codeforces1023B.rb | UTF-8 | 68 | 2.734375 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
n,k=gets.split.map &:to_i
p [[n,k-1].min-k/2,0].max
| true |
4aa4fd4e0cf9d6374daa90d0b8c7288600cd5ff2 | Ruby | mindreframer/api-stuff | /github.com/lanej/cistern/lib/cistern/attributes.rb | UTF-8 | 4,113 | 2.59375 | 3 | [
"MIT"
] | permissive | module Cistern::Attributes
def self.parsers
@parsers ||= {
:string => lambda{|v,opts| v.to_s},
:time => lambda{|v,opts| v.is_a?(Time) ? v : v && Time.parse(v.to_s)},
:integer => lambda{|v,opts| v && v.to_i},
:float => lambda{|v,opts| v && v.to_f},
:array => lambda{|v,opts| [*... | true |
672b4da7c89da167a5cfac9fccb9b352f9865a6a | Ruby | darklight721/guess_who | /lib/guess_who_no_fuzzy/comparator.rb | UTF-8 | 365 | 3 | 3 | [
"MIT"
] | permissive | module GuessWhoNoFuzzy
module Comparator
def self.better?(contender, best, contender_length, best_length)
if contender >= best
if contender == best # if the same score, go with simpler option
contender_length <= best_length
else # if not the same score, we have a winner!
... | true |
ed1422a380b4916fb2fc24040f0dbff51b692874 | Ruby | evfurio/finders | /Common/Services/src/REST/cybersource_tokenization_resource.rb | UTF-8 | 1,417 | 2.53125 | 3 | [] | no_license | # == Overview
# This calss is used to simplify d-con script writers interaction with the Rest Agent
#
# Refer to the parent base class (RestService) for more information.
#
# == Usage
# config = RestAgentConfig.new
# config.set_user_agent('iPhone')
# config.set_option("accept", 'application/json; charset = utf-8')
# co... | true |
421fe22915368671efd364ebf0877c52978fa6ac | Ruby | maestrano/mno-api-sandbox | /app/controllers/api/v1/base_controller.rb | UTF-8 | 3,137 | 2.6875 | 3 | [
"MIT"
] | permissive | # This controller is inherited by all API controllers
# It is used to automatically retrieve the current_app
# corresponding to the cloud service contacting us
#
# The controller uses http basic authentication and
# retrieves the app based on its api token
class Api::V1::BaseController < ApplicationController
before_... | true |
722bf93db393f76037c36e4d1713f302ecf6b03c | Ruby | abdulrahmannmohamed/W2D4-CW | /anagrams.rb | UTF-8 | 1,711 | 3.796875 | 4 | [] | no_license | def anagram?(str1, str2)
permutations(str1.split('')).join.include?(str2)
end
def permutations(array)
return [array] if array.length == 1
first = array.shift
perms = permutations(array)
total_perms = []
perms.each do |perm|
(0..perm.length).each do |idx|
total_perms << perm[0...idx] + [first]... | true |
7002615b8fe382eb2291d711612f07d98b2f2fe3 | Ruby | shinob/guestcard | /lib/al_graph.rb | UTF-8 | 43,741 | 2.703125 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
# alone : application framework for small embedded systems.
# Copyright (c) 2010-2011
# Inas Co Ltd., FAR END Technologies Corporation,
# All Rights Reserved.
#
# This file is destributed under BSD License. Please read the COPYRIGHT file.
#
#
#
req... | true |
a1b87088c2d338d0e4c2c8138b048b8205b85263 | Ruby | rcyep87/day3 | /class-fun.rb | UTF-8 | 5,228 | 3.96875 | 4 | [] | no_license | # # # class Student
# # # CAMPUS = 'ATX'
# # # def sleep
# # # puts "Goes to bed"
# # # end
# # # def study
# # # puts "studies"
# # # end
# # # end
# # # VERSION = "1.1.1"
# # # # Creating an instance of the class Student and
# # # # Assigning it to the variable 'jacob'
# # # # Without this you ... | true |
71fff0b7717e8efc761bfdb2a73523f93762edce | Ruby | nick-stebbings/ruby_simple_exercises | /numdiv.rb | UTF-8 | 329 | 3.65625 | 4 | [] | no_license | def valid_number?(number_string)
number_string.to_i.to_s == number_string
end
answer = 0.0
puts ">> Give me a number"
num1 = gets.chomp
puts ">> Give me another number"
num2 = gets.chomp
(valid_number?(num1) && valid_number?(num2) && num2.to_i !=0)? (puts "#{num1}/#{num2} is #{answer=(num1.to_f)/(num2.to_i)}") : (pu... | true |
5d86138e22b1683ef7e1e69bfaca4d8ea7f2f787 | Ruby | kengos/cdigits | /spec/cdigits/luhn/store_spec.rb | UTF-8 | 4,255 | 2.9375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe Cdigits::Luhn::Store do
let(:obj) { described_class.new(modulus: modulus, digits: digits) }
let(:modulus) { 10 }
let(:digits) { nil }
describe '#sum' do
subject { obj.sum }
context 'when modulus = 10, digits = [7, 8, 9]' do
let... | true |
41937de0a51d23386831e72b43d6020d5b45cd6e | Ruby | xpositivityx/SommTest | /randaddscratch.rb | UTF-8 | 368 | 2.765625 | 3 | [] | no_license | def pick_answers subreg
answers = Array.new(4)
regs = Subregion.order("RANDOM()").limit(6)
answers.each_with_index do |v, i|
if i == 0
answers[i] = subreg.subregion.name
else
regs.each do |item|
if !answers.include? item.name
answers[i] = item.name
break
end
end
end
end
retur... | true |
efd65d1fa496a638bc91d4fa9ac799ae3b791202 | Ruby | ganmacs/playground | /ruby/rack/dsl.rb | UTF-8 | 510 | 3.28125 | 3 | [] | no_license | class A
def initialize(name, &block)
@name = name
instance_eval(&block) if block_given?
end
def map(path, &block)
set(:get, path, block)
end
def get(path)
key = [:get, path]
route_table[key].call
end
private
def set(name, path, block)
key = [name, path]
route_table[key] =... | true |
27fd78c9f4e45510185e3da75349d55afaa157f2 | Ruby | StephenSanchez05/school-domain-online-web-pt-110419 | /lib/school.rb | UTF-8 | 460 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_accessor :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(name, grade)
@roster ||= @roster[grade] = "#{name}"
if @roster.include?(grade)
@roster[grade] << "#{name}"
else @roster[grade] = ["#{name}"]
end
end
def grad... | true |
75a8b1357ebcdccf80b8f244fcefd08b5f2dcf79 | Ruby | mob1970/dagen | /test/test_simple_item_with_plain_text_source.rb | UTF-8 | 2,426 | 2.6875 | 3 | [] | no_license | # Done because RubyMine has a bug which doesn't allow to set LOAD_PATH values
$LOAD_PATH.push("~/Development/dagen/lib/dagen/")
require "test/unit"
require 'items/simple_item_with_plain_text_source.rb'
class TestSimpleItemWithPlainTextSource < Test::Unit::TestCase
##
#
#
def test_object_creation()
item =... | true |
95ab021fac688378dc867b1f9e2487dbc34a21a7 | Ruby | rabinpoudyal/learning-rspec | /calculator/calculator.rb | UTF-8 | 229 | 3.375 | 3 | [] | no_license | class Calculator
def self.add(first, second)
first + second
end
def self.substract(first, second)
first - second
end
def self.multiply(first, second)
first * second
end
end
| true |
c967fb6252dd67e3d1f9e1829c240ac97d4bb263 | Ruby | teubanks/design_patterns | /builder/ruby/frame.rb | UTF-8 | 187 | 2.59375 | 3 | [] | no_license | class Frame
FRAME_TYPES = [ :car, :truck ]
attr :frame_type
def initialize(frame_type: frame_type)
# Unimplemented: validate frame types
@frame_type = frame_type
end
end
| true |
f14e6a2a3cd588a6c8e8e0354dde9f9d812f102e | Ruby | amandeep1420/RB120 | /Exercises/CO2/1_greeting.rb | UTF-8 | 207 | 3.578125 | 4 | [] | no_license | class Cat
def self.generic_greeting # technically able to define it as def Cat.generic_greeting as well
puts "Hello! I'm a cat!"
end
end
kitty = Cat.new
puts kitty.class
kitty.class.generic_greeting | true |
b68e4297f7ad146e4a88fe89a1a78d0828de208d | Ruby | StevenACZ/ruby-exceptions-testing-StevenACZ | /28people/people.rb | UTF-8 | 1,031 | 4.28125 | 4 | [] | no_license | class UnpronounceableName < StandardError
def initialize(message = "This name is unpronounceable")
super(message)
end
end
class InvalidAge < StandardError
def initialize(message = "This age is not possible")
super(message)
end
end
class Person
attr_reader :name, :age
def initialize(name: "", age:... | true |
ae42821b9f2671f05b38c4820b511506eea7cb5f | Ruby | mingder78/zombieTest | /spec/lib/zombie_spec.rb | UTF-8 | 382 | 2.765625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "zombie"
describe Zombie do
it "is named Ash" do
zombie = Zombie.new
zombie.name.should == 'Ash'
end
it "has no brain" do
zombie = Zombie.new
zombie.brains.should be < 1
end
it "is alive" do
zombie = Zombie.new
zombie.alive.should == false
end
it "is hungry" do
... | true |
1e9ccb789ca3568d28cde49bca9c245dc7d103d6 | Ruby | jonjpeterkin/rails-url-helpers-lab-web-0916 | /app/models/student.rb | UTF-8 | 278 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Student < ActiveRecord::Base
after_initialize :init
def init
self.active = false if self.active.nil? && self.has_attribute?(:active)
end
def to_s
self.first_name + " " + self.last_name
end
def toggle_active
self.active = !self.active
save
end
end | true |
7dfba77875186c9e0dc6f8c9dc80daa897418ce9 | Ruby | darrenburgess/launch-school-object-oriented-programming | /lesson_02/many_pets.rb | UTF-8 | 507 | 3.9375 | 4 | [] | no_license | class Person
attr_accessor :name, :pets
def initialize(name)
@name = name
@pets = []
end
end
class Pet
def speak(sound)
sound
end
end
class Cat < Pet
def claws_sharp?
true
end
end
class Dog < Pet
def claws_sharp?
false
end
def swims?
true
end
end
bob = Person.new("ro... | true |
e69b9700ef6e6e890dd6d94915ec8d1e84ba61da | Ruby | wata727/analysis-example | /interpreter/denotational/function/update.rb | UTF-8 | 162 | 2.875 | 3 | [] | no_license | class Update
def initialize(name, val)
@name = name
@val = val
end
def call(state)
state.update(@name.call(state), @val.call(state))
end
end
| true |
29747111ae6cdb3dea5433e7e6fb6cb8867aad1b | Ruby | monkeywidget/puzzles | /ruby/first_letter_that_is_twice.rb | UTF-8 | 3,346 | 4.09375 | 4 | [] | no_license | # Problem statement:
# Given a string,
# print the first letter that appears which appears twice in the entire string
def first_twice_letter(source_string)
seen_before = []
source_string.downcase.split('').each do |letter|
if seen_before.include?(letter)
puts "First duplicate letter in >>#{source_string}... | true |
ac2f3757b178d5ee79a77a84759f1d7fe2e802e1 | Ruby | kevgathuku/exercism | /ruby/hamming/hamming.rb | UTF-8 | 359 | 3.453125 | 3 | [] | no_license | module BookKeeping
VERSION = 3
end
class Hamming
def self.compute(first, second)
raise ArgumentError, "String lengths don't match" unless first.size == second.size
# Prefer each_char, which returns an Enumerator
# chars converts the enumerator to an array
first.each_char.zip(second.each_char).count... | true |
e22d3c86eaa4338c7ffc60da5e7c006d14241303 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/73b693e5b5ca4e52b3693bfef5c070be.rb | UTF-8 | 433 | 3.40625 | 3 | [] | no_license | module Hamming
def self.compute a, b
DNA.new(a).ham_with DNA.new(b)
end
class DNA
def initialize sequence
@sequence = sequence.split('')
end
def ham_with other
diff(other).size
end
def diff other
o_indexed = other.indexed
indexed[0...o_indexed.size] - o_indexed
... | true |
00bd32d5268f7527d052383249544d40216a6d0a | Ruby | tcollier/sommelier | /lib/sommelier/match_catalog.rb | UTF-8 | 2,184 | 3.34375 | 3 | [
"MIT"
] | permissive | require_relative 'descending_insertion_sort_array'
require_relative 'preference'
class Sommelier
# A collection of all matches to consider for pairing up dishes and wines.
class MatchCatalog
attr_reader :max_dish_preferences
def initialize
@dishes = {}
@wines = {}
@max_dish_preferences =... | true |
ac9650838652552fbec3e43ece8dd9612ea2ec4c | Ruby | justinkrol/AdventOfCode | /lib/2019/Day5/solution_1.rb | UTF-8 | 276 | 2.8125 | 3 | [] | no_license | require_relative 'intcode_computer'
INPUT_FILE = 'input.txt'
line = File.open("#{__dir__}/#{INPUT_FILE}") { |file| file.readline }
memory = line.split(",").map { |s| s.to_i }
intcode_computer = IntcodeComputer.new
intcode_computer.memory = memory
intcode_computer.process!
| true |
091abd339356a812224c0777bbb2dd5790f95b38 | Ruby | fangxiao-dong/range_calcuoator | /range_calculator_test.rb | UTF-8 | 2,374 | 2.828125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'range_calculator'
module SdetTest
class RangeCalculatorTest < MiniTest::Test
def setup
@range_calculator = RangeCalculator.new
end
def test_range_calculator_simple
actual = @range_calculator.calculate_range(1, 10, [3, 5, 7])
expected = %w[1-... | true |
7662dd2b14253fcf569cef9e8ec55974b6968477 | Ruby | skateonrails/codechallenge | /spec/lib/poro/london_train_graph_spec.rb | UTF-8 | 1,407 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe LondonTrainGraph do
before :all do
@graph = LondonTrainGraph.new
end
describe '.find_path' do
pending "Not Implemented Yet"
end
describe '.find_shortest_path' do
it 'return array with stations in sequence' do
source = Station.find(114) #Harrow & Weald... | true |
7ee7f0f8c5bd59c4fa137f3e90ea5aeb44620a86 | Ruby | marinalimeira/moltres | /spec/moltres/array_spec.rb | UTF-8 | 310 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'moltres/array'
require 'spec_helper'
describe Array do
context ".sum" do
it "sums values inside array" do
expect([1,2,3,4].sum).to be_eql 10
end
end
context ".subtraction" do
it "sums values inside array" do
expect([-5,2,1,1].subtraction).to be_eql 1
end
end
end
| true |
e91d47ff8bf46ebdba9dff511f0eb2f47c1a37fd | Ruby | Lerati00/black_jack | /black_jack/deck.rb | UTF-8 | 463 | 3.328125 | 3 | [] | no_license | require_relative 'card.rb'
class Deck
attr_reader :cards
def initialize
create_new_deck
end
def create_new_deck
@cards = []
Card::SUITS.each do |suit|
Card::RANKS.each do |rank|
@cards << Card.new(rank, suit)
end
end
end
def mix_deck
cards.shuffle!
end
def to... | true |
2aa0836ccf92c82531716bd013cba418c3b534b2 | Ruby | dalbert23/phase-0-tracks | /ruby/nested_data_structures.rb | UTF-8 | 903 | 3.140625 | 3 | [] | no_license | apartment = {
bedroom: {
occupant: 'David',
items: ['bed', 'dresser', 'mirror', 'bookshelf']
},
kitchen: {
occupants: 'everyone',
items: ['pan', 'spoon', 'fork', 'filter'],
appliances: {
dish_washer: 1,
fridge: 2
}
}
living_room: {
occupants: 'everyone',
items: ['couch', 'TV', 'sofa', 'the ... | true |
e71c602d9ea950fc48e8b0ec1d314f88388e501d | Ruby | fulldecent/html-proofer-mailto_awesome | /lib/mailto_awesome.rb | UTF-8 | 882 | 2.546875 | 3 | [
"MIT"
] | permissive | require "html/proofer/mailto_awesome/version"
module Html
module Proofer
module MailtoAwesome
class Error < StandardError; end
class MailToAwesome < ::HTMLProofer::Check
def mailto?
return false if @link.ignore? || @link.href.nil?
@link.href.match /^mailto:/i
end
... | true |
1134b5c43467acc48b608d580bd2d31b48820703 | Ruby | jbrunton/jira-team-metrics | /spec/mql/jira_team_metrics/mql_expr_parser_spec.rb | UTF-8 | 3,111 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
RSpec.describe JiraTeamMetrics::MqlExprParser do
class TestExprParser < Parslet::Parser
include JiraTeamMetrics::MqlLexer
include JiraTeamMetrics::MqlOpParser
include JiraTeamMetrics::MqlExprParser
root :expression
end
let(:parser) { TestExprParser.new }
it "parses int... | true |
117afe81c5733d117a3cf5fca7c949cec924e5d2 | Ruby | colimit/ruby-tram | /lib/ruby_tram/params.rb | UTF-8 | 1,937 | 3.328125 | 3 | [] | no_license | require 'uri'
class Params
def initialize(req, route_params = {})
@params = parse_www_encoded_form(req.query_string || "")
@params.deep_merge!(parse_www_encoded_form(req.body || ""))
@params.deep_merge!(route_params)
@permitted_keys = []
end
def [](key)
@params[key]
end
def permit(*k... | true |
cb9486a9554066f774a5e8e721fc32e2aaf45504 | Ruby | step1profit/yamlr | /lib/yamlr/writer.rb | UTF-8 | 1,794 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'yamlr/writer/builder'
module Yamlr
module Writer
class EmptyFilenameError < StandardError; end
class EmptyInputError < StandardError; end
class InvalidInputError < StandardError; end
class InvalidFilenameError < StandardError; end
# array, hash, or string to array of lines of .yml file
... | true |
7784069f8f28584b0d5df19bec6f5e01bd80578f | Ruby | torianin/Budget-app-database | /custom_logger.rb | UTF-8 | 272 | 2.6875 | 3 | [] | no_license | require 'stringio'
require 'logger'
def get_execute_time(sql_command)
strio = StringIO.new
l = Logger.new strio
DB.loggers << l
DB.execute(sql_command)
puts "#{sql_command} => #{/\((.*)s\)/.match(strio.string)[1]}"
return /\((.*)s\)/.match(strio.string)[1].to_f
end | true |
7d8353bfa35a04e6256098253a94d5bdb071723d | Ruby | jeter1208/Ruby | /day2.rb | UTF-8 | 368 | 3.140625 | 3 | [] | no_license | desc "印bar"
# 描述
task :foo do
puts "bar"
end
task :default =>"db:migrate"
# rake -T 查看描述
# block_given? 查看有沒有block
list =[1 , 2 , 3 , 4 ,5]
def my_select(arr)
result = []
arr.each do |i|
result << i if yield(i)
end
result
end
# list =[1 , 2 , 3 , 4 ,5]
p my_select([1, 2, ... | true |
353371b295544951981a7c7f78eb06e35c63c5e3 | Ruby | PerpetuumMobile/ruby-l2p | /chapter_04/ask_for_name_and_greet.rb | UTF-8 | 378 | 4.03125 | 4 | [] | no_license | #Write a program which asks for a person's first name, then middle, then last. Finally, it should greet the person using their full name.
puts 'What is your first name?'
fname = gets.chomp
puts 'What is your middle name?'
mname = gets.chomp
puts 'What is your last name?'
lname = gets.chomp
name = fname + ' ' + mname +... | true |
420f424d22cccf3904ef5368e32d51e753f85d7d | Ruby | LouisSayers/zen-search | /lib/zen_search.rb | UTF-8 | 794 | 2.890625 | 3 | [] | no_license | module Commands end
class ZenSearch
def initialize(prompter, outputter, commands, data_store)
@prompter = prompter
@outputter = outputter
@commands = commands
@data_store = data_store
end
def run
begin
loop do
command_mappings = commands_by_name
selected_option = @prom... | true |
93fbcfbb42268f2269dcfdc1bfa574d94d8d97c7 | Ruby | furafura/square_array-001-prework-web | /square_array.rb | UTF-8 | 125 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def square_array(array)
# your code here
newArray = []
array.each{|x| newArray.push(x**2)}
newArray
end | true |
268b6a223b8c9b86058487c805bf1afb88ae150b | Ruby | balastan/comfortable-mexican-sofa | /lib/comfortable_mexican_sofa/content/tags/file_link.rb | UTF-8 | 1,779 | 2.515625 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | # This is how you link previously uploaded file to anywhere. Good example may be
# a header image you want to use on the layout level.
# {{cms:file_link id, as: image}}
#
# `as` - url (default) | link | image - how file gets rendered out
# `label` - attach label attribute to link or image tag
# `resize` - ima... | true |
e64a2bdae592cd1ea621fce3eb7f4dc612c9bdd7 | Ruby | m1key/m1key_gallery_generator | /lib/m1key_gallery_generator/viewable_photo.rb | UTF-8 | 700 | 2.515625 | 3 | [
"MIT"
] | permissive | module GalleryGenerator
class ViewablePhoto
attr_reader :id, :title, :description, :metadata, :technical_info
def initialize(id, title, description, metadata, technical_info)
@id = id
@title = title
@description = description
@metadata = metadata
@technical_info = technical_info
... | true |
6e3cfe53b8256f9c46a73255caf47d31f48b8b27 | Ruby | alpharez/ohsoccer | /app/models/team.rb | UTF-8 | 771 | 2.578125 | 3 | [] | no_license | class Team < ActiveRecord::Base
belongs_to :club
belongs_to :division
has_many :homegames, :class_name => "Game", :foreign_key => "hometeam_id"
has_many :awaygames, :class_name => "Game", :foreign_key => "awayteam_id"
has_many :games
has_many :team_assignments
has_many :users, :through => :team_assignment... | true |
42319957ff1633782eced0149c47da8a4301aad4 | Ruby | elma635/ruby-objects-has-many-lab-nyc-web-051319 | /lib/artist.rb | UTF-8 | 1,317 | 4.09375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative '../lib/song.rb'
class Artist
attr_accessor :name #dont need to call song here bc it's not holding all the responsibility.
@@all = [] #first part is setting the class
@@counter = 0 #bc we're need song count later so we'll declare in add song --bc everytime we add a song it'll run it.
def initi... | true |
85880631f0ef9a2ee4ad324f3eac827c77ec1bb3 | Ruby | mbhung101/apples-and-holidays-prework | /lib/holiday.rb | UTF-8 | 2,564 | 4.125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
# return the second element in the 4th of July array
holiday_hash.each do |season,holiday|
holiday.each do |name,stuff|
if name == :fourth_of_july
return stuff[1]
end
end
end
end
def add_supply_to_winter_holidays... | true |
91c0d80fe07dfe3ff019b34360627ab657f22cca | Ruby | rupindermonga/RubyPractice | /t27.rb | UTF-8 | 127 | 2.59375 | 3 | [] | no_license | File.open("employees.txt","a") do |file|#"a" is for appending at the end of the file
file.write("\nOscar, Accounting")
end
| true |
adcbda130c6d7a9a42eb5df55ac95e5725591dde | Ruby | hohemarie/GoogleSearcher | /04_mailsender_ruby_file.rb | UTF-8 | 2,247 | 2.765625 | 3 | [] | no_license | #architecture du dossier
#app.rb
#Gemfile
#Gemfile.lock
#.env
#.gitignore
#lib
#---app
#------application.rb
#------email_sender.rb
#---views
#------views.rb
#spec
#------application_spec.rb
#------email_sender_spec.rb
#------spec_helper.rb
def parent_directory
system("cd ..")
end
def create_folder2
adresse='/hom... | true |
94fc3a582d64cf825b95d0754b1ca39d3d07328e | Ruby | Nazmul1216/ruby-oo-relationships-practice-art-gallery-exercise-nyc01-seng-ft-060120 | /app/models/donor.rb | UTF-8 | 144 | 3.21875 | 3 | [] | no_license | class Donor
attr_reader :name, :amount
@@all=[]
def initialize(name, amount)
@name=name
@amount=amount
end
end | true |
abe75d40e7d37368a47721f9287c1a698233390a | Ruby | samover/learn_to_program | /ch10-nothing-new/ninety_nine_bottles_of_beer.rb | UTF-8 | 1,516 | 4.03125 | 4 | [] | no_license | # LEARNING TO PROGRAM WITH CHRIS PINE, 9.5 ex 1
###############################################
# “Ninety-nine Bottles of Beer on the Wall.” Using english_number and your
# old program on page 49, write out the lyrics to this song the right way this
# time. Punish your computer: have it start at 9999. (Don’t pick a num... | true |
4da19b20d4822437a7d8bf4d052ab9a0da26ca06 | Ruby | pawan9489/TeachingRuby | /DemoCode/Session2/3.Arrays/9.IncludeMethod.rb | UTF-8 | 451 | 4.34375 | 4 | [
"Unlicense"
] | permissive | # 9. Include Method # whether an array contains an element or not
puts
puts "================================================================="
puts "Include Method"
puts "================================================================="
# In ruby methods ending with ? will signify that they return true or false
# Pre... | true |
6abffe4d254f83fa143d7402db0cc83b2ff8ff53 | Ruby | pbragamiranda-teaching/inheritance-class-methods-self | /test.rb | UTF-8 | 431 | 3.109375 | 3 | [] | no_license | require_relative 'restaurant'
mangai = Restaurant.new(
"Mangai", "Brasilia", 500, "brasileira")
# p mangai
# puts "O restaurante #{mangai.name} fica em #{mangai.city}"
# puts "São #{Time.now.hour} horas e
# o #{mangai.name}
# está #{mangai.open? ? "aberto" : "fechado"}"
# puts mangai.... | true |
f99a43dde3a9a984afa32f4b61154d3405a9b1eb | Ruby | michaeltranlong/ruby_lib | /lib/appium_lib/common/touch_actions.rb | UTF-8 | 1,620 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | module Appium
# Perform a series of gestures, one after another. Gestures are chained
# together and only performed when `perform()` is called. Default is conducted by global driver.
#
# Each method returns the object itself, so calls can be chained.
#
# @example
#
# action = TouchAction.new.press(x:... | true |
358b84ed5b06f3b6ed907c497e2bf0cba3765b82 | Ruby | roboconf/roboconf.github.io | /validate-structure.rb | UTF-8 | 7,228 | 3.0625 | 3 | [
"CC-BY-3.0"
] | permissive | #!/usr/bin/ruby
# We use Ruby as this script is executed on Travis CI
# with a Ruby configuration (Jekyll, our web site generator, is a Ruby gem).
# The following assertions are verified:
# - All the files referenced in "_data/*.yml" files exist.
# - Referenced MD files have the right layout.
# - Referenced MD file... | true |
d61dff26ebfd723e2b2d867650b45a1a8a9dfeaf | Ruby | guilffer/kanbangit | /spec/kanbangit/item_spec.rb | UTF-8 | 1,531 | 2.71875 | 3 | [] | no_license | require 'kanbangit/item'
require 'kanbangit/environment'
require 'helper'
describe Kanbangit::Item do
let(:env) {Kanbangit::Environment.new('/')}
let!(:instance) {described_class.new('nome', env)}
after { FileUtils.rm(instance.itemfile_path) }
describe '.name' do
it { instance.name.should == 'nome' }
e... | true |
8ca46341d354fdeb9de72f0230bde3ce0c9f4213 | Ruby | mikeebert/foundry-public | /lib/datastore/dm_datastore/models/apprenticeship.rb | UTF-8 | 1,856 | 2.84375 | 3 | [] | no_license | require 'data_mapper'
require 'weeks'
require 'date'
class Apprenticeship
include DataMapper::Resource
property :id, Serial
property :start_date, Date, :required => true
property :end_date, Date, :required => true
property :created_at, DateTime
property :updated_at, DateTime
belong... | true |
66d8eef764c2c88c61b5050122bc60e30dc43b34 | Ruby | TuanNguyen1010/Bookmark_manager | /bookmark_manager/lib/bookmark_class.rb | UTF-8 | 739 | 3.078125 | 3 | [] | no_license | require 'pg'
class Bookmark
attr_reader :title, :url
def initialize(title, url)
@title = title
@url = url
end
def self.all
# connection = PG.connect dbname: "bookmark_manager", user: ENV["USER"]
data = CONNECTION.exec("select * from bookmarks")
result = []
data.each {|saved_bookmark|... | true |
2fc746b6a28b4cdef706ca6db3352488fcbeaf00 | Ruby | FcoMaturana19/mayor-que-4 | /mayor_que_4_numeros.rb | UTF-8 | 591 | 3.40625 | 3 | [] | no_license | valor_1 = ARGV[0].to_i
valor_2 = ARGV[1].to_i
valor_3 = ARGV[2].to_i
valor_4 = ARGV[3].to_i
if ARGV[3] == nil
if valor_1 > valor_2 && valor_1 > valor_3
puts "El valor #{valor_1} es mayor"
elsif valor_2 > valor_3 && valor_2 > valor_1
puts "El valor #{valor_2} es mayor"
else
puts "El v... | true |
a7a34ec2ae660f7516442fe0d2736d00d157dcd9 | Ruby | funmia/bank_tech_test | /lib/debit.rb | UTF-8 | 256 | 3.078125 | 3 | [] | no_license | class Debit
attr_reader :amount, :current_balance
def initialize(amount, current_balance)
@amount = -amount
@current_balance = current_balance
@created_at = Time.now
end
def date_created
@created_at.strftime("%d/%m/%Y")
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.