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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6a3908fba374fbcc0d0cfa4714e0231bc0a22cd8 | Ruby | apalski/crud-with-validations-lab-v-000 | /app/models/song.rb | UTF-8 | 411 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
validates :title, :artist_name, presence: true
validates_uniqueness_of :title, scope: :release_year
validates :released, inclusion: {in: [true, false]}
validates :release_year, presence: true, if: :is_released?
validates :release_year, numericality: {less_than_or_equal_to: Dat... | true |
559dfbbac9e8f2bc0f4bb1cdf127125c884ece25 | Ruby | GeorgieGirl24/backend_mod_1_prework | /day_6/exercises/burrito.rb | UTF-8 | 1,266 | 3.859375 | 4 | [] | no_license | # Add the following methods to this burrito class and
# call the methods below the class:
# 1. add_topping
# 2. remove_topping
# 3. change_protein
class Burrito
attr_reader :protein, :base, :toppings
def initialize(protein, base, toppings)
@protein = protein
@base = base
@toppings = toppings
end... | true |
068aae0cd133a84018f20c0828fe8232970e60ad | Ruby | sundayguru/bootcampXV | /src/factorial.rb | UTF-8 | 120 | 3.296875 | 3 | [] | no_license | def factorial(number)
return 1 if number <= 1
return number * factorial(number - 1);
end
puts factorial 4 | true |
f6bbe1d74d002c6f4b6f0b23fbd7385f70a077b8 | Ruby | grosscol/hydra-pcdm | /lib/hydra/pcdm/services/collection/get_objects.rb | UTF-8 | 600 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | module Hydra::PCDM
class GetObjectsFromCollection
##
# Get member objects from a collection in order.
#
# @param [Hydra::PCDM::Collection] :parent_collection in which the child objects are members
#
# @return [Array<Hydra::PCDM::Collection>] all member objects
def self.call( parent_colle... | true |
add2402034191d24cd62cdef89db406f83991596 | Ruby | eulis01/debugging-with-pry-onl01-seng-pt-041320 | /lib/pry_debugging.rb | UTF-8 | 63 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
(num + 2)
num = (num + 2)
end
plus_two(3)
| true |
c2ee07b0fbe12b56757fba07cd2b6532c3f9af40 | Ruby | alexhawkins/query | /db/seeds.rb | UTF-8 | 1,861 | 2.78125 | 3 | [] | no_license | require 'faker'
# Create Users
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: 'helloworld'
)
user.skip_confirmation!
user.save
end
users = User.all
# Create Topics
20.times do
Topic.create(
title: Faker::Commerce.color,
about: Faker::Lore... | true |
013fcc41f188a777dab8f86918902539a62cc1dc | Ruby | rlcoble/learn_ruby | /testing/intro/02_calculator/calculator.rb | UTF-8 | 416 | 3.5625 | 4 | [] | no_license | def add(first,second)
first+second
end
def subtract(first,second)
first-second
end
def sum(array)
total = 0
array.each do |item|
total += item
end
total
end
def multiply(array)
total = 1
array.each do |item|
total *= item
end
total
end
def power(first,second)
first**second
endn
def factorial(num)
... | true |
10533b8112e4d498994029786a5cc24700d8d8dc | Ruby | IanDCarroll/deleteMe | /spec/acceptance_spec.rb | UTF-8 | 747 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'rspec/given'
require 'ian_strscan'
describe 'Acceptance Test' do
Given(:s) { IanStrscan.new('This is an example string') }
Then { false == s.eos? }
And { "This" == s.scan(/\w+/) }
And { nil == s.scan(/\w+/) }
And { " " == s.scan(/\s+/) }
And { nil == s.scan(/\s+... | true |
3b67f40102bcf6b9313a6fa13d73c026254639a3 | Ruby | anand180/nick-tictactoe-server | /spec/creators/move_creator.rb | UTF-8 | 555 | 2.65625 | 3 | [] | no_license | module MoveCreator
def self.add_three_non_winning_moves(game:)
type = game.x_first ? 'x' : 'o'
class << type
@@counter = 0
def switch
type = @@counter.even? ? 'o' : 'x'
@@counter += 1; type
end
end
Move.create(game_id: game.id, player_id: game.send("#{type... | true |
dfddd91c515ca9b6e88c869b9e2faba7bb0e1082 | Ruby | emacca/wdi_sydney_3 | /students/eduard_fastovski/w1d2/simplecalc_doesnt_loop.rb | UTF-8 | 1,302 | 4.28125 | 4 | [] | no_license | # this doesnt work. until command == "q" do
puts "Please type 'A' for addition, 'S' for subtraction 'M' for multiplication and 'D' for division. 'P' for Power. /n Press q to quit."
command = gets.chomp
def add(a, b)
puts "The answer is #{a+b}"
end
def sub(a, b)
puts "The answer is #{a-b}"
end
def mul(... | true |
4144c18e20140c41fbbab2bb16000b3208d8c721 | Ruby | WHomer/pantry_03 | /lib/pantry.rb | UTF-8 | 753 | 3.546875 | 4 | [] | no_license | require './lib/recipe'
require './lib/ingredient'
class Pantry
attr_reader :stock
def initialize
@stock = {}
end
def stock_check(input_ingredient)
result = @stock.find{|ingredient| ingredient[0] == input_ingredient}
return 0 if result.nil?
result.last
end
def restock(input_ingredient, qua... | true |
2f7efc59eb22bf828dd84c03611f6578253bb9c9 | Ruby | kanevk/Core-Ruby-1 | /week5/1-meta/solution_test.rb | UTF-8 | 2,140 | 3.40625 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require_relative 'solution'
class SolutionTest < MiniTest::Unit::TestCase
class Try
private_attr_accessor :a, :b
protected_attr_accessor :c, :d
cattr_accessor(:clas, :empty){"NO"}
@@clas = 42
def initialize()
@a, @b, @c, @d = 1, 2, 3, 4
end
def try_... | true |
09aab5171d264f61d392f5ac54eff5a7c857d180 | Ruby | yb66/english-words | /scripts/cleanup.rb | UTF-8 | 438 | 3.296875 | 3 | [] | no_license | # This script makes sure that each entry is unique and lowercase.
require 'pathname'
DEFAULT_DATA = Pathname(__dir__).join("../words3.txt")
data = ARGV[0] && Pathname(ARGV[0]) || DEFAULT_DATA
xs = IO.readlines(data.realpath);
ys = xs.sort
.map(&:chomp)
.map(&:downcase)
.inject([]){|mem,obj|
... | true |
8d367ce0fb6d95787e4f3ec91253152f93029a07 | Ruby | lisavogtsf/gluten_free | /people.rb | UTF-8 | 3,684 | 4 | 4 | [] | no_license | # Lisa Vogt
# August 13, 2014
# * Create a Person class. A person will have a stomach and allergies
# * Create a method that allows the person to eat and add arrays of ingredients to their stomachs
# * If a food array contains a known allergy reject the food.
# When a person attempts to eat a food they are allergic to... | true |
4abc613018ccf2f5f1b9948900329fbdf0f9685f | Ruby | teecay/StorageVisualizer | /lib/storage_visualizer.rb | UTF-8 | 18,166 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
# @author Terry Case <terrylcase@gmail.com>
# Copyright 2015 Terry Case
#
# Licensed under the Creative Commons, Version 3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://creativecommons.org/li... | true |
5458519e8b63bce252b9242cc0e7923b55090385 | Ruby | davidhuff2014/testproject | /good_dog.rb | UTF-8 | 427 | 3.796875 | 4 | [] | no_license | module Speak
def speak(sound)
puts "#{sound}"
end
end
# defines a good dog
class GoodDog
include Speak
end
# what people do too much of
class HumanBeing
include Speak
end
# sparky = GoodDog.new
# sparky.speak('Arf!')
# bob = HumanBeing.new
# bob.speak('Hello!')
puts '--- GoodDog anc... | true |
fddc3e91bd77c7200bcbfc71ffe5505b920f2c81 | Ruby | nessamurmur/codeclimate-services | /test/invocation_test.rb | UTF-8 | 2,916 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path('../helper', __FILE__)
class TestInvocation < Test::Unit::TestCase
def test_success
service = FakeService.new(:some_result)
result = CC::Service::Invocation.invoke(service)
assert_equal 1, service.receive_count
assert_equal :some_result, result
end
def test_retries
... | true |
92759e9ed09523b228b260a28dcd19047a9b5769 | Ruby | peckapp/webservice | /app/workers/crawl/crawler.rb | UTF-8 | 3,758 | 2.65625 | 3 | [] | no_license | module Crawl
# this class handles the main crawl loop and dispatches other workers to parse individual pages
class Crawler
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { daily }
# bloom filter as a persistent class variable
# use is for efficiency, not accuracy, so occasiona... | true |
5055d6c76603fabaab4c59f8d34896e1ba9f1906 | Ruby | sbcn7/atcoder-by-ruby | /abc008/D.rb | UTF-8 | 240 | 3.140625 | 3 | [] | no_license | # http://abc008.contest.atcoder.jp/tasks/abc008_4
W, H = gets.split.map(&:to_i)
N = gets.to_i
XY = []
N.times do
XY.push gets.split.map(&:to_i)
end
XY.permutation(N) do |xy|
xy.each do |x, y|
# 金塊を回収したい
end
end
| true |
981f8ae2a0582d78c2e7d61273bf6c96cf287f95 | Ruby | saheb222/ruby_practice | /basics/gsub_hackerrank.rb | UTF-8 | 292 | 3.515625 | 4 | [] | no_license | def strike(str)
"<strike>#{str}</strike>"
end
def mask_article(str,str_arr=[])
my_str = str
str_arr.each do |ar_str|
if my_str.include?(ar_str)
my_str = my_str.gsub("#{ar_str}",strike(ar_str))
end
end
my_str
end
puts mask_article("i am saheb seikh",["i","seikh"]) | true |
fd71f6b00a022ff7389e2fd52fa311f570fda015 | Ruby | teoucsb82/pokemongodb | /lib/pokemongodb/pokemon/farfetchd.rb | UTF-8 | 1,327 | 2.71875 | 3 | [] | no_license | class Pokemongodb
class Pokemon
class Farfetchd < Pokemon
def self.id
83
end
def self.base_attack
138
end
def self.base_defense
132
end
def self.base_stamina
104
end
def self.buddy_candy_distance
2
end
d... | true |
589d3c0cd41a0cecbd255258c486ccc1714379de | Ruby | clynchga/class_4_hw | /name_programs.rb | UTF-8 | 390 | 4.1875 | 4 | [] | no_license | # Write a program that asks the user for her name and greets her with her name
puts "Enter your name "
username = gets.chomp.capitalize
puts "Hello #{username}!"
# Change the previous name program such that only the users Jack or Jill are greeted
puts "Enter your name "
username = gets.chomp.capitalize
if username =... | true |
fef83c3a0d90d900dde713d8734b7f5d029b9c8d | Ruby | puremana/f2pehp | /app/services/hiscores.rb | UTF-8 | 5,761 | 2.59375 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | require 'open-uri'
class Hiscores
extend Base
REG_MODE = %w[Reg].freeze
IRONMAN_MODES = %w[UIM HCIM IM].freeze
ALL_MODES = %w[UIM HCIM IM Reg].freeze
class << self
def fetch_stats_by_acc(player_name, account_type)
stats_uri = api_url(account_type, player_name)
res = fetch(stats_uri)
i... | true |
5232c1adb224409ac3484e6e6a6f1dc2ce3d5305 | Ruby | RaphaelwHuang/Set-Game | /testing/test_deck.rb | UTF-8 | 1,046 | 3.078125 | 3 | [] | no_license | require_relative '../board'
require "test/unit"
class TestDeck < Test::Unit::TestCase
# Author: Sunny Patel - 2/5
def test_deck_init
assert_nothing_raised {Deck.new}
end
# Author: Sunny Patel - 2/5
def test_deck_draw_fullDeck
deck = Deck.new
assert_nothing_raised {deck.draw}
end
# Author: Su... | true |
5b97fa7c5a7f367badaff654e3566525e71c6ff6 | Ruby | inem/lazibi | /lib/filter/optional_end_filter.rb | UTF-8 | 3,157 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'filter_base'
module Lazibi
module Filter
class OptionalEnd < FilterBase
def up( source )
rb = source
py = []
lines = rb.split("\n")
lines.each_index do |index|
l = lines[index]
if l.strip =~ /^end$/
next
end
l = r... | true |
3fc5bb8a558ac5c7f685311d657be6323dbdf162 | Ruby | BearingMe/exercicios-CeV | /exs/mundo_1/ruby/025.rb | UTF-8 | 299 | 3.890625 | 4 | [
"MIT"
] | permissive | =begin
Desafio 025
Problema: Crie um programa que leia o nome de uma pessoa e diga se ela tem "SILVA" no nome.
Resolução do problema:
=end
print"Digite seu nome: "
n = gets.chomp.upcase
if n.index('SILVA') != nil
puts"Você tem Silva no nome."
else
puts"Você não tem Silva no nome."
end
| true |
f955458c825cc19d94ab601d9d4a808ecd2db05e | Ruby | anibal/dashboard | /script/update_slimtimer.rb | UTF-8 | 5,019 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'optparse'
require 'rdoc/usage'
require 'logger'
require 'pp'
def quit_with_usage(opts)
STDERR.puts opts
exit 1
end
@options = {}
OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options]"
opts.on("-l", "--logfile FILE", "Log to FILE (defau... | true |
a9e36dab08512b7301b1855573c836f7d9bacb57 | Ruby | RodrigoRGRB/Codewars | /ucoder/1030.rb | UTF-8 | 1,350 | 2.921875 | 3 | [] | no_license | entrada = gets.split
qfita = entrada[0].to_i
qtd = entrada[1].to_i
fita = []
dias = []
for t in (0...qfita)
fita << 0
end
def teste(posicao, tamanho, fita)
anterior = posicao - 1
atual = posicao
proxima = posicao + 1
puts "\n\n\n\n"
if anterior < 0
fita.insert((proxima - 1), 1)
fita.delete_at(prox... | true |
d8f879897f026d25e18cc6bede3ea3d8fc9f0682 | Ruby | patmaddox/21-day-challenge | /2_adventures/001/jbrains/11/langtons_ant_ui.rb | UTF-8 | 1,768 | 2.796875 | 3 | [] | no_license | require "gtk2"
class LangtonsAntWalkGridSquare < Gtk::Frame
attr_accessor :grid_square_model
# grid_square_model (can't be called "model", because Gtk::Frame uses that) must support:
# add_listener(listener)
# color
def self.with_model(model)
self.new(model.color).tap { |view|
view.grid_square_mod... | true |
813249d7006df0cacf739236c0ab4ed5a109399a | Ruby | sooyang/algo | /merge_sort.rb | UTF-8 | 765 | 3.875 | 4 | [] | no_license | # Chapter 2
def merge(array, p, q, r)
left = array[p..q]
right = array[q+1..r]
i = 0 # left array index
j = 0 # right array index
k = p # main array
while i < left.length && j < right.length
if left[i] < right[j]
array[k] = left[i]
i += 1
else
... | true |
ba7f9afb194e9e5c9950e42631fcb7c5485d87cf | Ruby | palladius/riclife | /app/helpers/tags_helper.rb | UTF-8 | 1,172 | 2.546875 | 3 | [] | no_license | module TagsHelper
def sample_tags
sminuzza_tags 'dublin bologna riccardo gnocca connector goliardia friend sex love gnocca family son spouse imelda_may'
end
### Use partial "tags/link" , :tags => ARRAY
# restituisce un array... '
def sminuzza_tags(str)
return [] unless str
str.split(/[ ,]/... | true |
736321a45b645afd625f47e7bafc86effff081a4 | Ruby | Proffard/vimeo_rails | /lib/vimeo/categories.rb | UTF-8 | 1,026 | 2.546875 | 3 | [
"MIT"
] | permissive | module Vimeo
class Categories < Vimeo::Base
# Get a list of the top level categories. GET #
def self.find_all
get('/categories')
end
# Get a category. GET #
#
# category = category name
def self.search(category)
get("/categories/#{category}")
end
##################... | true |
9907791c98ca759a9b6768a2f9654bc8e4e39ab5 | Ruby | ZeusLimited/ksa_copy | /app/models/concerns/arm_minenergo.rb | UTF-8 | 809 | 2.578125 | 3 | [] | no_license | module ArmMinenergo
extend ActiveSupport::Concern
include Constants
class_methods do
def to_arm_thousand(val)
return 0 if val.nil?
(val.to_f / 1000.0).round(3)
end
end
private
def default_value(type)
[:float, :integer].include?(type) ? 0 : nil
end
def reject_special_symbols(e... | true |
ce74f452e3b37644d2c235e7ffd9185458940a4a | Ruby | ryouyatanaka/bowling | /lib/bowling.rb | UTF-8 | 1,273 | 3.609375 | 4 | [] | no_license | class Bowling
def initialize
@scores = []
@index = 0
@frame = 1
@total = 0
@frame_scores = []
end
def add_score(pins)
@scores << pins
end
def total_score
@total
end
def calc_score
while @frame <= 10 do
... | true |
c851ce151e6d0b3e37d5fca7e60b8e54bd145fb7 | Ruby | jmennick/cornDog | /app/formatters/time_value_formatter.rb | UTF-8 | 299 | 2.546875 | 3 | [] | no_license | class TimeValueFormatter < JSONAPI::ValueFormatter
FORMAT='%m/%d/%Y %I:%M:%S%p'
class << self
def format(raw_value)
super(raw_value.to_time.strftime(FORMAT))
end
def unformat(value)
# super(Date.strptime(value, FORMAT))
super(Time.parse(value))
end
end
end
| true |
a998faf1e0e76cd29b45faef9041653c51e58946 | Ruby | m11o/algoruby | /src/section3/code3_2.rb | UTF-8 | 214 | 2.9375 | 3 | [] | no_license | n = gets.chomp.to_i
v = gets.chomp.to_i
array = []
(0..(n - 1)).each { array << gets.chomp.to_i }
found_id = nil
array.each_with_index do |item, index|
next if item != v
found_id = index
end
puts found_id
| true |
fd53814b94b3fdb2e20b0033a09d9c2b5a9660b5 | Ruby | stephepush/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-nyc04-seng-ft-041920 | /nyc_pigeon_organizer.rb | UTF-8 | 964 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(data)
# write your code here!
organized_data = {} # Used to store the names of the pigeons and assign values
# Iterates through top layer of Hash
data.each do|color_gender_lives, attribute_hash|
# Iterate through middle layer of hash
attribute_hash.each do |attribute, name_array|
... | true |
4736b1811c994e6865d253485074ecfb92243be6 | Ruby | AnVales/Use-Web-APIs | /class_network.rb | UTF-8 | 14,587 | 3.3125 | 3 | [] | no_license | require './class_helper.rb'
require './class_gene_info.rb'
require 'json'
require 'rest-client'
class Network
########## CLASS ##########
# this class has one object which must be a subnetwork of Arabidopsis if the hypothesis is right
########## ATTRIBUTE ##########
# network: a hash with ... | true |
31d808457e681debaf2a9a23a92ce618348b3a97 | Ruby | giokro/Ruby-Developement | /fix-ois-p2/lib/courses.rb | UTF-8 | 1,065 | 3.109375 | 3 | [] | no_license | # module
module Courses
require 'time'
require 'date'
require 'course'
require 'csv_importer'
require 'parse_helper'
def self.find_course(id)
course = Course.find_by(id: id)
raise "Course with id #{course_id} not found in database" unless course
course
rescue StandardError => e
warn e.mes... | true |
6ad3d06ca1dc40558495a7a08de613a73e4abdfe | Ruby | Steph0088/array-equals | /lib/array_equals.rb | UTF-8 | 361 | 3.5625 | 4 | [] | no_license | # Determines if the two input arrays have the same count of elements
# and the same integer values in the same exact order
def array_equals(array1, array2)
if array1.length == array2.length
number = array1.length
number.times do |i|
if array1[i] != array2[i]
return false
end
end
... | true |
ed4f9dd9581e84df82acf76473c8d59b07e5c94a | Ruby | sheleg/Projects | /Test projects/testRuby/test.rb | UTF-8 | 305 | 2.5625 | 3 | [] | no_license | require 'httparty'
require 'nokogiri'
require 'open-uri'
page = HTTParty.get("https://newyork.craigslist.org/search/pet?s=0")
doc = Nokogiri::HTML(page)
pets_array = []
tem = doc.css('.content').css('row').css('hdrlnk').map do |a|
post_name = a.text
pets_array.push(post_name)
end
puts pets_array
| true |
f5cd24ac6288d9608851cb312d800bc9400b3715 | Ruby | cbastable/japanese | /lib/tasks/jlpt_words_links.rake | UTF-8 | 1,338 | 2.578125 | 3 | [] | no_license | namespace :db do
desc "Fill database with jlpt word data"
task populate_word_links: :environment do
make_word_collections
make_word_kanjis
end
end
def make_word_collections
WordCollection.destroy_all
Collection.all.each do |collection|
data_dir = "#{Dir.pwd}/db/data/#{collection.name}/words"
... | true |
8dbef678c0f1952c757a1b689cc0f8e5b888566e | Ruby | MagneticRegulus/intro_to_prog | /09MoreStuff/2_variable_pointers.rb | UTF-8 | 1,229 | 4.25 | 4 | [] | no_license | a = "hi there" # => "hi there"
b = a # => "hi there"
a = "not here" # => "not here" (reassigns variable due to "=")
# b still returns "hi there"
# diagram: https://d2aw5xe2jldque.cloudfront.net/books/ruby/images/variables_pointers1.jpg
c = "hi there" # => "hi there"
d = c # => "hi there"
c << ", Bob"# => "hi there, Bo... | true |
f0ea13add21295137e25655c0a0c2d59a2e77f7d | Ruby | xentek/hyperdrive | /spec/hyperdrive/docs_spec.rb | UTF-8 | 1,728 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'spec_helper'
describe Hyperdrive::Docs do
before do
@resources = { :thing => default_resource }
@docs = Hyperdrive::Docs.new(@resources)
end
it 'generates a header with size 1 as default' do
@docs.header('Thing Resource').must_equal "\n\n# Thing Resource\n\n"
end
it ... | true |
2dc12d9d6342c1f0bd5ac6a09ae9f85880bf4f4d | Ruby | hakimu/roman_numerals | /test_app.rb | UTF-8 | 3,148 | 3.265625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative 'app'
class RomanNumeralTest < Minitest::Unit::TestCase
def test_find_roman
expected_1 = "I"
expected_5 = "V"
expected_10 = "X"
assert_equal expected_1, RomanNumeral.new(1).find_roman
assert_equal expected_5, RomanNumeral.new(5).... | true |
5959f2a88de730413b6fa5fc5bc0370d417a0ea8 | Ruby | tian-xiaobo/filter_word | /lib/filter_word/rseg.rb | UTF-8 | 3,484 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'singleton'
require 'net/http'
require 'yaml'
require File.join(File.dirname(__FILE__), 'engines/engine')
require File.join(File.dirname(__FILE__), 'engines/dict')
require File.join(File.dirname(__FILE__), 'engines/english')
require File.join(File.dirname(__FILE__), 'filters/fullwidth')
req... | true |
cc8f6638dafe00b0370c4ee2ad122fa1c03b1ded | Ruby | eirinikos/ruby-bites | /_codewars.rb | UTF-8 | 12,052 | 3.96875 | 4 | [] | no_license | # codewars kata: which are in?
# http://www.codewars.com/kata/which-are-in/train/ruby
def in_array(array1, array2)
string = array2.join(' ')
array1.select { |substring| string.include? substring }.sort!
end
# codewars kata: deodorant evaporator
# http://www.codewars.com/kata/deodorant-evaporator/train/ruby
def ... | true |
5a1143e6972f664814834a76056922b39b8295d8 | Ruby | ghulammurtaza27/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 2,536 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
# validation tests/examples here
it 'should save a user when name, email, and password are provided properly' do
user = User.create(
first_name: "Ghulam",
last_name: "Murtaza",
email: "gm@gm.co... | true |
08af5ac8838e15f64ef42b4a51b434345d4a93b5 | Ruby | yazseyit77/binary-search-tree-online-web-ft-081219 | /binary_search_tree.rb | UTF-8 | 457 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class BST
attr_accessor :data, :right, :left
def initialize(data)
@data = data
end
def insert(n)
if n <= @data
if @left.nil?
@left = BST.new(n)
else
@left.insert(n)
end
else
if @right.nil?
@right = BST.new(n)
else
@right.insert(n)
... | true |
36f5bacac8bf38bdf1978642c6c83e90bada7c75 | Ruby | mbme/cman | /lib/cman/utils.rb | UTF-8 | 873 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'pathname'
module Cman
# some common utils
module Utils
def copy_file(src, dst)
if File.file?(src)
FileUtils.cp src, dst
elsif File.directory?(src)
copy_dir src, dst
end
end
def copy_dir(src, dst)
dst_path = Pathname.new dst
src... | true |
66f509f6fb4ffc10400e36f9446aba8bbe456d0b | Ruby | tvaroglu/backend_mod_1_prework | /section1/exercises/learn_ruby_the_hard_way/ex15/ex15.rb | UTF-8 | 745 | 4.125 | 4 | [] | no_license | #Supply file name as first ARG for script
filename = ARGV.first
#Assign file (ARG) as a new variable which has the 'open' method called upon it
txt = open(filename)
#Print the filename (ARG) interpolated into a string for the user
puts "Here's your file #{filename}:"
#Print the text previously assigned to the 'txt' v... | true |
a48070dcd18cd69fd75c8211a619074cb6db59f1 | Ruby | bwlv/debt_ceiling | /spec/debt_ceiling_spec.rb | UTF-8 | 1,373 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'debt_ceiling'
describe DebtCeiling do
it 'has failing exit status when debt_ceiling is exceeded' do
DebtCeiling.configure {|c| c.debt_ceiling = 0 }
expect(DebtCeiling.debt_ceiling).to eq(0)
expect { DebtCeiling.calculate('.', preconfigured: true) }.to raise_error
end
i... | true |
7a3cb2ec19acf3f042d4c6624ada78e38629341d | Ruby | html/sup | /test/unit/post_test.rb | UTF-8 | 567 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class PostTest < ActiveSupport::TestCase
context "Post::list" do
should "return 5 items" do
20.times do
Post.make
end
assert_equal Post.list.size, 5
end
should "order by id DESC" do
3.times do |i|
Post.make :date => Date.today + (3 - i).hour... | true |
b47415822a40da2f625a991bcf320c5dcded059e | Ruby | molawson/repeatable | /spec/repeatable/expression/weekday_spec.rb | UTF-8 | 2,700 | 3.03125 | 3 | [
"MIT"
] | permissive | # typed: false
require "spec_helper"
module Repeatable
module Expression
describe Weekday do
subject { described_class.new(weekday: 4) }
it_behaves_like "an expression"
describe "#include?" do
it "returns true for dates matching the weekday given" do
expect(subject).to inclu... | true |
8c76340e5f04eddfb2f007be1cfe05de192d7cc2 | Ruby | Dmitry-Pryshchepa/log_parser | /lib/log_parser/log_line.rb | UTF-8 | 270 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
module LogParser
class LogLine
private_class_method :new
def self.call(file_line)
new(*file_line.split)
end
attr_reader :url, :ip
def initialize(url, ip)
@url = url
@ip = ip
end
end
end
| true |
0ed237efc4f9306511b416a90b49384c96052ebf | Ruby | prrn-pg/Shojin | /Practice/atcoder/ABC/040/src/c.rb | UTF-8 | 1,232 | 3.046875 | 3 | [] | no_license | # 再帰の深さの上限に引っかかるのでなんとかするやつ
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
#Rubyパスを取得するには、rbconfigかrubygemsを使う。AtCoderでは--disable-gemsされているので、require 'rubygems'は必須である。
#require 'rbconfig';RUBY=File.join(RbConfig::CONFIG['bindir'],RbConfig::CONFIG['ruby_install_name'])
require 'rubygems';RUBY=Gem.ruby
exec({'R... | true |
abf700fcaee8b3580707d88ad0ffdd9e1a2b33ef | Ruby | georgehwho/ruby-exercises | /initialize/lib/monkey.rb | UTF-8 | 148 | 2.875 | 3 | [] | no_license | class Monkey
attr_reader :name, :type, :favorite_food
def initialize(a)
@name = a[0]
@type = a[1]
@favorite_food = a[2]
end
end
| true |
7b5eb8d508cf3375c0890b666da0a981168e0af2 | Ruby | brooklynresearch/Deuces | /db/seeds.rb | UTF-8 | 498 | 2.78125 | 3 | [] | no_license | row_count = 9
column_count = 17
rows_with_large = [0,2,4,6]
row_count.times do |r|
if rows_with_large.include?(r)
#create large locker- in first column
Locker.create(row: r, column: 0, large: true)
#no locker in second column
#
#create 3rd - n column lockers for row
(2...column_count).each ... | true |
dde29e7429ffa34167dab1806d3d5d5b8610d0fb | Ruby | kojiro-abk/rails-simple-airbnb | /db/seeds.rb | UTF-8 | 1,651 | 2.59375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
bb9f53da02e0dfc840ce1f2b2b883c66c1836f35 | Ruby | BrandyMint/auto_logger | /lib/auto_logger.rb | UTF-8 | 1,817 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'logger'
require 'active_support'
require 'active_support/core_ext/string/inflections'
require 'beautiful/log'
require "auto_logger/version"
require "auto_logger/formatter"
require "auto_logger/named"
# Миксин добавляет в класс метод `logger` который пишет лог
# в файл с названием класса
#
#
# Использование:
... | true |
7a74d323f7bb3d1e11226523c888784d727b8fe5 | Ruby | githubtest96/Ani-Test | /app/controllers/sessions_controller.rb | UTF-8 | 1,420 | 2.578125 | 3 | [] | no_license | class SessionsController < ApplicationController
def index
@sessions = Session.order(start_date: :desc).all
end
def new
@cinemas = Cinema.order(name: :desc).all
end
def create
_start_date = DateTime.parse(params[:startDate])
_cinemaId = params[:cinemaId]
_hall_id = params[:hallId]
_f... | true |
915eb4142c535b0e1f21a892af55bc40d5a5b694 | Ruby | degica/openlogi | /spec/openlogi/base_object_spec.rb | UTF-8 | 1,816 | 2.71875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
class DummyObject < Openlogi::BaseObject
property :bar
end
describe Openlogi::BaseObject do
describe ".new" do
it "issues warning about attributes not defined as properties on object" do
expect_any_instance_of(DummyObject).to receive(:warn).once.with("foo is not a property of Dummy... | true |
6a31f6a469b27b5ad792a581f39b8e3da3552ecc | Ruby | Joanf81/citytalk | /app/models/articles/article.rb | UTF-8 | 564 | 2.5625 | 3 | [] | no_license | module Articles
class Article < ApplicationRecord
has_many :article_editions
has_many :users, through: :article_editions
validates :article_editions, length: { minimum: 1 }
attr_accessor :picture
attr_accessor :content
def article_owner
article_editions.first.user
end
def is_article_owner? user... | true |
bff2df978e5a9c8e547393dac23b18cdbc19dc9e | Ruby | r-osoriobarra/desafios_hashes_01-06-21 | /ejercicio_propuesto.rb | UTF-8 | 314 | 3.390625 | 3 | [] | no_license | #ejercicio propuesto
100.times do |e|
num = e+1
if num % 3 == 0
if num % 5 == 0
pp "#{num} es divisible por ambos"
else
pp "#{num} es divisible por 3"
end
elsif num % 5 == 0
pp "#{num} es divisible por 5"
else
pp "#{num}"
end
end | true |
53daf41e11f01d84c96753c20738c4855b392702 | Ruby | GoBeyond87/URI-Ruby | /1008.rb | UTF-8 | 161 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
f = gets.to_i
h = gets.to_i
v = gets.to_f
s = h * v
puts "NUMBER = #{f}"
print 'SALARY = U$ '
puts format('%.2f', s)
| true |
ce45fe4b4dd1e0cd526bd6932597b42cbca82068 | Ruby | oguratakayuki/code_test | /ruby/basis/dump_test.rb | UTF-8 | 463 | 3.59375 | 4 | [] | no_license | class Hoge
attr_accessor :name
def initialize
@name = 'hoge'
end
end
#h = Hoge.new
#c_name = h.name
#
##破壊的メソッドを使うと書き換わる
#h.name.replace('piyo')
#puts c_name
#
#
#
#h2 = Hoge.new
#c_name2 = h2.name.dup
#
##これは大丈夫
#h2.name.replace('piyo')
#puts c_name2
h =Hoge.new
h2 =h
h3 =h.dup
puts h.object_id
puts h... | true |
df40450afe5ac2bcce44968f7f8fde1ebd03407d | Ruby | PikachuEXE/stale_options | /lib/stale_options/abstract_options.rb | UTF-8 | 2,611 | 2.796875 | 3 | [
"MIT"
] | permissive | module StaleOptions
class AbstractOptions
# Params:
# +record+:: +Object+:: An +Object+, +Array+ or +ActiveRecord::Relation+.
# +options+:: +Hash+::
# * +:cache_by+::
# * +String+ or +Symbol+::
# A name of method which returns unique identifier o... | true |
72c25a34c158032e4c555d28e2494e1b19e8aac8 | Ruby | dowism/Coding | /Ruby5-8/evenmoreHashPractice.rb | UTF-8 | 2,708 | 4.5 | 4 | [] | no_license | =begin
In this lesson you will take the scattered lines of
this code and reconstruct it into a program that does the following
1. tells the user what is going to happen
2. collects the users classes until they are done
3. collects the users HW for each class.
4. then allows the use to view their hw, change their hw, ad... | true |
f2ce25d65ef92e170c4579d1046978c5d6f29542 | Ruby | pete3249/oo-banking-onl01-seng-pt-052620 | /lib/transfer.rb | UTF-8 | 1,456 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Transfer
attr_accessor :status
attr_reader :sender, :receiver, :amount
def initialize(sender, receiver, amount)
@sender = sender
@receiver = receiver
@amount = amount
@status = "pending"
end
def valid?
if self.sender.valid? && self.receiver.valid?
return true ... | true |
942ca033878e36836c01e7d3253cd9bb5a513d7f | Ruby | ewansheldon/leap-year-kata | /spec/year_spec.rb | UTF-8 | 575 | 3.109375 | 3 | [] | no_license | require './lib/year'
describe 'leap_year?' do
it 'returns false if year is not divisible by 4' do
year = Year.new(1997)
expect(year.leap_year?).to equal(false)
end
it 'returns true if year is divisible by 4' do
year = Year.new(1996)
expect(year.leap_year?).to equal(true)
end
it 'returns tru... | true |
4a56c42be7a00222256eef8caa36508872d26b6e | Ruby | charleswang234/Two-Player-Math-Game | /main.rb | UTF-8 | 745 | 3.671875 | 4 | [] | no_license |
class Player
def initialize(name, lives)
@name = name
@lives = lives
end
end
class Question
attr_accessor :num1, :num2, :sum
def initialize()
@num1 = generate_random
@num2 = generate_random
@sum = total_sum
end
def generate_random
rand(1..20)
end
def total_sum
self.num... | true |
26ef6c766360486006d4a5aa09f2b699e83586d8 | Ruby | nikhilbelchada/family-tree | /spec/command_spec.rb | UTF-8 | 2,881 | 2.953125 | 3 | [] | no_license | require 'command.rb'
require 'command/add.rb'
require 'command/relation.rb'
require 'command/search.rb'
require 'relation.rb'
require 'relation/father.rb'
require 'relation/mother.rb'
require 'relation/child.rb'
require 'relation/sibling.rb'
RSpec.describe Command do
describe "is_valid?" do
context "add" do
... | true |
7b311d2387c4c6362142efd0f064d78c8f892966 | Ruby | mark/shard | /lib/shard/cli/fork.rb | UTF-8 | 1,343 | 2.71875 | 3 | [
"MIT"
] | permissive | module Shard::CLI
class Fork
################
# #
# Declarations #
# #
################
attr_reader :ref
###############
# #
# Constructor #
# #
###############
def initialize(shard_line)
@ref = Shard:... | true |
a6a3ab9954b8182c7cc148ff251828a72554043f | Ruby | thebravoman/software_engineering_2013 | /class7_homework/test_Kiril_Kostadinov.rb | UTF-8 | 479 | 2.53125 | 3 | [] | no_license | require 'csv'
CSV.open("Kiril_Kostadinov_test_data/result.csv", "w") do |csv|
Dir.glob("*.rb") do |program|
next if program[0..3] == test
`mkdir test`
`ruby #{program} Kiril_Kostadinov_test_data/28.srt Kiril_Kostadinov_test_data/out.txt`
result = `diff Kiril_Kostadinov_test_data/out.txt Kiril_Kostadinov_test_... | true |
548dd6580481ba87066f332d3a6bcb36b7579889 | Ruby | zedtran/PrinciplesOfProgrammingLangs | /Ruby_LexicalAnalyzer/TinyToken.rb | UTF-8 | 752 | 3.484375 | 3 | [] | no_license | #
# Class Token - Encapsulates the tokens in TINY
#
# @type - the type of token
# @text - the text the token represents
#
class Token
attr_accessor :type
attr_accessor :text
EOF = "eof"
LPAREN = "("
RPAREN = ")"
WS = "whitespace"
ADDOP = "+"
MINUSOP = "-"
MULTOP = "*"
DIVOP = "/"
EQUALOP = ... | true |
1f9d64e9af7f1685d1c8aaaf7c4ac6447eb20f55 | Ruby | jkoomjian/MyEmailResponseRate | /email2db.rb | UTF-8 | 3,748 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'net/imap'
require 'mongo'
require 'date'
include Mongo
############################################
# This script copies emails from gmail and
# inserts them into a mongo db
# modified from: http://wonko.com/post/ruby_script_to_sync_email_from_any_imap_server_to_gmail
#####################... | true |
eca121c3214cd03a1da28405d6a4c141f905f9b3 | Ruby | ckaminer/api_curious | /app/models/geocoding.rb | UTF-8 | 218 | 2.609375 | 3 | [] | no_license | class Geocoding < OpenStruct
def self.service
@@service ||= GeocodingService.new
end
def self.retrieve(lat, lng)
address = service.get_address(lat, lng)
Geocoding.new({address: address})
end
end
| true |
679bb42749ef2356cf4de85ac604e3b7c5d8cdfc | Ruby | Berlinta/ruby-object-attributes-lab-online-web-pt-021119 | /lib/dog.rb | UTF-8 | 240 | 3.265625 | 3 | [] | no_license | class Dog
def name=(new_pup)
@name = new_pup
end
def name
@name
end
def breed=(new_kind)
@breed = new_kind
end
def breed
@breed
end
end
fido = Dog.new
fido.name = "Fido"
snoopy = Dog.new
snoopy.breed = "Beagle" | true |
30c515404f4c17dd6c5f26600e32aa79b85ff8ee | Ruby | arpodol/ruby_small_problems | /easy7/lettercase_counter.rb | UTF-8 | 680 | 3.78125 | 4 | [] | no_license | def letter_case_count(string)
results_hash = {:lowercase => 0, :uppercase => 0, :neither => 0}
string_array = string.split('')
string_array.each do |character|
if !!(character =~ /[a-z]/)
results_hash[:lowercase] +=1
elsif !!(character =~ /[A-Z]/)
results_hash[:uppercase] +=1
else
re... | true |
fd54261e6f18afe82c68551e355f30d6b9f27cfe | Ruby | ardenzhan/dojo-ruby | /arden_zhan/rails/blogs/queries.rb | UTF-8 | 2,735 | 2.8125 | 3 | [] | no_license | # Have the first 3 blogs be owned by the first user
User.first.update(blogs: Blog.where("id <= 3"))
# Have the 4th blog you create be owned by the second user
Blog.fourth.owners.create!(user: User.second)
# Have the 5th blog you create be owned by the last user
Blog.fifth.owners.create!(user: User.last)
# Have the t... | true |
b224e6afdc7106ea9137dbea1d7425b4972ecb71 | Ruby | BeerBatteredCode/week_02 | /day_01/specs/library-spec.rb | UTF-8 | 661 | 2.828125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../library')
class TestLibrary < Minitest::Test
def setup
@library = Library.new()
@book = {
title: "lord_of_the_rings",
rental_details: {
student_name: "Jeff",
date: "01/12/16"
}
}
@library.b... | true |
2f865a5c170bece897a7a6d5f4f33e08066f3c35 | Ruby | rockcoolsaint/depot_in_rails | /app/models/user.rb | UTF-8 | 1,075 | 2.59375 | 3 | [] | no_license | class User < ActiveRecord::Base
require 'digest/sha2'
attr_accessor :password
#attr_reader :password
validates :name, presence: true, uniqueness: true
validates :password, presence: true, confirmation: true
#validate :password_must_be_present
before_save :encrypt_password
after_destroy :ensure_an_admin_rem... | true |
441ab1168611f2dae93767ec31c85283ec84ae6a | Ruby | wildkain/simple_rack_time | /time_formatter.rb | UTF-8 | 886 | 3.046875 | 3 | [] | no_license | class TimeFormatter
TIME_FORMAT = { "year" => "%Y", "month" => "%m", "day" => "%d",
"hour" => "%H h", "minute" => "%M m", "second" => "%S s" }.freeze
attr_accessor :status, :body
def initialize(query_string)
@query_string = query_string
@true_format = []
@unknown_format = []
qu... | true |
bc2e26f66455abee9c1eadaa76604ebccf0ac7d9 | Ruby | ZABarton/phase-0 | /week-6/credit-card/my_solution.rb | UTF-8 | 4,812 | 4.34375 | 4 | [
"MIT"
] | permissive | # Pseudocode
# Input: A 16 digit credit card number
# Output: True or false (depending on if credit card number is valid or not)
# Steps:
#
# Define CC Class
#
# Define the initialize method:
# Raise an argument error if CC# is not a 16 digit integer
# Take the argument passed into the init method and create a 16-... | true |
8ab76ab96588364183b6b949845f5a37a4848406 | Ruby | machinio/solrb | /lib/solr/query/request/filter.rb | UTF-8 | 1,810 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'date'
module Solr
module Query
class Request
class Filter
include Solr::Support::SchemaHelper
using Solr::Support::StringExtensions
EQUAL_TYPE = :equal
NOT_EQUAL_TYPE = :not_equal
attr_reader :type, :field, :value
def initialize(type:, field:, valu... | true |
152ea5c210f49e7f3c25cce0eb1bfeda2ca76514 | Ruby | yauralee/merchant-guide | /spec/lib/calculator_spec.rb | UTF-8 | 2,496 | 3.03125 | 3 | [] | no_license | require 'parser/input_parser'
require 'Calculator'
RSpec.describe Calculator do
let(:input_parser) {InputParser.new}
let(:known_transactions) {input_parser.yaml_parser('resource/known_transactions.yml')}
let(:symbols_attributes) {input_parser.yaml_parser('resource/latin_symbols_attributes.yml')}
let(:calculato... | true |
690f7919926d4426c53b95c0d2e61a5cdc946eb4 | Ruby | mi2zq/senju | /lib/senju/credentials.rb | UTF-8 | 351 | 2.59375 | 3 | [] | no_license | require 'yaml'
class Senju::Credentials
attr_reader :data
def initialize(filepath = nil)
filepath ||= Dir.home + '/.senju/credentials'
@data = YAML.load_file(filepath)
end
def [](conf)
@data[conf]
end
end
class Senju::Credential
def self.all
Senju::Credentials.new.data
end
def self.fi... | true |
829379e1ab5135601c310b046438ff3b1360529d | Ruby | nhsykym/AOJ | /ITP1_6_A.rb | UTF-8 | 69 | 2.796875 | 3 | [] | no_license | n = gets.to_i
arr = gets.split.map(&:to_i)
puts arr.reverse.join(' ') | true |
ad75528f9099f140fa4bef7475e3b2af96de8ca3 | Ruby | martinstreicher/laserbeam | /lib/room.rb | UTF-8 | 2,204 | 3.234375 | 3 | [] | no_license | require 'hashie'
class Room
LASER = '@'
NoLaserException = Class.new Exception
RoomDesignException = Class.new Exception
InfiniteLoopException = Class.new Exception
attr_accessor :grid, :laser, :optics
def initialize(description)
self.optics = to_optics to_rows(description)
self.grid = to_room... | true |
cfadb45ba577e0015e483aa6f8a99ff6edcc4423 | Ruby | PhilipTimofeyev/LaunchSchool | /Intro_To_Programming/Ruby_Basics/Strings/String_Ex10.rb | UTF-8 | 93 | 2.53125 | 3 | [] | no_license | colors = 'blue pink yellow orange'.split
colors.include?('yellow')
colors.include?('purple') | true |
39eff94295398e100557bfb1807e95720526af49 | Ruby | christianmacnamara/GA-Files | /HW_04.rb | UTF-8 | 2,640 | 4.53125 | 5 | [] | no_license | ###############################################################################
#
# Introduction to Ruby on Rails
#
# Lab 04
#
# Purpose:
#
# Read the steps below and complete the exercises in this file. This Lab
# will help you to review the basics of Object-Oriented Programming that
# we learned in Lesson 04.
#
#####... | true |
adea2d931e0501596116f8246808f92b48e30771 | Ruby | seann1/to_do_list_activerecord | /spec/list_spec.rb | UTF-8 | 690 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe List do
it "has many tasks" do
list = List.create({:name => "list"})
task1 = Task.create({:name => "task1", :list_id => list.id})
task2 = Task.create({:name => "task2", :list_id => list.id})
list.tasks.should eq [task1, task2]
end
it 'validates presence of a name' ... | true |
02312bc064d05555d8739932c52fff18d6a15249 | Ruby | Mortaro/towstagem | /lib/towsta/kinds/datetime.rb | UTF-8 | 443 | 2.53125 | 3 | [] | no_license | module Towsta
module Kinds
class DatetimeKind < MainKind
def set content
return @content = content if content.class == Time
begin
@content = DateTime.strptime(content, '%m/%d/%Y %H:%M').to_time
rescue
@content = nil
end
end
def export
... | true |
3b9d4e57040730ddc9abe0ac9d8a9b2bb5899edb | Ruby | mdippery/usaidwat | /spec/usaidwat/formatter_spec.rb | UTF-8 | 16,559 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'timecop'
module USaidWat
module CLI
describe BaseFormatter do
describe "options" do
describe "date formats" do
describe "#relative_dates?" do
it "should return true if a relative date formatter" do
f = BaseFormatter.new(:date_format... | true |
808e0bfd439ecb1aedf6fea395020381b8544390 | Ruby | SauperMagiuse/Forum | /app.rb | UTF-8 | 3,130 | 2.78125 | 3 | [] | no_license | require 'sinatra'
require 'sequel'
enable 'sessions'
#Open Database
DB = Sequel.connect('sqlite://db/userdata.db') #Where everything is kept
get '/' do #Main forum page
@login = session[:username]
@posts = []
postdata = DB[:dataPost].where(:parentID => 0) # Passing in Front page render data and only grabs the ... | true |
c71f483606f39cd89a130a9d75d0a25978386618 | Ruby | CraMo7/wkndhw2 | /classes/hotel.rb | UTF-8 | 959 | 3.125 | 3 | [] | no_license | require_relative("../classes/booking.rb")
require_relative("../classes/recordbook.rb")
class Hotel
attr_reader :capacity, :occupancy, :bookings
def initialize(params = {})
params.has_key?(:single_rooms) ? @single_rooms_total = params[:single_rooms] : @single_rooms_total = 0
params.has_key?(:double_room... | true |
d28011d6c1b6b7719382f8a2c8034ef0b57eb42e | Ruby | jociemoore/ruby_oop_practice | /120_lesson_2/bonus_features.rb | UTF-8 | 6,479 | 3.484375 | 3 | [] | no_license | # keep score
# Lizard Spock
# History of Moves
# => I used an array of arrays which records the win or loss and the move choice.
# => I included the history methods in the existing Player class.
# => I outputted the history of moves as a numbered list.
# Adjust computer choice based on history
require 'pry'
class ... | true |
22872cb009f00314f1acbd1132fb188318284d36 | Ruby | chongr/minesweeper | /minesweeper.rb | UTF-8 | 4,770 | 3.40625 | 3 | [] | no_license | require "yaml"
class Minesweeper
def initialize(player)
@player = player
@gameboard = Board.new
end
def play
playturn until gameover?
end
def playturn
#@gameboard.display
@gameboard.player_display
move = @player.get_move
make_move(move)
save_game
... | true |
4fd9c1e4ae59d24c7dd81614a6dfe2dcd7af218d | Ruby | oneplus-x/OhNo | /ohno-c | UTF-8 | 15,613 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Evil Image Builder
# A Ruby ExifTool GUI of sorts
# By: Hood3dRob1n
#
# Pre-Requisites:
# MiniExifTool is a wrapper for ExifTool CLI
# ExifTool CLI Installation: http://www.sno.phy.queensu.ca/~phil/exiftool/install.html
# Download file...
# cd <your download directory>
# gzip -dc Image-E... | true |
d613e23a87f37caebdb6a4aee46f896869cc81e9 | Ruby | justin-tse/app-academy | /02-software-engineering-foundations/08-object-oriented-programming/justin-fa-mastermind_project/lib/mastermind.rb | UTF-8 | 462 | 3.484375 | 3 | [] | no_license | require_relative "code"
class Mastermind
def initialize(length)
@secret_code = Code.random(length)
end
def print_matches(other_code)
puts "exact matches: #{@secret_code.num_exact_matches(other_code)}"
puts "near matches: #{@secret_code.num_near_matches(other_code)}"
end
def ask_user_for_guess
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.