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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0c08e397152bf936afbeccd24b1d0d4856faa89f | Ruby | siman-man/my_ruby_tips | /joke/all_result_inverse.rb | UTF-8 | 660 | 2.703125 | 3 | [] | no_license | klasses = ObjectSpace.each_object(Module).reject {|k| k.singleton_class? }.sort_by(&:to_s)
klasses -= [ARGF.class, BasicObject]
methods = {}
klasses.reject! do |k|
methods[k] = k.instance_methods(false).select {|m| m.to_s.end_with?('?') } - [:respond_to?]
methods[k].empty?
end
klasses.each do |k|
k.class_eval(... | true |
3c5139692ace2f6b8d91b500c44b8a02ddcd7f1e | Ruby | aidenmendez/BotSavesPrincess | /Bot_Saves_Princess_2/lib/princess.rb | UTF-8 | 168 | 2.859375 | 3 | [] | no_license | class Princess
attr_reader :x, :y, :coords
def initialize(grid)
@x = grid.locate_princess[0]
@y = grid.locate_princess[1]
@coords = [@x, @y]
end
end
| true |
d2e3ca7a2c67ebbd1cdb02fd824bc040e17662f1 | Ruby | jergason/decision_tree | /runner.rb | UTF-8 | 1,878 | 2.765625 | 3 | [] | no_license | $:.push "."
require 'bundler'
Bundler.require(:default)
require 'lib/decision_tree'
require 'lib/cross_validation'
def graph_tree(tree, filename)
puts "in graph_tree"
g = GraphViz.new(:G, :type => :digraph)
id3_root = tree.instance_variable_get("@root")
root = g.add_node(id3_root.label)
recursive_graph(g, r... | true |
3544ce77de8c446e31e6fd8a754968f4880d76a2 | Ruby | makern/knife-vagrant2 | /lib/chef/knife/vagrant_server_delete.rb | UTF-8 | 2,388 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | require 'chef/knife/vagrant_base'
# These two are needed for the '--purge' deletion case
require 'chef/node'
require 'chef/api_client'
class Chef
class Knife
class VagrantServerDelete < Knife
include Knife::VagrantBase
banner "knife vagrant server delete SERVER [SERVER] (options)"
attr_read... | true |
b5649d398de6b253e08f8e4048569128d1ef8be2 | Ruby | alu0100696585/prct05 | /tc_racional.rb | UTF-8 | 778 | 2.84375 | 3 | [] | no_license | # Implementar en este fichero las Pruebas Unitarias asociadas a la clase Fraccion
require "./racional.rb"
require "test/unit"
class Test_Fraccion < Test::Unit::TestCase
def setup
@p1 = Fraccion.new(3,5)
@p2 = Fraccion.new(2,3)
end
def tear_down
#nothing
end
def test_simple
ass... | true |
50ade05ab3939309498ea32575e511a911c77037 | Ruby | catalistt/Ruby | /mayor_de_4.rb | UTF-8 | 1,090 | 3.5 | 4 | [] | no_license | ##################################################################
# OBTENCIÓN DE NÚMEROS DESDE EL USUARIO #
##################################################################
num1 = ARGV[0].to_f
num2 = ARGV[1].to_f
num3 = ARGV[2].to_f
num4 = ARGV[3].to_f
#Se deja todo en formato "float" por ... | true |
042cad5ec7749cd34c57dad29daf943e2a0383be | Ruby | yazgoo/prysless | /lib/prysless.rb | UTF-8 | 5,808 | 2.859375 | 3 | [
"MIT"
] | permissive | require "prysless/version"
require 'pry'
require 'pstore'
require 'fileutils'
require 'net/ssh'
# Public: Utilities to make ruby object accessible via pry
#
# Examples
#
# Prysless::Shell.new
module Prysless
# Public: Pry store allowing to pass and persist data between sessions
# Data can be accessed either... | true |
ee9e3f9f4eb2f934cb26cd0eb0763f6eecc5a87b | Ruby | florapetersen/ruby-class-variables-and-class-methods-lab-onl01-seng-pt-052620 | /lib/song.rb | UTF-8 | 956 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist, :genre
@@count = 0
@@genres = []
@@artists = []
def initialize(name, artist, genre)
@@count += 1
@name = name
@artist = artist
@genre = genre
@@genres << genre
@@artists << artist
end
def self.count
return @@count
end
def self.g... | true |
52d92b337f6e9f718183f06886d844a9cf80f250 | Ruby | bitdomo/bs2 | /Scripts/_.37.rb | UTF-8 | 4,463 | 2.578125 | 3 | [] | no_license | =begin
#==============================================================================
[名前] ステートの残りターン数表示+α
[作者] 焼きノリ
[配布元] まったりツクール雑貨 http://mata-tuku.ldblog.jp/
#------------------------------------------------------------------------------
[更新履歴]
・2012/10/28 公開
・2012/12/01 不具合修正。「表示優先度0のステートアイコン非表示」機能... | true |
9f5f2489e8381c2c8e8aa0d50b82e57fc1015048 | Ruby | karagenit/commit-time-github | /user.rb | UTF-8 | 395 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative 'commit-time-github'
# TODO: throw error if missing ARGVs
repos = get_all_repos(File.read('api.token'), ARGV[0])
# TODO: display progress info for queries
repos.each do |repo|
name = repo[:name]
times = repo[:times]
# TODO: format into columns
puts "#{name}: #{(times.to... | true |
1774f6c23c37f52f36bea34f52ea603885db18d5 | Ruby | mhdz9/cbeasy | /3_LongestWord.rb | UTF-8 | 468 | 4.375 | 4 | [] | no_license | #Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string.
#If there are two or more words that are the same length, return the first word from the string with that length.
#Ignore punctuation and assume sen will not be empty.
def LongestWord(sen)
longest = "... | true |
342c079170ca9f169ed7ec3691eb6254a79cfb28 | Ruby | ArmandoAmador/ruby-exercises | /twelvedaysofchristmas.rb | UTF-8 | 813 | 3.53125 | 4 | [] | no_license | @song_array = [
'A Partridge in a Pear Tree', 'Two Turtle Doves', 'Three French Hens',
'Four Calling Birds', 'Five Gold Rings', 'Six Geese a-laying',
'Seven Swans a-Swimming', 'Eigth Maids a-Milking', 'Nine Ladies Dancing',
'Ten Lords a-Leaping', 'Eleven Pipers Piping', 'Twelve Drummers Drumming'
]
@order = [
... | true |
528c019226110d0216f3d5950c8f48d628a9abce | Ruby | Nenry/W2D3- | /TDD/TDD_methods/lib/TDD_methods.rb | UTF-8 | 915 | 3.515625 | 4 | [] | no_license | def my_uniq(arr)
count_hash = Hash.new(0)
arr.each {|el| count_hash[el] += 1 }
count_hash.keys
end
class Array
def two_sum
result = []
self.each_with_index do |el1, idx1|
self.each_with_index do |el2, idx2|
next if idx1 >= idx2
result << [idx1, idx2] if self[idx1] + self[idx2]... | true |
52f897396756289da6cfb111b65374a3877842b7 | Ruby | campoore2/Pingping-Ruby | /lib/pingPong.rb | UTF-8 | 400 | 3.0625 | 3 | [] | no_license | class Fixnum
define_method(:pingPong) do
number_array=[]
numbers = (1..self)
numbers.each() do |number|
if number.%(15) == 0
number_array.push('pingpong')
elsif number.%(5) == 0
number_array.push('pong')
elsif number.%(3) == 0
number_array.push('ping')
else... | true |
4d2a1110e8db1823c418dd7d0d48ee780b1bbe92 | Ruby | azach/split_words | /split_words.rb | UTF-8 | 1,394 | 3.40625 | 3 | [] | no_license | require 'csv'
require 'rambling-trie'
class SplitWords
class UnknownWordError < StandardError; end
attr_reader :string, :trie
def self.populate_trie(trie: trie, file_path: file_path)
raise 'Invalid file' unless File.exists?(file_path)
CSV.foreach(file_path, 'r') { |line| trie.add(line.first.downcase.st... | true |
4707ef9dad4c98a51357b8ed08c208843d5b2b9f | Ruby | stephenh71/week5_weekend_homework | /specs/testing_task_2_spec.rb | UTF-8 | 606 | 3.0625 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../testing_task_2.rb")
require_relative("../card.rb")
class TestCardGame < Minitest::Test
def setup
@card1 = Card.new("hearts", 9)
@card2 = Card.new("spades", 1)
@cards = [@card1, @card2]
@cardgame1 = CardGame.new(@cards)
end
... | true |
6e555fcf93ad68c1ace2ed3d00d29b779f24c2d4 | Ruby | jcbmllgn/bidsy | /app/helpers/posts_helper.rb | UTF-8 | 743 | 2.609375 | 3 | [] | no_license | module PostsHelper
# Creates a field with data-field="field"
def post_field( post, field, tag, &block )
if post.new_record?
value = capture(&block) if block_given?
else
value = post.send field
end
d = "data-field='#{field}'"
"<#{tag} #{d} class='post-field input'>#{value}</#{tag}>".... | true |
b3c2d85d9d3ea7b2e8a7f2fc221ee02d29c04411 | Ruby | hannaohandrews/ar-exercises | /exercises/exercise_4.rb | UTF-8 | 859 | 3.1875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
puts "Exercise 4"
puts "----------"
# Your code goes here ...
surrey = Store.create(name: "Surrey", annual_revenue: 224000, mens_apparel: false, womens_apparel: true)
whistler= Store.create(n... | true |
642e187a0505763e30d2fc03b87a5a0e6723c6fe | Ruby | msa/threesmodel | /features/steps/game_play_steps.rb | UTF-8 | 923 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'threesmodel'
require 'threesmodel/game_board_folder'
Before do
end
Given(/^a new game is started$/) do
@game_controller = Threesmodel::GameController.new
@game_state = @game_controller.start_new_game
end
Then(/^an id is attached to the game$/) do
expect(@game_state[:id]).to_not eq(nil)
end
Then(/^th... | true |
70bbfd1c7885f40adf5293dd8623c9b26180b183 | Ruby | bestwebua/codewars | /ruby/numerical_palindrome_4.rb | UTF-8 | 1,836 | 4.25 | 4 | [] | no_license | =begin
Numerical Palindrome #4 by Vladislav Trotsenko.
A palindrome is a word, phrase, number, or other sequence of characters which reads
the same backward as forward. Examples of numerical palindromes are:
2332
110011
54322345
For a given number num, return its closest numerical palindrome which can either be
smal... | true |
e6591e71b64b6672257375d3ca8d036729e825bc | Ruby | nerzid/aegeantale | /app/models/group.rb | UTF-8 | 559 | 2.5625 | 3 | [] | no_license | class Group < ApplicationRecord
belongs_to :user
has_many :group_maps, :dependent => :destroy
has_many :users, :through => :group_maps
def is_owner?(user)
self.user == user
end
def is_member?(user)
self.group_maps.where(:user_id => user).pluck(:status) == :accepted
end
def get_users(user)
... | true |
82ae1c04d5fe01c056869ae4168540d83b9e24a3 | Ruby | tsoohub/WriteCode | /lib/parser.rb | UTF-8 | 36,207 | 2.921875 | 3 | [] | no_license | class Parser
attr_accessor :parser_error
attr_accessor :declarations
def initialize(lexem)
@main = nil
@stack = Array.new
@classes = Array.new
@declars = Array.new
@functions = Array.new
@error_list = Array.new
@declarations = Array.new
@parser_error = false
@assignment_term = nil
@lexer = lex... | true |
769ac0841c9775155c203333f9035d7b4988e1dd | Ruby | slacksky/ruby-examples | /herencia.rb | UTF-8 | 221 | 2.796875 | 3 | [] | no_license | class Mamifero
def respirar
puts "respira"
end
end
class Perro < Mamifero
def ladrar
puts "guau guau.."
end
end
mamifero = Mamifero.new
perro = Perro.new
mamifero.respirar
perro.respirar
perro.ladrar
| true |
d7266031d6fd456948e426ebadaaf0f88685b1ec | Ruby | Nilsyy/collections-and-iterations | /exercise3.rb | UTF-8 | 910 | 3.15625 | 3 | [] | no_license | #array
fav_colours = ["green", "yellow", "pink", "blue"]
age = [17, 18, 21, 37]
coin = ["heads","heads","tails","heads","heads"]
fav_artist = ["Grimes", "Enya", "Coldplay"]
sym_fav_colours = [:green, :yellow, :pink, :blue]
#hash
words = {
:homogeneous=> "The same.",
:computer=> "A technological machine that is use... | true |
bad967dde20e532fa80a3f9b3dc98924af5d5927 | Ruby | dmartinezm/ruby-objects-belong-to-lab-dumbo-web-100719 | /lib/artist.rb | UTF-8 | 272 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist
attr_accessor :name
end
artist = Artist.new
artist.name = "Beyonce"
# binding.pry
# class Artist
# attr_accessor :name, :genre
# def initialize(name, genre)
# @name = name
# @genre = genre
# end
# end | true |
8a59b632b6a10897be585077520b3ea5810d1302 | Ruby | eriq-augustine/580-knk | /puzzle_parser.rb | UTF-8 | 1,591 | 3.640625 | 4 | [] | no_license | require './puzzle.rb'
class PuzzleParser
def self.parseFile(filename, onePerLine)
puzzles = []
count = 0
file = File.open(filename, 'r')
file.each{|line|
count += 1
if (!onePerLine)
if (count == 1)
next
elsif (count == 3)
... | true |
15c063559550ebbba868b92ef6e816e24507ee73 | Ruby | midas/settled | /lib/settled/settings.rb | UTF-8 | 2,129 | 2.609375 | 3 | [
"MIT"
] | permissive | module Settled
class Settings
attr_reader :configuration
def self.build( &block )
Settled::Settings.new( &block )
end
def initialize( &block )
@configuration = {}
@files = []
@instance_strategies = []
@namespaces = []
if block_given?
block.arity < 1 ?
... | true |
9b6254932a0d4f2982fc920fcd029df321bf455a | Ruby | zzeligg/zlocalize | /lib/zlocalize/rails/translated_columns.rb | UTF-8 | 1,958 | 2.921875 | 3 | [
"MIT"
] | permissive | #
# === Translated columns ====
#
# Allows an ActiveRecord Model to declare multiple values (one for each locale) for given attributes.
# This module stores the values of each locale in table columns, such as:
#
# create_table :articles do |t|
# t.string :title_fr, :default => ''
# t.string :ti... | true |
087f8e4806ffec1c322b3b99a7266a8553bbfa1a | Ruby | Diegomo/wtm | /ruby/suma.rb | UTF-8 | 251 | 3.984375 | 4 | [] | no_license |
def suma(num1, num2 )
puts num1.to_i + num2.to_i
end
puts "Bienvenido a la suma de dos numeros"
puts "Ingresa un numero"
num1 = gets.chomp
puts "Ingresa el segundo numero"
num2 = gets.chomp
puts "el resultado de la suma es:"
puts suma(num1,num2) | true |
fb530a7441dfdbe3dd585921df92fba67f618948 | Ruby | jeager/novaquotes | /app/models/quote.rb | UTF-8 | 1,335 | 2.578125 | 3 | [] | no_license | class Quote < ApplicationRecord
belongs_to :user
validates :user, :presence => { :message => "O usuário fornecido não foi encontrado!" }
# Recebe uma quote e determina se precisa alterar a sua description.
def parse_quote(user_name)
user = nil
text_array = []
if ((self.description.include? 'by: @'... | true |
8234b742e8c73db04f547d4a9d97a560a6339f66 | Ruby | Tribe216/cracking_the_coding_interview | /ch01/07_rotate_matrix.rb | UTF-8 | 456 | 3.828125 | 4 | [] | no_license | def reverse_in_place(arr)
(arr.length / 2).times do |i|
arr[i], arr[-1-i] = arr[-1-i], arr[i]
end
end
def diag_flip(arr)
(arr.length - 1).times do |col|
((col + 1)..(arr.length - 1)).each do |row|
arr[row][col], arr[col][row] = arr[col][row], arr[row][col]
end
end
end
def rotate(arr)
diag_... | true |
5531fe91155d67a07692fd4b0d960cbf57e86b72 | Ruby | since08/kkmodels | /concerns/wheel_count_creator.rb | UTF-8 | 1,562 | 2.515625 | 3 | [] | no_license | # 创建用户生成器
module WheelCountCreator
extend ActiveSupport::Concern
module ClassMethods
def create_count
wheel_daily_count.increase_daily_new_user_count
total_count = wheel_total_count.increase_new_user_count
# 当总人数达到一定量的时候会产生大奖
return if ENV['WHEEL_EXPENSIVE_PRIZE'].eql?('false')
cr... | true |
6c0e33afa934742fa7cf0b02e4f08ba9ea192012 | Ruby | syntruth/Risus-RPG | /risus.rb | UTF-8 | 5,303 | 3.53125 | 4 | [] | no_license | =begin rdoc
# Risus RPG Module in Ruby
# Created by Randy Carnahan June, 2009
# Free to Redistribute but please keep this header intact.
#
# See here for distribution details:
# http://www222.pair.com/sjohn/risus-usage.htm
#
# VERSION:: 1.2
# Change Log::
# 1.0 Initial version.
# 1.1 Added Pumped Dice syntax
# ... | true |
85b3f9c468a2a5c977399da118d8e1f085d9f026 | Ruby | euqueme/enumerable-methods | /main.rb | UTF-8 | 3,273 | 3.453125 | 3 | [] | no_license | # frozen_string_literal: true
# rubocop:disable Metrics/ModuleLength
# Maru's Enumerables
module Enumerable
def my_each
if block_given?
size.times do |i|
is_a?(Range) ? yield(min + i) : yield(self[i])
end
self
else
to_enum
end
end
def my_each_with_index
if block_... | true |
793d559847b1b77303a8358fbf3b6cf840d08e35 | Ruby | andymeneely/project-bolt-rats | /lib/deck.rb | UTF-8 | 2,705 | 2.703125 | 3 | [] | no_license | require 'squib'
require_relative './helpers'
require_relative './version'
data = Squib.xlsx(file: 'data/game.xlsx', sheet: 0) do |col, item|
newlineate(col, item)
end
File.open('data/deck.txt', 'w+') { |f| f.write data.to_pretty_text }
Squib::Deck.new(cards: 14) do
use_layout file: 'layout.yml'
background col... | true |
4c902309d352efa568fb4fc5bf096aed8d729974 | Ruby | monkeyx/throneofthestars | /app/models/order_processing/disembark_army_order.rb | UTF-8 | 752 | 2.5625 | 3 | [] | no_license | module OrderProcessing
class DisembarkArmyOrder < CaptainOrder
def initialize(order)
super(order)
end
def prepare_new_parameters
new_parameter("Army", OrderParameter::OWN_ARMY,true)
end
def processable?
return false unless super
@army ||= params[0].parameter... | true |
67b1ec17df8cf46368a897350a3654e1150425bd | Ruby | cielavenir/procon | /codeforces/tyama_codeforces630G.rb | UTF-8 | 113 | 2.875 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
def comb(n,k)
r=1
k.times{|i|
r=r*(n-i)/(i+1)
}
r
end
n=gets.to_i
p comb(n+4,5)*comb(n+2,3) | true |
e7bcb2d9f2c12903a5a6084c1230602842c44461 | Ruby | brpadilha/conceitos_ruby | /modulo_02/11_class_object.rb | UTF-8 | 55 | 2.59375 | 3 | [] | no_license | numero = 1
letra = 'abc'
p numero.class
p letra.class
| true |
a8ec1f4d017beccbd83959457d9aed949f67f7f6 | Ruby | sekoudosso82/ruby_interview_prep | /rails_interview.rb | UTF-8 | 7,005 | 3.0625 | 3 | [] | no_license |
# difference btwn destroy and delete
Basically destroy runs any callbacks on the model while delete
doesn''t. ... The row is simply removed with an SQL DELETE
statement on the record''s primary key, and no callbacks are
executed. To enforce the object''s before_destroy and after_destroy
callba... | true |
6db24c5919596a4a42788acbcd3bb416ab3873fe | Ruby | svenfuchs/cl | /examples/readme/type | UTF-8 | 432 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$: << File.expand_path('lib')
class Add < Cl::Cmd
register :add
opt '--active BOOL', type: :boolean
opt '--retries INT', type: :integer
opt '--sleep FLOAT', type: :float
def run
p active: active.class, retries: retries.class, sleep: sleep.class
end
end
Cl.new('owners').run(%w(add... | true |
de2f98a56e22ef73ef2a32727d7274ae5d0c321f | Ruby | tmacram/learning_ruby | /work.rb | UTF-8 | 144 | 2.734375 | 3 | [] | no_license | ask= 'What do you want?'
puts ask.upcase
rqst = gets.chomp
puts 'WHADDAYA MEAN, ' + '"' + rqst.upcase + '"' + ' YOU\'RE'
puts 'FUCKING FIRED!!'
| true |
bc8a155e069e57e7673e49bd6770aeba8b6d9a0c | Ruby | jessiegcollins/ruby-challenges | /symbols.rb | UTF-8 | 349 | 2.71875 | 3 | [] | no_license | book_01 = {title: "Watership Down", author: "Adams"}
book_02 = {title: "A Man Called Ove", author: "Backman"}
book_03 = {title: "What Alice Forgot", author: "Moriarty"}
book_04 = {title: "Count of Monte Cristo", author: "Dumas"}
book_05 = {title: "Cat in the Hat", "author" => "Suess"}
favorite = book_05[:title]
puts "... | true |
e079f0299192c6d1abba2546bc7010563adce9ab | Ruby | pdeka/selenium-core-example | /functional-tests/generate_all_tests.rb | UTF-8 | 2,471 | 2.71875 | 3 | [] | no_license | require 'rubygems'
require 'RubySelenium'
require 'methods/selenium_methods'
require 'stringio'
require 'find'
class Batch_Generator
# override to create TestSuite.html, which is the FitRunner default
def create_test_suite_file_for_all_files
File.open("#{@generate_location}/TestSuite.html", "w"){|f| f... | true |
0c5a3d229d71722e2cd0ccf3357a2ffac8915162 | Ruby | elektronaut/dynamic_image | /lib/dynamic_image/model.rb | UTF-8 | 3,669 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "dynamic_image/model/dimensions"
require "dynamic_image/model/transformations"
require "dynamic_image/model/validations"
require "dynamic_image/model/variants"
module DynamicImage
# = DynamicImage Model
#
# ActiveModel extension for the model holding image data. It assumes ... | true |
8431ffb610abcd6c8fb4338528394b53612921f3 | Ruby | TIYDC/newline_hw | /lib/newline_hw/stream_processor.rb | UTF-8 | 1,328 | 2.859375 | 3 | [
"MIT"
] | permissive | require "json"
module NewlineHw
class StreamProcessor
# Don't instant shutdown wait for messages to clear, as chrome is much faster
# to trigger disconnect callback over wait for succesful messages.
SHUTDOWN_PAUSE = 0.5
attr_reader :logger
def initialize(stdin, stdout, opts = {})
@logger = ... | true |
eace7472d5a400c2cfec71bfef8c5e42ddece58f | Ruby | jaymuk/airport_challenge | /spec/plane_spec.rb | UTF-8 | 923 | 2.953125 | 3 | [] | no_license | require 'plane'
## Note these are just some guidelines!
## Feel free to write more tests!!
# When we create a new plane, it should have a "flying" status,
# thus planes can not be created in the airport.
#
# When we land a plane at the airport, the plane in question should
# have its status changed to "landed"
#
# Wh... | true |
70131d5c804bc77d16904e3f172ce3a0ed900098 | Ruby | exosyphon/advent_of_code | /2018/day_2_part_1/inventory_management.rb | UTF-8 | 528 | 3.375 | 3 | [] | no_license | def compute(input = File.readlines('./input.txt'))
two_character_counts = 0
three_character_counts = 0
input.each do |line|
duplicate_characters = Array.new(26, 0)
line.strip.chars.each do |character|
duplicate_characters[character.ord - 97] += 1
end
two_character_counts += duplicate_ch... | true |
e0f5d534c1ee4c538af893fe5aa7c7f12389e2b3 | Ruby | Jacob-Co/intro_to_ruby | /ruby_basics/strings/exercise_are_you_there.rb | UTF-8 | 130 | 2.609375 | 3 | [] | no_license | colors = 'blue pink yellow orange boredom'
puts colors.include? "yellow"
puts colors.include? "purple"
puts colors.include? "red" | true |
c5fcfc2097cee1fe65899eb20f76443535a809c8 | Ruby | krismacfarlane/godot | /w01/d02/student/interpolation.rb | UTF-8 | 400 | 3.328125 | 3 | [] | no_license |
# first_name = 'SOME_NAME'
# second_name = 'SOME_OTHER_NAME'
# third_name = 'YET_ANOTHER_NAME'
# other_likes_count = 'SOME INTEGER VALUE'
# Directions
# 1. uncomment the variable assignments above, and assign values of your own choosing.
# 2. use string interpolation to build a string similar to "John Thomas Suhar, ... | true |
641a443d02b17abe332f1131f05e1f077df599bb | Ruby | jamescook/kapsyen | /lib/kapsyen/subtitle.rb | UTF-8 | 1,453 | 2.875 | 3 | [] | no_license | #Sample subtitle file
#=====================
#
#1
#00:00:31,640 --> 00:00:34,200
#[I amar prestar aen]
#another line
#
require "strscan"
module Kapsyen
class Subtitle
def self.from_file(filename)
new File.read(filename, :mode => 'r:bom|utf-8').encode(:universal_newline => true)
end
attr_reader :... | true |
b8859e20c503d16133716d276a59956b293a5102 | Ruby | pingram/test_first_ruby | /12_rpn_calculator/rpn_calculator.rb | UTF-8 | 2,577 | 3.8125 | 4 | [] | no_license | require 'debugger'
class RPNCalculator
@stack
@temp_stack
def initialize
@stack = []
@temp_stack = []
end
def push(num)
@stack.push(num)
end
def plus
check_empty_calculator
@stack.push(:+)
end
def minus
check_empty_calculator
@stack.push(:-)
end
def times
check_empty_calculator
@... | true |
ad9e5b533e14872e76576fccfa9d0f368e30187b | Ruby | GPAunder1/DrinkKing-api | /app/domain/shops/mappers/shop_detail_mapper.rb | UTF-8 | 1,376 | 2.734375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'parser'
module DrinkKing
module Googlemap
# Data Mapper: Googlemap placedetails -> Shop and Review entity
class ShopDetailMapper
def initialize(token, gateway_class = Googlemap::Api)
@token = token
@gateway = gateway_class.new(@token)
... | true |
d3ab6255859a9b2a89cec808a6c33852a2bef62a | Ruby | febanda/apis-and-iteration-houston-web-111918 | /lib/command_line_interface.rb | UTF-8 | 136 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Hello Star Wars Fan"
end
def get_character_from_user
puts "please enter a character name"
user_input = gets.chomp
end
| true |
b2af0e9fdb89ec5e46e5037ea43b9e128d0c0f9d | Ruby | wanglian/rongping | /app/helpers/activities_helper.rb | UTF-8 | 6,678 | 2.53125 | 3 | [
"MIT"
] | permissive | module ActivitiesHelper
# Given an activity, return a message for the feed for the activity's class.
def feed_message(activity)
user = activity.user
case activity_type(activity)
when "Blog"
"{user} {action} {object}: {object_link}"[:action_feed, user_link(user), "published"[], "a blog"[], blog_li... | true |
199a14e9053a62cc62a010d5a81b5a17c3c29915 | Ruby | jferris/semiformal | /spec/semiformal/resource_spec.rb | UTF-8 | 4,081 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
require 'semiformal/resource'
describe Semiformal::Resource do
include ModelBuilder
it "has a #name" do
build_resource('Post').name.should == "post"
end
it "delegates #to_key" do
resource = build_resource do
def to_key
"expected"
end
end
resource.to_k... | true |
5d846f04d52615ff9f4b42d119fec5df63149d7b | Ruby | vivekkartha/exercism-ruby | /pangram/pangram.rb | UTF-8 | 102 | 3.234375 | 3 | [] | no_license | class Pangram
def self.pangram?(s)
(("a".."z").to_a - s.downcase.chars).empty?
end
end | true |
30a354bcda0ab254a64aa6fddd787ca163a3ca2b | Ruby | nllevin/W8D4 | /build_your_own_active_record/lib/00_attr_accessor_object.rb | UTF-8 | 298 | 2.65625 | 3 | [] | no_license | require 'byebug'
class AttrAccessorObject
def self.my_attr_accessor(*names)
names.each do |name|
attr_str = "@#{ name }"
define_method(name) { instance_variable_get(attr_str) }
define_method(name.to_s + "=") { |val| instance_variable_set(attr_str, val) }
end
end
end
| true |
30f3f9d4541fd3fa85c333903b01df0b0db06747 | Ruby | shiro-tech/ruby | /ruby_rensyu/ruby02.rb | UTF-8 | 464 | 3.890625 | 4 | [] | no_license | date = "初めてのRuby"
puts date
date2 = "Ruby" + "始めました"
puts date2
tasu = 3+3
hiku = 3-3
kake = 3*3
wari = 3/3
puts tasu
puts hiku
puts kake
puts wari
array = [1, 2, 3, 4]
puts array
num_array = array
p num_array
takuya = {name: 'kishimoto', birthday: '1993/05/16', blood: 'O'}
p takuya[:name]
def plus_ruby(plus... | true |
19ad4cf28dd7ad0c3adfcbee7dd800b2c5febfa7 | Ruby | d40cht/whitehall | /script/transform_import_script_to_use_s3_for_attachments_with_no_extension.rb | UTF-8 | 1,964 | 2.640625 | 3 | [] | no_license | require 'csv'
require 'fog'
require 'open-uri'
path = "~/tmp/fco_attachments"
def run(cmd)
`#{cmd}`
end
connection = Fog::Storage.new({
provider: 'AWS',
aws_access_key_id: 'XXX',
aws_secret_access_key: 'XXX'
})
BUCKET_NAME = "fco-temp-attachment-store"
@directory = connection.directories.get(BUCKET_NAME) |... | true |
3e60c6c676d5dd75af94f5b66b0e015d0cdcaaf4 | Ruby | shaunakv1/masters_course_work | /ror/HW1/robot_test.rb | UTF-8 | 2,594 | 3.46875 | 3 | [] | no_license | require 'test/unit'
require 'robot'
class RobotTest < Test::Unit::TestCase
def setup
@robot = Robot.new
@robot2=Robot.new
end
def test_learn_to_turn_left
exercised_skill = false
@robot.learn_maneuvering('left') { puts "turn left"; exercised_skill = true}
@robot.left
assert exercis... | true |
c7c24ce2276470ecdb06613e3b38e2077a5c080c | Ruby | c-bartell/backend_mod_1_prework | /day_3/exercises/ex29.rb | UTF-8 | 1,615 | 4.40625 | 4 | [] | no_license | people = 20
cats = 30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed!"
end
if people > cats
puts "Not many cats! The world is saved!"
end
if people < dogs
puts "The world is drooled on!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if people >= dogs
puts "People are... | true |
7d4aea07d62654f9731190180a9181c6b2d1c877 | Ruby | Spleefys/ruby-learn | /lib/files.rb | UTF-8 | 367 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require 'daru'
# class FileCSV
class FileCSV
def initialize(file)
@df = Daru::DataFrame.from_csv(file)
end
def max
@df['state_breweries'].max
end
def min
@df['state_breweries'].min
end
def average
@df['state_breweries'].mean
end
def dispersion
@d... | true |
a3e12ab3f324777c76395f7fcffa8e7c634283b5 | Ruby | ipcrm/pem | /lib/pem/utils/modules.rb | UTF-8 | 1,791 | 2.765625 | 3 | [] | no_license | module Pem
module Utils
module Modules
# Used on startup to determine what modules are deployed populate the modules instance var
def self.load_modules(pem)
begin
Pathname.new(pem.conf['mod_dir']).children.select(&:directory?).each do |m|
Pem::Module.new(m.basename.to_s, ... | true |
cae010160072ec7aab411c71f544ba7e8c7f87a2 | Ruby | dmitrydi/movie_pack | /lib/movie_pack/new_movie.rb | UTF-8 | 345 | 2.734375 | 3 | [] | no_license | require_relative 'movie_classes'
require 'date'
module MoviePack
# module describing Movie produces in PERIOD
class NewMovie < MovieToShow
PERIOD = 2001..Date.today.year
PRICE = 5
def to_s
years_ago = Date.today.year - @year
"#{@title} - new film, released #{years_ago} years ago... | true |
6588da5d4c228bb22d9c1986abe2f931c9ee7c96 | Ruby | whatalnk/cpsubmissions | /atcoder/ruby/code-festival-2018-quala/code_festival_2018_quala_a/3241536.rb | UTF-8 | 580 | 3.25 | 3 | [] | no_license | # Contest ID: code-festival-2018-quala
# Problem ID: code_festival_2018_quala_a ( https://atcoder.jp/contests/code-festival-2018-quala/tasks/code_festival_2018_quala_a )
# Title: A. 配点
# Language: Ruby (2.3.3)
# Submitted: 2018-09-22 12:03:24 +0000 UTC ( https://atcoder.jp/contests/code-festival-2018-quala/submissions/... | true |
d1d92568e9e2fb81b9608f93597843bef6253127 | Ruby | edvio4/catechumen | /db/seeds.rb | UTF-8 | 636 | 2.75 | 3 | [] | no_license | # ['Lessons', 'Pages', 'Sections', 'Units', 'Modules'].each do |name|
# UnitType.create( name: name )
# end
#
# ['Lessons', 'Sections', 'Units', 'Parts', 'Modules'].each do |name|
# DivisionType.create( name: name )
# end
#
# ['Math', 'Grammar', 'Reading', 'Spelling', 'Handwriting'].each do |name|
# Subject.creat... | true |
03bc4a24e0724a2685662bf52e6deb2d93609223 | Ruby | 29fx/whois-parser | /lib/whois/parsers/whois.ftld.dnrs.godaddy.rb | UTF-8 | 3,209 | 2.625 | 3 | [
"MIT"
] | permissive | #--
# Ruby Whois
#
# An intelligent pure Ruby WHOIS client and parser.
#
# Copyright (c) 2009-2015 Simone Carletti <weppos@weppos.net>
#++
require_relative 'base'
module Whois
class Parsers
# Parser for whois.ftld.dnrs.godaddy server.
class WhoisFtldDnrsGodaddy < Base
property_not_supported :disclaim... | true |
27855a8a0623a35a560a70f4d78e6d9e8685df8f | Ruby | grahamjenson/pathby | /lib/transformations.rb | UTF-8 | 2,371 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'matrix'
module GTransMat
def self.gRotateMatrix(radian)
return Matrix[[Math.cos(radian) , Math.sin(radian),0],
[-Math.sin(radian) , Math.cos(radian),0],
[0,0,1]]
end
def self.gTranslateMatrix(dx,dy)
return Matrix[[1 , 0 ,dx],
[0 , 1 ,dy],
... | true |
56e1eabfada71cad80514ae78823b53e54001278 | Ruby | hrushikesh/wee | /test/stress/stress_server.rb | UTF-8 | 1,620 | 2.609375 | 3 | [] | no_license | $LOAD_PATH.unshift '../../lib'
require 'wee'
class Wee::MessageBox < Wee::Component
def initialize(text)
@text = text
end
def render(r)
r.bold(@text)
r.form do
r.submit_button.value('OK').callback { answer true }
r.space
r.submit_button.value('Cancel').callback { answer false }
... | true |
98c51e5400f08d4ba8553b07f64a4b41b715e7e1 | Ruby | mvanholstyn/rddb-playground | /vendor/gems/CouchDb-Ruby/src/couchdb/server.rb | UTF-8 | 1,933 | 3.015625 | 3 | [] | no_license | require 'net/http'
module Couch
#
# The Server class contains the information to connect
# to a CouchDb server and provide methods for the raw
# HTTP server interactions.
#
# To connect to a CouchDb server on localhost port 8888 you can initialize
# a server object like:
#
# serve... | true |
1c96060aa37d75acb274669b550edef952a7ffda | Ruby | SteveOscar/ruby_challenges | /pig-latin/pig_latin.rb | UTF-8 | 749 | 3.828125 | 4 | [] | no_license | class Translator
def vowels
'aeiouy'
end
def main
loop do
puts
puts "Ready for you word, oink oink"
word = gets.downcase.chomp
return if word == "exit !"
translate(word)
end
end
def translate(word)
split = find_first_vowel(word)
consonant(word, split) unless... | true |
bbb9327e7a1278f35de9338f1b5ab9c9d5320915 | Ruby | thunderenlight/odin | /test_suite/ceaser_cipher_tdd/cc.rb | UTF-8 | 935 | 3.78125 | 4 | [] | no_license |
def caesar_cipher(string, move)
encrypted_string = []
result = []
# string.each_char do |l|
# n = l.ord
# if letter?(n)
# encrypted_string << n + move
# else
# encrypted_string << n
# end
# end
# encrypted_string.each do |n|
# if capital?(n)
# result << (n + 32).chr
# elsif letter?(n) == false ... | true |
dcf179f937171229fe21660f5b9b8d934968f1c6 | Ruby | ryou-kuzuno/RSpecPaiza | /spec/paiza_機械の総合病院_C_spec.rb | UTF-8 | 1,246 | 3.015625 | 3 | [] | no_license | # require 'spec_helper'
# RSpec.describe Lebel_C do
# let(:password) { Lebel_C.new(word: "DjZGrduN8Mj4") }
# describe '文字列の長さ' do
# it "6以上" do
# expect(password.pass_check1).to eq true
# end
# it "6以下" do
# false_pass = Lebel_C.new(word: "abc")
# expect(false_pass.pass_check1... | true |
5c861335704901091aa753c3b06b213fc486c650 | Ruby | crismali/js_objects_gem | /lib/2.0/prototype.rb | UTF-8 | 1,052 | 3.34375 | 3 | [] | no_license | require "ostruct"
class Prototype < OpenStruct
def [](key)
super(key.to_s)
end
def []=(key, value)
if value.kind_of? Proc
super(key.to_s, value)
define_proc_getter_method(key, value)
else
super(key.to_s, value)
end
end
private
def method_missing(method, *arguments, &bl... | true |
f74262f5406c574f372352991220ff8075cd2427 | Ruby | pjfranzini/programArchive | /codewars/ruby/determinant.rb | UTF-8 | 537 | 3.859375 | 4 | [] | no_license | # calculate (recursively) the determinant of a matrix of arbitrary size, using minors
def determinant(m)
return m[0][0] if m.length == 1
total = 0
m[0].each_with_index {|e,i| total = total + (-1)**i * e * determinant(minor(m,i))}
total
end
# method to extract minors
def minor(m,i)
n = m.length
mb = m[1..-1... | true |
3f1f80cca4271fe8e05e96927daad0655cc4af85 | Ruby | danigro77/MineSweeper | /mine_sweeper.rb | UTF-8 | 3,697 | 3.046875 | 3 | [] | no_license | # =============================
# MINE SWEEPER
# =============================
# Daniela Grossmann
# April, 2016
require './board.rb'
require './field.rb'
require './robot.rb'
require './helper.rb'
# -----------------------------
# Game methods
# -----------------------------
def play_game
set_variable... | true |
553f44e64cae47120646d38d17e415953aca57ac | Ruby | henteko/TeResRuby | /Ex1/bird.rb | UTF-8 | 1,032 | 3.453125 | 3 | [] | no_license | class Bird
attr_accessor :name, :tweets
def initialize(name)
@name = name
@tweets = []
@flowers = []
end
def tweet(text)
tweet = Tweet.new(text, self)
@tweets.push(tweet)
end
def my_tweets
print_tweets([self])
end
def follow(user)
raise 'Not Bird instance' unless user.c... | true |
d8d32c7d0297caf79609e13acca90cd74b94f9d6 | Ruby | hackersthinkers/can_haz_evatr | /lib/can_haz_evatr/check.rb | UTF-8 | 2,112 | 2.5625 | 3 | [
"MIT"
] | permissive | require "active_support/configurable"
require 'active_model'
require 'nokogiri'
module CanHazEvatr
class Check
FIELD_MAPPING = {
'Erg_PLZ' => :zip,
'Erg_Ort' => :city,
'Erg_Name' => :name,
'Erg_Str' => :street,
}.freeze
RESULT_MAPPING = {
'A' => :ok,
'B' => :no_match... | true |
57a4a52ba86f851011c7d178c226a774004cb4dd | Ruby | victorpolicastro/recipe-api | /app/controllers/api/v1/recipes_controller.rb | UTF-8 | 4,628 | 2.734375 | 3 | [] | no_license | module Api
module V1
class RecipesController < ApplicationController
#GET
#Receive all recipes from database
def index
recipe_name = params[:name]
recipe_ingredients = params[:ingredients]
recipe_tag = params[:tag]
recipes = get_recipes(recipe_name, recipe_tag, recipe_ingredients)
ren... | true |
97a8a73dd83a83dadc74d23759114f794476fa30 | Ruby | JongwonHan/Ruby-exercise | /currency.rb | UTF-8 | 188 | 2.875 | 3 | [] | no_license | require 'eu_central_bank'
def exchange(from,to)
bank = EuCentralBank.new
bank.update_rates
return bank.exchange(100, from, to)
end
puts "$1 => #{exchange 'USD', 'KRW'}원" | true |
8215a73afd6952487394fb6945216142d32e3185 | Ruby | KierepkaE/MakersBNB | /lib/request.rb | UTF-8 | 2,728 | 2.859375 | 3 | [] | no_license | require 'pg'
class Request
def self.create(property_id, owner_id, requester_id)
if ENV['ENVIRONMENT'] == 'test'
conn = PG.connect(dbname: 'makersbnb_test')
else
conn = PG.connect(dbname: 'makersbnb')
end
sql = "INSERT INTO requests (property_id, owner_id, requester_id, status) VALUES('#... | true |
0fb549c1502872668464d1a6f77e8accdba798d2 | Ruby | starkbank/sdk-ruby | /lib/payment_preview/brcode_preview.rb | UTF-8 | 3,861 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative('../utils/rest')
module StarkBank
class PaymentPreview
# # BrcodePreview object
#
# A BrcodePreview is used to get information from a BR Code you received before confirming the payment.
#
# ## Attributes (return-only):
# - status [string]: Paym... | true |
09cc4dbf84447ec3766708e1e1d69ea811692164 | Ruby | mbryzek/typed-class | /test/specs/test_readme_spec.rb | UTF-8 | 1,145 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | require File.dirname(__FILE__) + '/../init'
describe "readme" do
class CodeBlock < TypedClass
field :class_name, String
field :code, String
end
def parse_readme
file = File.join(File.dirname(__FILE__), '../../README.md')
blocks = []
class_name = nil
block = nil
IO.readlines(file)... | true |
0da99daa7c15d9145b055844e41d902fe492397c | Ruby | bruffin1221/ruby-objects-has-many-through-lab-online-web-sp-000 | /lib/genre.rb | UTF-8 | 258 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
@@all=[]
attr_accessor :name
def initialize(name)
@name=name
@@all<<self
end
def self.all
@@all
end
def songs
Song.all.select{|songs| songs.genre==self}
end
def artists
Song.all.map{|songs| songs.artist}
end
end
| true |
18c069df9b21d2895e644345a75b04f09056594e | Ruby | Mark228zzz/rubydev | /4/add_to_cart.rb | UTF-8 | 345 | 2.625 | 3 | [] | no_license | require_relative 'init'
require_relative 'cart'
owner = ARGV.delete_at(0)
cart = Cart.new(owner)
ARGV.each do |arg|
@items.each { |obj| cart.add_item obj if arg == obj.name }
end
cart.read_from_file
begin
cart.save_to_file
rescue ItemNotSupported
puts'You have VirtualItem or AntiqueItem in your cart'
+ "#{Car... | true |
8a72a87703f2a3512fcaa4e36104be364ad47fa1 | Ruby | El-Treshka/Tasks_rb | /6/155.rb | UTF-8 | 268 | 3.421875 | 3 | [] | no_license | def fun()
puts "Input n (n>=2):"
n = gets.to_i
x = []
for i in (1..n)
puts "Input x#{i}"
x[i] = gets.to_f
end
result = 1
for k in (2..n)
result *= ((1.to_f / (x[k - 1]).abs + 1.to_f) + x[k].to_f).abs
end
puts "Result: #{result}"
end
fun
| true |
d5898f1d9901b297f9e3d340e550d11541a025e4 | Ruby | 18F/identity-idp | /app/services/personal_key_generator.rb | UTF-8 | 1,213 | 2.734375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | class PersonalKeyGenerator
attr_reader :user_access_key, :length
INVALID_CODE = 'meaningless string that RandomPhrase will never generate'.freeze
def initialize(user, length: 4)
@user = user
@length = length
end
def create
user.personal_key = raw_personal_key
user.save!
raw_personal_key... | true |
2e6334a9f9472cf837f962d3dd05a95c90fc7750 | Ruby | ManageIQ/manageiq.org | /lib/miq/blog_year.rb | UTF-8 | 1,063 | 2.625 | 3 | [] | no_license | require "jekyll"
module Miq
class BlogYear < Jekyll::Page
attr_reader :year, :months
# Initialize a new Blog Archive.
#
# site - The Site object.
# dir - The String path between the source and the file.
# year - Date year, eg 2016 or 2014/05; becomes title.
# posts - Posts with this ta... | true |
47937f3c1d99416556c6c8b737d128294eae09a3 | Ruby | nysdin/AtCoder | /ABC/195/b.rb | UTF-8 | 336 | 3.078125 | 3 | [] | no_license | a, b, w = gets.split.map(&:to_i)
w = w * 1000
l = 10**8
m = 0
def min(a, b)
if a > b
return b
end
a
end
def max(a, b)
if a > b
return a
end
b
end
w.times do |i|
if a * (i+1) <= w && w <= b * (i+1)
l = min(l, i+1)
m = max(m, i+1)
end
end
if l == 10**8
puts 'UNSATISFIABLE'
else
puts ... | true |
0f7cad05e41d4463e8a082b766f5975bc51c4b63 | Ruby | connorpaulstauffer/RailsLite | /lib/params.rb | UTF-8 | 1,412 | 3.03125 | 3 | [] | no_license | require 'uri'
class Params
def initialize(req, route_params = {})
parse_www_encoded_form(req.query_string)
parse_www_encoded_form(req.body)
@params = my_deep_merge(@params, route_params)
end
def [](key)
@params[key.to_s] || @params[key.to_sym]
end
def to_s
@params.to_s
end
class At... | true |
2acfb7ee399b48516a1bdfc83705523d06706681 | Ruby | g-ilham/csv_record | /lib/csv_record/file_actions/create.rb | UTF-8 | 1,409 | 2.609375 | 3 | [
"MIT"
] | permissive | require "#{File.dirname(__FILE__) + '/base.rb'}"
module CsvRecord
module FileActions
class Create < CsvRecord::FileActions::Base
def create
if ::File.exist?(path)
add_record!
else
persist_record!("wb")
end
attrs
end
private
def add_re... | true |
e59a4450bda12fa4e4fe1603685a5486c4ce62fb | Ruby | adamPrice1/zoomruby | /leapyear.rb | UTF-8 | 373 | 3.890625 | 4 | [] | no_license | print "Enter a year: "
year = gets.chomp
while year.to_i.to_s != year or year.to_i < 0
print "Enter an actual year please: "
year = gets.chomp
end
if year.to_i % 4 == 0 && year.to_i % 100 != 0
puts "Yup, #{year} is a leap year"
elsif year.to_i % 4 == 0 && year.to_i % 400 == 0
puts "Yup, #{year} is a leap year"... | true |
732299e7a1567e5bea3e065184a5c12ab5825bf7 | Ruby | jhartwell/ironruby | /Tests/Experiments/Misc/NotOperator.rb | UTF-8 | 529 | 3.875 | 4 | [] | no_license | x = true
puts !x
puts !!x
puts !!!x
if not x then print 'A' end
if not not x then print 'B' end
if not !x then print 'C' end
if not not !!!x then print 'D' end
# if !(x**2 == 1) then print 'E' end
puts
a = x ? !x : x
class C
def bar(i, &b)
puts b[i]
self
end
end
c = C.new
a = !c... | true |
da6798d4984be6229a630097b9b5d51c4c86ca71 | Ruby | MisterMur/git-gainz-backend | /app/serializers/schedule_serializer.rb | UTF-8 | 609 | 2.515625 | 3 | [
"MIT"
] | permissive | class ScheduleSerializer < ActiveModel::Serializer
attributes :id,:name,:workouts
def workouts
customized_workouts = []
object.workouts.each do |workout|
# Assign object attributes (returns a hash)
# ===========================================================
custom_workout = workout.attr... | true |
4f90b30cd5512d53639402e598c6ca41aaa76e8d | Ruby | sportngin/sync_client | /app/models/sync_client/sub_message.rb | UTF-8 | 1,056 | 2.609375 | 3 | [
"MIT"
] | permissive | module SyncClient
class SubMessage < SyncClient::Message
attr_accessor :success
def process
with_logging do
self.success = message_handler.send(action.to_sym) if handler_present?
end
!!success
end
def handler_present?
return true if handler_class and handler_class.act... | true |
280fb3a374a60cb2993ba9b0ec931800188dd9ad | Ruby | grant-mc/LaunchSchool-RB130-Ruby-Foundations | /Ruby_Challenges/Easy_1/anagram.rb | UTF-8 | 345 | 3.59375 | 4 | [] | no_license | class Anagram
def initialize(word)
@word = word.downcase
end
def match(comparators)
anagrams = []
comparators.each do |comp|
comp_word = comp.downcase
a = @word.split('').sort.join('')
b = comp_word.split('').sort.join('')
anagrams << comp if a == b && @word != comp_word
e... | true |
85d802eb30a0b6a5406ded7c953cf40623769650 | Ruby | rabelirv/method-scope-lab-dumbo-web-091718 | /lib/catch_phrase.rb | UTF-8 | 112 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | phrase = "It's-a me, Mario!"
def catch_phrase(phrase)
puts phrase="It's-a me, Mario!"
end
catch_phrase(phrase) | true |
8d0ff3dab189b6f0a7e7a1e96c0f1e34e22c1eba | Ruby | Newland-A/js-rails-as-api-custom-json-rendering-using-rails-onl01-seng-ft-081720 | /app/controllers/birds_controller.rb | UTF-8 | 1,220 | 2.90625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class BirdsController < ApplicationController
def index
@birds = Bird.all
# render json: @birds
# or we could just do an except on the method that we don't want all info in the hash
# render json: birds, except: [:created_at, :updated_at]
# simpilist way to accomplish both things.
render jso... | true |
0e92b2bc7dbe70c5980eb5d7f2ac16db6cd1ab84 | Ruby | byung82/sas_web | /app/models/api/v1/request/card.rb | UTF-8 | 1,209 | 2.578125 | 3 | [] | no_license | module Api
module V1
module Request
class Card
include ActiveModel::Validations
include ActiveModel::Conversion
include ActionView::Helpers::NumberHelper
extend ActiveModel::Naming
attr_accessor :business_no, :card_no, :phone_no
validates_presence_of :busine... | true |
27ac2d4fc19c1cff0d7f5388b3eef56cd9a85a50 | Ruby | juliocesarjunior/URI | /1035.rb | UTF-8 | 183 | 2.796875 | 3 | [] | no_license | A = gets.to_i
B = gets.to_i
C = gets.to_i
D = gets.to_i
if (B > C && D > A && C+D > A+B && C > 0 && D > 0 && A%2 == 0)
puts "Valores aceitos"
else
puts "Valores nao aceitos"
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.