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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37a5672dd383162f6e25ddc8a646d287abd4e5d0 | Ruby | pemacy/Launch_School | /Coursework/100/149/Challenges/Medium2/3_pascals_triangle.rb | UTF-8 | 526 | 3.921875 | 4 | [] | no_license | # 3_pascals_triangle.rb
require 'pry'
class Triangle
def initialize(num)
@num = num
@arr = [[1],[1,1]]
end
def rows
first_iteration if @num > 2
@arr.first(@num)
end
def first_iteration
(@num - 2).times do |n|
a = @arr.last.dup
@arr << [1, second_iteration(a), 1].flatten
end
end
def second_... | true |
9d10b11546bd7feff4d6cb29420102bbc78caf5d | Ruby | pixelastic/oroshi | /config/awesome_print/awesome_print_config.rb | UTF-8 | 890 | 2.6875 | 3 | [] | no_license | # Awesome_print defaults.
# Awesome print only accept a small range of colors for its output. We'll try
# to get colors as close as our theme as we can. When not sure what a color is,
# we'll just put it to red, to easily spot it.
AwesomePrint.defaults = {
indent: 2,
index: true,
html: false,
mul... | true |
6c0d22dcc4eab30fd0275212a9a7739525c04303 | Ruby | linhbui/Euler-Uva-CodeAbbey | /Random problems/Remove Specified Characters.rb | UTF-8 | 1,112 | 3.78125 | 4 | [] | no_license | #delete characters from a string. remove_str(str,remove).
# any character existing in remove must be deleted from str.
#eg "Battle of the Vowels: Hawaii vs. Grozny" and remove "aeiou"
# => "Bttl f th Vwls: Hw vs. Grzny"
# Ruby
def remove_str(str, remove)
original = str.split(//)
deleted = remove.split(//)
dele... | true |
b05528b98db2511b3ab42a653e4c57311a52daa3 | Ruby | ddianalim/monkey_patching_project | /monkey_patching_project/lib/array.rb | UTF-8 | 1,922 | 3.609375 | 4 | [] | no_license | # Monkey-Patch Ruby's existing Array class to add your own custom methods
require 'byebug'
class Array
def span
# if self.length > 0
if !self.empty?
return self.max - self.min
end
end
def average
# if self.length > 0
if !self.empty?
return s... | true |
734e3596052b53f2c612f5ce94443b98e1e32ef9 | Ruby | Jekmetz/CS310Repo | /Ruby/prelimprogram.rb | UTF-8 | 206 | 3.078125 | 3 | [] | no_license | arr = Array.new(10) { rand(1..20) }
def printarr (arr)
$STDOUT.print("[")
for i in 0..(arr.length - 1)
$STDOUT.print("#{arr[i]}, ")
end
$STDOUT.print("#{arr[arr.length - 1]}]\n")
end
printarr(arr)
| true |
eff5a351891279c6a3d470606b84392f7b5641af | Ruby | alxcarrion713/OOP | /wizard,ninja,samurai/ninja.rb | UTF-8 | 187 | 3.203125 | 3 | [] | no_license | require_relative 'human'
class Ninja < Human
def initialize
@stealth = 175
end
def steal(object)
attack(object)
@health += 10
self
end
def get_away
@health -= 15
end
end | true |
46ccf979c38b065c21265bedc87450bd3e9e1df9 | Ruby | Woumpousse/KHL | /bop/quizzes/interpret-methods/exercises.rb | UTF-8 | 989 | 2.8125 | 3 | [] | no_license | require './Shared.rb'
require './Java.rb'
require './Toledo.rb'
class Question
def initialize(code)
@code = code
end
def output
bundle = Java::Bundle.from_string(@code)
Java::run(bundle)
end
attr_reader :code
end
$questions = []
def question
code = yield
$questions.push( Question.new(co... | true |
a9ef83e7727dd6c4b06782bda16f2179c9f3baf4 | Ruby | dmoore1989/BenchBnb | /app/models/bench.rb | UTF-8 | 753 | 2.609375 | 3 | [] | no_license | class Bench < ActiveRecord::Base
validates :description, :lat, :lng, :seating, presence: true
def self.bench_in_bounds(params)
bounds = params["bounds"]
if params["min"] && params["max"]
min = params["min"] != "" ? params["min"] : 0
max = params["max"] != "" ? params["max"] : nil
else
... | true |
fc6915113ccb805683e1707b0bdc7fc100226c82 | Ruby | davetrollope/gitstats | /app/helpers/pr_view_data_mapping_helper.rb | UTF-8 | 4,026 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'hash_arrays'
module PrViewDataMappingHelper
class << self
def open_author_summary_json(_filename, pr_data)
pr_data.sort_by! {|pr| pr[:author].downcase}
authors = pr_data.map {|pr| pr[:author]}.uniq
summary_data = authors.map {|author|
author_prs = pr_data.where(author: author)... | true |
cf4e3e069ebeb5d807f7bc6fe3e3cf783a0124b2 | Ruby | LelandCurtis/flash_cards | /lib/turn.rb | UTF-8 | 459 | 3.6875 | 4 | [] | no_license | # create a turn class
class Turn
# initialize variables with read funcationality
attr_reader :guess,
:card
# initialize Turn class
def initialize(guess, card)
@guess = guess
@card = card
end
# add correct? method
def correct?
self.guess.downcase == self.card.answer.downcase
... | true |
5006a3f7248dace12faa5927ece45b0bf4a92f28 | Ruby | AlchemyCMS/alchemy_cms | /spec/libraries/config_spec.rb | UTF-8 | 4,687 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require "rails_helper"
module Alchemy
describe Config do
describe ".get" do
it "should call #show" do
expect(Config).to receive(:show).and_return({})
Config.get(:mailer)
end
it "should return the requested part of the config" do
expect(Con... | true |
72a4043f89d6b92fda1d3a9ea73092e34da8d705 | Ruby | JLWolfe1990/andros | /app/models/card.rb | UTF-8 | 421 | 3.4375 | 3 | [] | no_license | class Card
attr_accessor :suit, :type
SUITES = ['hearts', 'spades', 'clubs', 'diamonds'].freeze # quick and dirty enum
TYPE_AND_VALUES = {
'A' => 1,
'2' => 2,
'3' => 3,
'4' => 4,
'5' => 5,
'6' => 6,
'7' => 7,
'8' => 8,
'9' => 10,
'10' => 10,
'J' =>... | true |
37f123096f3c25b514c8932f485e64f9d039c70f | Ruby | atnan/euler | /004.rb | UTF-8 | 448 | 3.890625 | 4 | [] | no_license | # Problem 4:
# Find the largest palindrome made from the product of two 3-digit numbers
class Integer
def palindrome?
str = self.to_s
str.to_s == str.reverse
end
end
largest = 1
range = 999
range.downto(100) do |one|
range.downto(100) do |two|
next if one < two
product = one * two
if produc... | true |
cbe1e88093eaa25dfc25a314aecd4f6c1fa4a5d8 | Ruby | larisasmiles/homework | /bad_connection.rb | UTF-8 | 595 | 3.3125 | 3 | [] | no_license | counter = 0
ready_to_quit = counter > 1
puts "HELLO, THIS IS A GROCERY STORE!"
until ready_to_quit
input = gets.chomp
if input.empty?
puts "HELLO?!"
elsif input.chars.any? { |letter| letter == letter.downcase }
puts "I am having a hard time hearing you."
elsif input.chars.all? { |word|... | true |
cf0f7638361aca9866f0a69b3c7b425ad5b6727c | Ruby | mooreniemi/experiments | /lib/dij.rb | UTF-8 | 690 | 2.796875 | 3 | [] | no_license | def dij(g, target)
unvisited = g.keys
visited = []
distances = unvisited.each_with_object(Hash.new(:not_found)) do |k, h|
h[k] = Float::INFINITY
end
distances[unvisited.first] = 0
paths = Hash.new([])
until unvisited.empty?
order = distances.sort_by { |_, v| v }.map(&:first)
unvisited = order... | true |
68e152cb21e4902ae2b2e97bc7d8004301a590fe | Ruby | stelligent/SWFpoc | /lib/shared.rb | UTF-8 | 642 | 2.703125 | 3 | [] | no_license | def log(message)
timestamp = Time.now.strftime "%H:%M:%S"
puts "#{timestamp}: #{message}"
end
def configure(config_file)
unless File.exist?(config_file)
puts <<END
To run the samples, put your credentials in config.yml as follows:
access_key_id: YOUR_ACCESS_KEY_ID
secret_access_key: YOUR_SECRET_ACCESS... | true |
8bfed91fd8bd090f8baa19914b26190307979fbc | Ruby | billc2021/DojoAssignments | /04RAILS/02OOP/07WizardNinjaSamurai/samurai.rb | UTF-8 | 365 | 3.484375 | 3 | [] | no_license | require_relative 'human'
class Samurai < Human
@@total_samurai = 0
def self.how_many
@@total_samurai
end
def initialize
super
@health = 200
@@total_samurai += 1
end
def death_blow(victim)
victim.health = 0
end
def meditate
@health = 200
end
end
t1 = Samurai.new
t2 = Samurai.new
t1.death_blow(... | true |
949df97d0d87413663a154c5f7c1f6eb1b829115 | Ruby | rnwaobasi/picky_eater | /lib/workers/transformer.rb | UTF-8 | 2,867 | 3.09375 | 3 | [] | no_license | require 'csv'
require 'date'
require 'set'
class Transformer
COLUMN_ORDER = {
restaurants: [:camis, :dba, :phone, :cuisine, :grade, :grade_date],
locations: [:id, :street, :building, :boro, :zipcode],
restaurant_locations: [:restaurant_camis, :location_id]
}
def initialize(run_id)
... | true |
cf5fe6e0265201634094106e5facf339bfa05f06 | Ruby | lukaszklis/oo_boot_camp_2015-02-02 | /graph/graph_test.rb | UTF-8 | 2,044 | 2.875 | 3 | [] | no_license | # Copyright 2015 by Fred George. May be copied with this notice, but not used in classroom training.
require 'minitest/autorun'
require_relative 'node'
# Confirms graph operations work correctly
class GraphTest < Minitest::Test
('A'..'G').each { |label| const_set(label.to_sym, Node.new(label)) }
B > [A, 6]
B >... | true |
46a446e40f63ab1791330c720cc6502934946478 | Ruby | Mgetch/krypt | /lib/krypt/GCTR.rb | UTF-8 | 772 | 3.328125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'openSSL'
require 'pkcs5' #For the string xor function
plaintext = "testMess"
#I believe this is what they're looking for with the inc function
def inc(cb)
c = 0
additive = 0
left_32 = cb.slice(12..15)
while c<=4
additive += left_32(c)
c+=1
end
additive %= 4
cb = cb.setbyte(15,additive)
e... | true |
811f924074d673bc0537286be63bb91c003cf5e8 | Ruby | iansheridan/dags-dice | /lib/dice/utility/string.rb | UTF-8 | 1,225 | 3.296875 | 3 | [] | no_license | class String
# +constantize+ tries to find a declared constant with the name specified
# in the string. It raises a NameError when the name is not in CamelCase
# or is not initialized. See ActiveSupport::Inflector.constantize
#
# 'Module'.constantize # => Module
# 'Class'.constantize # => Class
# ... | true |
0540f6c3d0c1658e678a06548fa749280c13d5be | Ruby | cookrn/clj_vs_ruby | /programming_clojure/ch1/p2/example.rb | UTF-8 | 273 | 3.0625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | def blank?( string )
string.nil? \
or string.empty? \
or string.chars.all? { | c | c == ' ' }
end
puts blank?( nil ).inspect
puts blank?( '' ).inspect
puts blank?( ' ' ).inspect
puts blank?( ' ' ).inspect
puts blank?( 'a' ).inspect
puts blank?( 'a ' ).inspect
| true |
b4f86a6139461b7d4c7d113788783344d7f04f71 | Ruby | jamespjbennett/bitmap_editor | /lib/bitmap_editor.rb | UTF-8 | 1,702 | 3.171875 | 3 | [] | no_license | require_relative 'bitmap_image.rb'
class BitmapEditor
def initialize(bitmap_image = BitmapImage.new)
@bitmap_image = bitmap_image
@grid = nil
end
def run(file)
return puts "please provide correct file" if file.nil? || !File.exists?(file)
File.open(file).each do |line|
line = line.chomp
... | true |
ee6ed811f250248548b4f067b05a8eb02a2fa55d | Ruby | stefanberndtsson/nmdb3-build | /load/load_people_ids.rb | UTF-8 | 2,371 | 2.78125 | 3 | [
"BSD-3-Clause"
] | permissive | module Nmdb
class People
def self.get_id(person_obj)
if @@people_ids[person_obj.full_name]
return @@people_ids[person_obj.full_name]
elsif @@people_ids[person_obj.reverse_name(true, true)]
return @@people_ids[person_obj.reverse_name(true, true)]
else
@@max_id += 1
... | true |
b906b589f65d2d7da01ff4a1e823da001cc0bf09 | Ruby | HaliksaR/UntitledGooseGame | /lib/actions/action_condition_item.rb | UTF-8 | 435 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative '../constants/action_const'
class ActionConditionItem
include ActionConst
attr_accessor :min, :max
def initialize(params)
@min = params[MIN]
@max = params[MAX]
end
def check_min_max(param)
check_max(param) && check_min(param)
end
def check_max(param_value)
@max.nil? ?... | true |
e6ecdb2aa9e4233766d053274530beec8e3690e5 | Ruby | vmadman/logstash | /spec/codecs/json_lines.rb | UTF-8 | 1,608 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require "logstash/codecs/json_lines"
require "logstash/event"
require "insist"
describe LogStash::Codecs::JSONLines do
subject do
next LogStash::Codecs::JSONLines.new
end
context "#decode" do
it "should return an event from json data" do
data = {"foo" => "bar", "baz" => {"bah" => ["a","b","c"]}}
... | true |
8f8e0b1a6f6d887013f6e4637e80a1ab40e2b891 | Ruby | pophealth-c4/popHealth | /contrib/measure_dates.rb | UTF-8 | 2,136 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | require 'rubygems'
require 'zip/zip'
class ZipFileGenerator
# Initialize with the directory to zip and the location of the output archive.
def initialize(input_dir, output_file)
@input_dir = input_dir
@output_file = output_file
end
def unzip_file()
Zip::ZipFile.open(@output_file) do |zip_file|
... | true |
d3274e7ebbe69ac074ef5124dd205e14407fbcd8 | Ruby | amacou/memcached-printer | /mrblib/memcached-printer/item.rb | UTF-8 | 957 | 2.578125 | 3 | [
"MIT"
] | permissive | module MemcachedPrinter
Item = ::Struct.new(:id, :key, :bytes, :expiration_time, :flags, :value) do
def simple_format(base64 = false)
str = "#{id} #{key} #{bytes} #{expiration_time}"
return str unless value
str = if base64
"#{str} #{flags} #{base64_value}"
else
... | true |
174a501cf0207187d7b08734d18eaaf23e78dbf4 | Ruby | msgalenwhite/News-Aggregator-Plus | /server.rb | UTF-8 | 2,518 | 2.984375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'pry'
require 'csv'
require 'json'
require_relative 'models/article'
set :bind, '0.0.0.0'
def submitted_urls
url_array = []
CSV.foreach('articles.csv', headers:true) do |row|
url_array << row[:url]
end
url_array
end
def write_article_to_csv(data)
CS... | true |
c9fbc1f9cd5e1c3c22d9a78dc552057a646f0747 | Ruby | micoongkeko/batch8-activities | /rubyactivities/count_positives.rb | UTF-8 | 290 | 3.5625 | 4 | [] | no_license | arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]
positive = 0
negative = 0
arr.each do |num|
if num > 0
positive += 1
elsif num < 0
negative += num
end
end
if arr == []
puts "[]"
else
puts "[#{positive}, #{negative}]"
end | true |
e1f5a4adc2cd9f2e26f262ce6930545c014da773 | Ruby | 17100045/assignment3 | /features/step_definitions/movie_steps.rb | UTF-8 | 1,706 | 3.3125 | 3 | [] | no_license | # Add a declarative step here for populating the DB with movies.
Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
# each returned element will be a hash whose key is the table header.
# you should arrange to add that movie to the database here.
Movie.create!(movie)... | true |
ba8d786944a848755fe5781942acb4771e3bb6b7 | Ruby | luizrogeriocn/ruby_rentacar | /Vehicle.rb | UTF-8 | 243 | 3.203125 | 3 | [] | no_license | class Vehicle
attr_accessor :model, :year, :price, :damage,:id
def initialize(id, model, year, price)
@model = model
@year = year
@price = price
@damage = 0;
@id = id
end
def cause_damage
damage += 1
end
end
| true |
c9124fc0253e9946f9fabd03cb4983ed89b911b9 | Ruby | PPaques/MyDomoHome | /app/controllers/authentification_controller.rb | UTF-8 | 1,566 | 2.5625 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
class AuthentificationController < ApplicationController
layout "identification"
def login
# Si on accède avec la méthode post, on vérifie le login
if request.request_method_symbol == :post
# Est ce qu'il existe une correspondance utilisateur - mot de passe ?
if Use... | true |
6e7116e494ac5f6ac3bb7a585d8303984c61ddd9 | Ruby | AmSmo/sql-table-relations-crowdfunding-join-table-lab-nyc01-seng-ft-080320 | /lib/sql_queries.rb | UTF-8 | 2,041 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
eeec95aed89015be015d31b2545a3d3498c578e4 | Ruby | jmurphy2404/rspecPractice | /app.rb | UTF-8 | 542 | 3.453125 | 3 | [] | no_license | require 'rspec/autorun'
class Factorial
def factorial_of(num)
(1..num).inject(:*)
end
end
# non let version of factorial
# describe Factorial do
# it "finds the factorial of 5" do
# calculator = Factorial.new
# expect(calculator.factorial_of(5)).to eq(120)
# end
# end
# using let (or let! to create object... | true |
6bbf7683643fc3b354897377541f1e4b7f5d8e65 | Ruby | Joseclamo/Scraping-con-Ruby | /scrap-en.rb | UTF-8 | 263 | 2.609375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
html = open("https://etherscan.io/").read
doc = Nokogiri::HTML(html)
doc.xpath('.//*[@id="ContentPlaceHolder1_Label1"]/a/font').map do |element|
puts "The last block in the Ethereum network is: #{element.inner_text}"
end
| true |
402bc8f6c26a44baf51a09dfbd52aa3747ff37d4 | Ruby | ambtus/word_salad | /lib/word_salad.rb | UTF-8 | 380 | 2.9375 | 3 | [
"MIT"
] | permissive | require "word_salad/core_ext"
module WordSalad
# the dictionary as a File object
def self.dictionary
open(File.join(File.dirname(__FILE__), "word_salad/dictionary"))
end
# all the words in the dictionary
def self.words
IO.readlines(self.dictionary)
end
# the number of words in the dictionary... | true |
8f60804e104b0cd10fe7fed379c09df27e48cfda | Ruby | cesarsan8a/seir-01 | /12-comp-sci/recursion/factorial.rb | UTF-8 | 356 | 3.515625 | 4 | [] | no_license | def factorial_iterative(n)
result = 1
while n > 1 # end condition
result *= n # mutation: changing this variable
n -= 1 # mutation: move towards the end condition
end
result
end
def factorial(n)
if n > 1 # keep going
n * factorial(n-1) # recursion: moving towards the end condition
else
1
... | true |
e81baa26dc2f979046787b5aea451e105b5915b5 | Ruby | halil-bolat/eng_20_backup | /OOP/mammals/dog.rb | UTF-8 | 384 | 3.234375 | 3 | [] | no_license | require_relative '../animal'
require_relative '../animal-types/mammals'
class Dog < Animal
#include modules and classes in this instance
include Mammals
def speak
super()
puts 'WOF WOF WOF'
end
def alive
super()
puts 'I am alive'
end
def number_of_legs
Quadraped.legs
end
end
r... | true |
734b42f585df0620dbdee96c5c70c858d5462751 | Ruby | byronroark/nmbr | /guessing_game.rb | UTF-8 | 577 | 4.1875 | 4 | [] | no_license | class Game
def initialize
@number = rand(100).to_i
end
def matches?(guess)
@number == guess
end
def message(guess)
if guess.nil?
"What number am I thinking?"
elsif guess > @number
"Too high, guess lower!"
elsif guess < @number
"Too low, guess higher!"
end
end
d... | true |
162c06d64e14dff750b81b13b7a82e6c8b1ed62b | Ruby | devWRM/ruby-oo-relationships-practice-recipes-exercise-atlanta-web-033020 | /app/models/Recipe.rb | UTF-8 | 982 | 3.140625 | 3 | [] | no_license | class Recipe
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.most_popular
self.all.max { |recipe1, recipe2| recipe1.recipe_cards.length <=> recipe2.recipe_cards.length }
end
def rec... | true |
ad87fdf5cb7dc7f83325de15b87e2fe1065c1791 | Ruby | somethvictory/sync_client | /src/apartment.rb | UTF-8 | 391 | 2.5625 | 3 | [] | no_license | require_relative 'synchronizer'
require_relative 'floor'
class Apartment < Synchronizer
attr_reader :external_id, :floor
def initialize(external_id, floor)
@external_id = external_id.strip
@floor = floor
end
def url
"http://localhost:3000/v1/floors/#{floor.id}/apartments"
end
def as_js... | true |
ce2f79e5ae792826e4a111ffc7cac8a6b7c24f23 | Ruby | m2candre/fuel_app | /test/models/check_status_test.rb | UTF-8 | 1,286 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class CheckStatusTest < ActiveSupport::TestCase
def setup
@new = check_statuses :new
end
test 'should respond to name, description' do
assert_respond_to @new, :name
assert_respond_to @new, :description
end
# Associations.
test 'should have zero or more checks' do
r... | true |
1d2dbb1fcfd034564a809cb6c393be1a6dab0675 | Ruby | islandpress/commons | /app/services/search_builders/sorter.rb | UTF-8 | 652 | 2.640625 | 3 | [] | no_license | module SearchBuilders
SORT_ATTRIBUTES = %w(published_at created_at updated_at).freeze
class Sorter
def initialize(sort, es_params)
@sort = sort
@attributes = @sort&.split(',')
@es_params = es_params
end
def build
return @es_params if @sort.blank?
@attributes.each do |att... | true |
c76ee211a25f6f8e25133656198f8859eebd25c1 | Ruby | dahveed15/App-Academy-Homework | /W1D5/w1d5_exercises.rb | UTF-8 | 948 | 3.578125 | 4 | [] | no_license | class Stack
attr_reader :stack
def initialize
# create ivar to store stack here!
@stack = []
end
def add(el)
# adds an element to the stack
stack.push(el)
end
def remove
# removes one element from the stack
stack.pop
end
def show
# return a copy of the stack
stack.dup... | true |
aa1ff4799cd3b0594e288bae8e65f3636d3d7049 | Ruby | jspooner/skatestock | /app/models/line_item.rb | UTF-8 | 2,934 | 2.6875 | 3 | [
"MIT"
] | permissive | class LineItem < ActiveRecord::Base
# belongs_to :master
belongs_to :image_shell
has_and_belongs_to_many :price_options
belongs_to :cart
belongs_to :price_usage
belongs_to :price_media
def self.for_master(img)
item = self.new
item.image_shell = img
item
end
# Options a... | true |
215752dcea67a77f5630f39e64302b80bf6c4259 | Ruby | bgates/littleredbrick | /app/models/term.rb | UTF-8 | 2,788 | 2.578125 | 3 | [] | no_license | class Term < ActiveRecord::Base
belongs_to :school
has_many :tracks, :dependent => :destroy
has_many :reported_grades, :as => :reportable,
:dependent => :destroy
has_many :sections, :through => :tracks,
... | true |
ba55cf1e80b5703f534a7539df96db96e67f4085 | Ruby | kierrakay/triangle-classification-online-web-pt-081219 | /lib/triangle.rb | UTF-8 | 943 | 3.171875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Triangle
def initialize(side_1,side_2,side_3)
@side_1 = side_1
@side_2 = side_2
@side_3 = side_3
end
def kind
if (@side_1 <= 0) || (@side_2 <= 0) || (@side_3 <= 0)
raise TriangleError
elsif (@side_1+@side_2 <= @side_3) || (@side_1+@side_3 <= @side_2) || (@side_2+@side_3 <= @side... | true |
f58d0d38b3ed87a4a731cea76a3dd175e348243c | Ruby | TimCPB/cautious-octo-guide | /src/modified_sums.rb | UTF-8 | 100 | 3.296875 | 3 | [
"MIT"
] | permissive | def modified_sum(nums, n)
modified_nums = nums.map {|x| x ** n}
modified_nums.sum - nums.sum
end | true |
be543870a96235d2b95c8e1d3e79b4a131cd5ede | Ruby | katamartin/ActiveRecordLite | /lib/sql_object.rb | UTF-8 | 5,658 | 3.078125 | 3 | [] | no_license | require_relative 'db_connection'
require 'active_support/inflector'
class SQLObject
# returns table's column names as array of symbols
def self.columns
return @columns if @columns
data = DBConnection.execute2(<<-SQL)
SELECT
*
FROM
#{self.table_name}
SQL
@columns = data.... | true |
c5b91b083db95de96daf249d90a14f6b9eaafa88 | Ruby | fgreinacher/7-languages-in-7-weeks | /ruby/day3/as_csv.rb | UTF-8 | 1,311 | 3.28125 | 3 | [
"MIT"
] | permissive | module ActsAsCsv
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_csv
include InstanceMethods
end
end
module InstanceMethods
def read
@csv_contents = []
filename = self.class.to_s.downcase + '.... | true |
9c7d52e070e51108c2a036b8436a5630561aa514 | Ruby | aDAVISk/MimicChest | /Ruby/msgbx.rb | UTF-8 | 1,369 | 3.125 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #msgbx.rb
# Author: Akito D. Kawamura (aDAVISk)
# Working on Ruby in gnupack_devel-13.06-2015.11.08
# This program is published under BSD 3-Clause License
# Description: A class of message box of arbitary
# dimension. Method write promises the string would
# not exceed the width of the box.
# Last Update: 2018/06/... | true |
53d52ff909d5ec0968f751af89b40457a9804db9 | Ruby | robertipk/AIHW2 | /solver.rb | UTF-8 | 636 | 2.71875 | 3 | [] | no_license | # Robert Ip, CISC 3410, Program #2
require_relative 'algorithms'
require_relative 'cell'
require_relative 'puzzle'
require_relative 'arc'
input = File.read("puzzle.txt").split(" ")
num_solved = 0
time = Time.now.strftime('%Y-%m-%d_%H-%M-%S')
backtracking_filename = "Puzzles_Solved_With_Backtracking_" + time
ac3_filena... | true |
57c7f9e0d4721993f97251f2c3a1d62b0684bf9f | Ruby | xthexder/ejson | /test/ejson_test.rb | UTF-8 | 3,388 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'tempfile'
require "mocha/mini_test"
require 'ejson/cli'
class CLITest < Minitest::Unit::TestCase
def test_ejson
f = Tempfile.create("encrypt")
f.puts JSON.dump({a: "b"})
f.close
encrypt f.path
first_run = JSON.load(File.read(f.path))
assert_match(/\AEN... | true |
009310f4746019696f4dd30523e7ea91702eeb9c | Ruby | nptravis/array-CRUD-lab-ruby-apply-000 | /lib/array_crud.rb | UTF-8 | 667 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def create_an_empty_array
[]
end
def create_an_array
[1,2,'3','four']
end
def add_element_to_end_of_array(array, element)
# array << element
array.push(element)
end
def add_element_to_start_of_array(array, element)
# array.unshift(element)
array.insert(0, element)
end
def remove_element_from_end_of_arra... | true |
e9529f06d0dc68108acb267588adf35a831275cd | Ruby | openaustralia/planningalerts_coverage | /scraper.rb | UTF-8 | 721 | 2.9375 | 3 | [] | no_license | # This is a template for a Ruby scraper on morph.io (https://morph.io)
# including some code snippets below that you should find helpful
require 'scraperwiki'
require 'mechanize'
agent = Mechanize.new
# Read in a page
page = agent.get("https://www.planningalerts.org.au/authorities/")
sentence = page.at("#content").... | true |
dce633d38e28ee987926cbe01e27c55ad834167f | Ruby | T-o-s-s-h-y/Learning | /Ruby/exercises/app/mission_d_197.rb | UTF-8 | 260 | 3.359375 | 3 | [] | no_license | =begin
購入金額に応じて付与するポイントを算出する。
=end
class MissionD197
def run
# 購入金額
price = $stdin.gets.to_i
# 購入金額に応じたポイントを付与
puts price >= 1000 ? price / 10 : 0
end
end
| true |
f2951145fab9e7934d20e12adc3a26fc7a2070ca | Ruby | zapo/validates_url | /lib/validate_url.rb | UTF-8 | 3,389 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'addressable/uri'
require 'active_model'
require 'active_support/i18n'
require 'public_suffix'
I18n.load_path += Dir[File.dirname(__FILE__) + "/locale/*.yml"]
module ActiveModel
module Validations
class UrlValidator < ActiveModel::EachValidator
def initialize(options)
options.reverse_merge!... | true |
104ffbe6fd3317f50d72b7618279761c95f2f62e | Ruby | mb52089/odin | /sp.rb | UTF-8 | 397 | 3.421875 | 3 | [] | no_license | def stock_picker(a=array)
i1 = 0
max = 0
days = []
a[(0..(a.length - 1))].each do |v1|
i1 += 1
i2 = i1 + 1
a[(i1..a.length )].each do |v2|
if (v2 - v1) > max then
days = [(i1 - 1),(i2 - 1)]
max = (v2 - v1)
puts "current max is #{max}"
puts "current days are #{d... | true |
f4136863e0d0feae090f7961ac521cf4c04d0929 | Ruby | will-r-wang/CMSLearn-Course-Management-System | /db/seeds.rb | UTF-8 | 3,591 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'faker'
# helper integer function roman to help with roman numeral conversion
class Integer
ROMAN_NUMBERS = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",
10 => "X",
9 => "IX",
5 => "V",
4 => "IV",
1 => "... | true |
3da326f3aa73643343f8ac20d65452b0ed9d231c | Ruby | FrancescoPalma/CodeClan---CX3 | /week_4/d3/rocket_league/specs/match_spec.rb | UTF-8 | 1,090 | 2.59375 | 3 | [] | no_license | require( 'minitest/autorun' )
require 'minitest/rg'
require_relative( '../models/match' )
require_relative( '../models/team' )
class TestMatch < Minitest::Test
def setup
@home_team = Team.new({'name' => 'Inter', 'id' => 1})
@away_team = Team.new({'name' => 'Juventus', 'id' => 2})
options = {
'hom... | true |
749245acfb67b8c9f134678ebd9ab6c00fb6cbd8 | Ruby | Javier-Machin/Gosu_144hz_test | /gosutest.rb | UTF-8 | 905 | 2.890625 | 3 | [] | no_license | require 'gosu'
class GosuTestThing < Gosu::Window #set update_interval: 16.66666 for 60 fps
def initialize width=800, height=600, options = {fullscreen: false, update_interval: 6.9444444}
super
self.caption = "Hello world!"
#object,method("text", line height, opt... | true |
34b32ff9e70960048d0349d85ff88fbf82232c80 | Ruby | sanjeevs/verilog_gen | /spec/hdl_child_array_spec.rb | UTF-8 | 686 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
# Check the syntax for accessing child instances in array.
#
describe VerilogGen::HdlModule do
before(:all) do
class Leaf < VerilogGen::HdlModule
end
class Node < VerilogGen::HdlModule;
10.times do |i|
add_child_instance "leaf#{i}", Leaf
end
end
end
i... | true |
8e1c1cf9c49dc068b642f652e3bbe796661564a4 | Ruby | joekhoobyar/edms-analyzer | /lib/edms/text_analyzer.rb | UTF-8 | 838 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'edms/classifier'
module EDMS
# Simple text analyzer that can classify text with an array of Classifier instances,
# then apply classifications from all applicable Classifier instances, in order.
class TextAnalyzer
def initialize(classifiers: [])
@classifiers = cl... | true |
2ca8d5226b2daa0cf0987249bf723cfa002bf915 | Ruby | a-G-a-o/RB101 | /small_problems/easy_9/7.rb | UTF-8 | 1,246 | 4.4375 | 4 | [] | no_license | =begin
Write a method that determines the mean (average) of the three scores passed to it, and returns the letter value associated with that grade.
Tested values are all between 0 and 100. There is no need to check for negative values or values greater than 100.
Numerical Score Letter Grade
90 <= score <= 100 ... | true |
81591ff5c544ecf838f6db27dc465f1b0f6dbdb3 | Ruby | jordanconway/brewbot | /ratebeer.rb | UTF-8 | 1,604 | 2.546875 | 3 | [] | no_license | #!/usr/local/bin/ruby
require 'rubygems'
require 'cinch'
require 'net/http'
require 'iconv'
require 'hpricot'
require 'uri'
class Ratebeer
include Cinch::Plugin
@help="!beerscore"
match /beerscore (.+)/
def execute(m,beer)
if(m.bot.nick != "homebrewbot")
if(m.bot.user_list.find("homebrewbot"))
... | true |
83399590aa4a3a991d145ff7b042d6eede8ab1b7 | Ruby | tute/refactoring-workshop | /3-replace-method-with-method-object/app.rb | UTF-8 | 1,720 | 3.375 | 3 | [
"MIT"
] | permissive | require 'csv'
# 1. Create a class with same initialization arguments as BIGMETHOD
# 2. Copy & Paste the method's body in the new class, with no arguments
# 3. Replace original method with a call to the new class
# 4. Apply "Intention Revealing Method" to the new class. Woot!
class ExportJob
# More code, methods, and... | true |
85470bf86bba593dca811c59b96c949f05b0e5e4 | Ruby | bugoodby/bugoodbylib | /script/rb/tools/net_printer/udpserver.rb | UTF-8 | 1,289 | 2.8125 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/ruby
require "socket"
require "date"
$count = 0
def saveRecvData( data, ip )
outfile = File.dirname(File.expand_path($0)) << "/udpserver_" << $count.to_s << "_" << Time.now.strftime("%Y%m%d_%H%M%S") << "_from" << ip << ".bin"
File.open(outfile, "wb") {|f|
f.write(data)
}
$count += 1
end
... | true |
8c7e200030f9776960b4faf17ceff21d91826898 | Ruby | kwokasch/oo-cash-register-denver-web-82619 | /lib/cash_register.rb | UTF-8 | 1,286 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class CashRegister
attr_accessor :total, :discount, :names, :item_quantity, :last_transaction
@@all = []
def initialize (discount = 0)
@total = 0
@discount = discount
@names = []
@item_quantity = 0
@last_transaction = 0
@@all << self
e... | true |
bbd55be7885b46b67fbd7d4cb1973258e402a8c2 | Ruby | krongk/enjoypicture | /lib/extractor/beautifulphotonet/import_csv_to_db.rb | WINDOWS-1250 | 1,277 | 2.9375 | 3 | [] | no_license | #==Synopsis
# How to parse CSV data with Ruby
# Parsing with plain Ruby
# filename = 'data.csv'
# file = File.new(filename, 'r')
#
# file.each_line("\n") do |row|
# columns = row.split(",")
#
# break if file.lineno > 10
# end
# This option has several problems
#
# Parsing with the CSV library
# require 'c... | true |
03ddc90626f8cc1b76c162889cf71a034fb98347 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz91_sols/solutions/Rick DeNatale/method_prompter.rb | UTF-8 | 6,783 | 3.03125 | 3 | [
"MIT"
] | permissive | module MethodPrompter
class Interactor
# Try to include the readline library
# if it's not available define a lower-function method
begin
require 'readline'
Interactor.class_eval('include Readline')
rescue... | true |
e8f502429f2f19e98fcf35141a46f586da0bbd13 | Ruby | baptiste-veyrard/Exos_jeudi-vendredi | /exo_14.rb | UTF-8 | 151 | 2.890625 | 3 | [] | no_license | puts 'Choisi un nombre'
nombre = gets.chomp
nombre.to_i.downto(0) do |i|
puts "00:00:#{'%02d' % i}"
sleep 1
end
puts "00:00:#{'%02d' % i}"
| true |
511229ae2b9e2d3e57e71fe888c695fd1ea63abc | Ruby | TonyBHerrera/ruby_authenticator | /area_code_dictionary/playground_area.rb | UTF-8 | 940 | 3.625 | 4 | [] | no_license | dial_book = {
"newyork" => "212",
"newbrunswick" => "732",
"edison" => "908",
"plainsboro" => "609",
"sanfrancisco" => "301",
"miami" => "305",
"paloalto" => "650",
"evanston" => "847",
"orlando" => "407",
"lancaster" => "717",
}
# Get city names form the hash
def get_city_name... | true |
8dc4302c9f9ccb7f7154fd35c6a5606c4bc567b7 | Ruby | urug/strategery | /lib/strategery/transformer/rbtree_repository.rb | UTF-8 | 2,623 | 3.625 | 4 | [
"MIT"
] | permissive | # This uses RBTree, more specifically MultiRBTree. That means that we
# are storing this data in a fairly efficient manner and that we can
# have multiple versions of each key.
# Usage:
# r = RBTreeRepository.new
# r[true] = [patthern]
class RBTreeRepository
include Math
require 'rubygems'
require 'rbtree'... | true |
07f0eb7427c7c0482faef5afb8e67200b9160bcb | Ruby | utja/OO-mini-project-nyc-web-062518 | /app/models/Ingredient.rb | UTF-8 | 777 | 3.21875 | 3 | [] | no_license | class Ingredient
attr_reader :allergen, :name, :users
@@all = []
def initialize(args = {})
@name = args[:name]
@@all << self
end
def self.all
@@all
end
def allergens
Allergen.all.select do |allergen|
allergen.ingredient == self
end
end
def users
allergens.map do |alle... | true |
c2078105587651dae76a5d2311d78c4f600669b4 | Ruby | rahulpatel-tavant/hackerearth | /hackerearth-master/ruby/vizury_1.rb | UTF-8 | 528 | 3.296875 | 3 | [] | no_license | test_cases = gets.chomp.strip.to_i
input1 = []
input2 = []
test_cases.times do
input1 << gets.chomp.strip.split(' ').map(&:to_i)
input2 << gets.chomp.strip.split(' ').map(&:to_i)
end
def sum(arr,n,m)
temp = []
arr.combination(m).to_a.each do |ar|
sum = 0
(1...ar.length).each do |i|
sum += (a... | true |
70fbd8a1c96bcc167ce8281b73fa91d2b1f1ad80 | Ruby | Abdona/Tic_Tac_Toe | /bin/main.rb | UTF-8 | 3,138 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative '../lib/board'
require_relative '../lib/player'
require_relative '../lib/cell'
public
def display_board(param)
puts '+---+---+---+'
puts "| #{param[0]} | #{param[1]} | #{param[2]} | "
puts '+---+---+---+'
puts "| #{param[3]} | #{param[4]} | #{param[5]} |"
puts '+---+---... | true |
b366907082224fd9608966b96a46891cfc4ff8a1 | Ruby | rase-/syksy2012 | /johtek/viikko1/reittiopas1/Search.rb | UTF-8 | 1,684 | 3.578125 | 4 | [] | no_license | require 'rubygems'
require 'json'
require './Node.rb'
# Used to decode the path from the goal node to the first
def decode_path(goal_node)
path = []
until goal_node.nil?
path.unshift goal_node
goal_node = goal_node.previous
end
return path
end
def bfs(start_id, goal_id, nodes)
start_node = nodes[sta... | true |
bd9ce25ade2b472b90c60d1c583dec64b5b60fa9 | Ruby | opheliasdaisies/todos | /todo33/find_keys.rb | UTF-8 | 394 | 4.53125 | 5 | [] | no_license | # Get keys of a hash whose values equal to given arguments.
# Code:
class Hash
def keys_of(*args)
keys = []
self.each do |key, value|
args.each do |num|
keys << key if num == value
end
end
keys
end
end
# {a: 1, b: 2, c: 3}.keys_of(1) #=> [:a]
# {a: 1, b: 2, c: 3, d: 1}.keys_of(... | true |
8b21ef94b2d40ec8f50ee938c70d4ec964ea36cf | Ruby | sbagdat/rubykitabi | /bolum-07/sira_sizde_1-dizi-tamsayi-mi.rb | UTF-8 | 336 | 3.515625 | 4 | [] | no_license | #encoding: utf-8
def tamsayi_mi?(dizi)
dizi.all? {|eleman| eleman.is_a? Integer}
end
dizi = [1, 3, 45, 69, 78, 52, 18]
if tamsayi_mi?(dizi)
puts "Hepsi tamsayı!"
else
puts "Hepsi tamsayı değil!"
end
dizi = [1, 3, 'metin', 69, 78, 52, 18]
if tamsayi_mi?(dizi)
puts "Hepsi tamsayı!"
else
puts "Hepsi tamsayı d... | true |
77ee3d5cafd4f0be3d8636b570e282b06c58096e | Ruby | Graciexia/Algorithm-Practice-Timus-online-judge- | /problem 1131 Copying.rb | UTF-8 | 1,552 | 3.546875 | 4 | [] | no_license | n, k = gets.strip.split(" ").map{|i| i.to_i}
finished_computer = 1
hour = 0
while finished_computer < n
hour += 1
square = 2 ** (hour - 1)
if k <= square
finished_computer += k
hour += ((n - finished_computer) / k.to_f).ceil
break
else
finished_computer += square
end
end
puts hour
# 1131. Co... | true |
d393a427122deae845c6ae3fa64f993f6b6679ca | Ruby | tiy-hou-q1-2016-rails/ruby-examples | /while-until/while.rb | UTF-8 | 244 | 3.40625 | 3 | [] | no_license | #
# counter = 0
#
# while (counter < 10) do
# puts "oh hai #{counter}"
# counter += 1
# end
choice = ""
until (["quit", "q"].include? choice) do
puts "do you want to quit? Enter 'quit or q' to quit"
choice = gets.chomp.downcase
end
| true |
0dde41ee586fb13b1e2d5a6ef9d8604486eadd0e | Ruby | shimbiro/head_first_ruby1 | /05_chapter5/block.rb | UTF-8 | 176 | 3.28125 | 3 | [] | no_license | def my_method (&my_block)
puts "We're in the metho, about to invoke your block"
my_block.call
puts "We're back in the method!"
end
#my method do
puts "We're in the block!"
| true |
02b4c5c54bdc64c70756a022c2cef7908b92eb94 | Ruby | jaimecartodb/Ironhack-week-1 | /4-thursday/2-blog-refactor/model/blog.rb | UTF-8 | 630 | 3.34375 | 3 | [] | no_license |
class Blog
POSTS_PER_PAGE = 3
def initialize(footer_class)
@all_posts = []
@footer_class = footer_class
end
def add_post(post)
@all_posts << post
end
def sort_posts
@all_posts = @all_posts.sort_by! {|post, date| post.date}.reverse
end
def show_front_page(publisher)
sort_posts
position = 0
(... | true |
029eec75cc9aa772e506d20c5db00bbaeb2dbcdb | Ruby | ashwinbalaguru/Hackerrank | /_site/chocolateFeast.rb | UTF-8 | 253 | 3.265625 | 3 | [] | no_license | t = gets.to_i
t.times{
(n, c, m) = gets.split.map{|i| i.to_i}
chocolates = wrappers = n / c
while wrappers >= m
exchange = wrappers / m
chocolates += exchange
wrappers -= (m - 1) * exchange
end
puts chocolates
} | true |
862edff35afd37eca346b01eea93ba12673e2329 | Ruby | spiritbear/cl-website | /app/services/customer_service.rb | UTF-8 | 938 | 2.578125 | 3 | [] | no_license | class CustomerService
class << self
def create_invites_from_params(invites,company_id)
count = 0
errors = []
company = Company.find(company_id)
invites.each_with_index do |invite,idx|
invite = invite.with_indifferent_access
if (invite[:first_name].blank? || invite[:last_nam... | true |
ce954575a12b928b89ed419a4265b4166b0430a4 | Ruby | binaythapamagar/boggle-rails | /app/controllers/application_controller.rb | UTF-8 | 2,036 | 3.328125 | 3 | [] | no_license | require 'json'
class ApplicationController < ActionController::API
# display random set of 16 words
def gameboard
alphabets=['A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
# prefered word for making game easy
easyAlphabets = ['A','H','... | true |
94538f0ecf664e290ae92a7efdf1f80980fffe17 | Ruby | SevenInches/tekala | /models/channel.rb | UTF-8 | 1,892 | 2.515625 | 3 | [] | no_license | #渠道
class Channel
include DataMapper::Resource
attr_accessor :password
# property <name>, <type>
property :id, Serial
property :school_id, Integer
property :gen_key, String
property :name, String
property :type, Integer
property :scan_count, Integer
property :refund_count, Integer
property :fee, ... | true |
91bf1e1116528ecc734132f2b11c1d8e3b13ce95 | Ruby | dinossaur23/mariokart | /project/sprite3D.rb | UTF-8 | 3,991 | 2.84375 | 3 | [] | no_license | class Sprite3D
attr_accessor :x, :y, :z
def initialize(p_window, filename)
@p_window = p_window
@sprites = Gosu::Image.load_tiles(@p_window, filename, 32, 32, true)
@sprites.each do |sprite|
glBindTexture(GL_TEXTURE_2D, sprite.gl_tex_info.tex_name)
glTexParameteri(GL_TEXTURE_2D,... | true |
31680dcbfd1dc19d170000da70805704437fdfff | Ruby | DavidPerich/leetcode-exercises | /backtracking/39.CombinationSum.rb | UTF-8 | 1,355 | 3.796875 | 4 | [] | no_license | # Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.
# The same repeated number may be chosen from candidates unlimited number of times.
# Note:
# All numbers (including target) will b... | true |
b9fd95d92cb8456b61494bf90b8924f596db864d | Ruby | Cloud-42/terraform-aws-jenkins | /Dangerfile | UTF-8 | 8,023 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
URL_SEMANTIC_RELEASE = 'https://www.conventionalcommits.org/en/v1.0.0/#summary'
SEMANTIC_COMMIT_TYPES = %w[build chore ci docs feat fix perf refactor revert style test].freeze
NO_RELEASE = 1
PATCH_RELEASE = 2
MINOR_RELEASE = 3
MAJOR_RELEASE = 4
COMMIT_SUBJECT_MAX_LENGTH = 72
COMMIT_BODY... | true |
e6930673ce8419c503353afd23417bd4d9762402 | Ruby | ricardojusto/ruby | /orange_tree/teste.rb | UTF-8 | 114 | 3.265625 | 3 | [] | no_license |
a = 50
user = gets.chomp
if
puts "ok"
elsif a > 5 && a < 8
puts "more ok"
else
puts "not ok"
end
puts a | true |
a6420858f1b2d770c735c26d953540c33b23c961 | Ruby | crispgm/dslr | /lib/dslr/parser.rb | UTF-8 | 1,379 | 3.140625 | 3 | [
"MIT"
] | permissive | module Dslr
class Parser
attr_reader :attributes, :file_content
attr_reader :result
attr_reader :error
def initialize(filename)
@attributes = {}
@file_content = File.read(filename)
@result = 0
end
def run
self.instance_eval(@file_content)
end
def valid?
... | true |
0074b1719c854ce90d0f9fbb0defd36592f2e9d4 | Ruby | zachjob/bitmaker | /accounts/apocalypse.rb | UTF-8 | 517 | 2.59375 | 3 | [] | no_license | class Zombie
@@horde = []
@@plague_level = 10
@@max_speed = 5
@@max_strength = 8
@@default_speed = 1
@@default_strength = 3
# Instance Methods
def initialize
#code
end
def encounter
#code
end
def outrun_zombie?
#code
end
def survive_attack?
#code
end
# Class Methods
... | true |
65ac3fa9caca0491c4af502f44dd811fd7b3cfaf | Ruby | 14kt0508/ruby | /ruby/lesson4.rb | UTF-8 | 120 | 2.859375 | 3 | [] | no_license | webcamp = "オンラインプログラミング学習"
puts webcamp
Pi = 3.14
puts Pi
name = "田中晃太郎"
puts name | true |
d4249e7e1c9032828e6cc0251dda8b1f4ce4aaca | Ruby | cbeer/KriKri | /lib/krikri/field_enrichment.rb | UTF-8 | 1,931 | 3.015625 | 3 | [
"MIT"
] | permissive | module Krikri
##
# Enrich a specific field or list of fields, setting the property to the
# supplied value
module FieldEnrichment
include Enrichment
##
# The main enrichment method; runs the enrichment against a stated
# set of fields for a record.
#
# This is a narrower case of `Krikri... | true |
9836c1cd41bf4ab27c0f90acd811d681cb92e49a | Ruby | jumbosushi/blogit | /spec/helpers/blogit/application_helper_spec.rb | UTF-8 | 3,495 | 2.5625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe Blogit::ApplicationHelper do
describe :blog_tag do
it "should create a tag element and give it a 'blog_post... prefixed class" do
helper.blog_tag(:div, "hello", id: "blog_div", class: "other_class").should == %{<div class="other_class blog_post_div" id="blog_div">hello</div>... | true |
8a6e0a577a66e797927b7f48e96f1301b881cd17 | Ruby | trefong/phase-0 | /week-4/factorial/my_solution.rb | UTF-8 | 376 | 3.390625 | 3 | [
"MIT"
] | permissive | # Factorial
# I worked on this challenge [with: Patrick Dewitte ].
# Your Solution Below
# return (1..number).each as first_array entries
# tell new array to have the size declared by number
# subtract number by index number and multiply it
# array entry each do n * (n-i)
#end
def factorial (number)
i=1
... | true |
0e4794406dc88b7578fef5d9a5328afb1afca6ea | Ruby | xdimedrolx/pakyow | /pakyow-core/lib/generators/pakyow/app/app_generator.rb | UTF-8 | 879 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
module Pakyow
module Generators
class AppGenerator
class << self
def start
case ARGV.first
when '--help', '-h', nil
puts File.open(File.join(CORE_PATH, 'commands/USAGE-NEW')).read
else
generator = self.new
generat... | true |
2ed1a1bc60b6f29cfb0e09c3ff07e51f03430ebe | Ruby | kstephens/abstracting_services_in_ruby | /hack_night/solution/prob-1.rb | UTF-8 | 347 | 3.625 | 4 | [] | no_license | # Write a MathService module that has a method that can sum an Array of Numbers
# It should raise an exception if not given an Array.
# It should raise an exception if any elements are not Numeric.
require 'math_service'
######################################################################
begin
puts MathService.... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.