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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2302076820233ba373c11811f96384602f2c277b | Ruby | jeromesardoma/LS_Exercises | /ITPWR/arrays/ex7.rb | UTF-8 | 72 | 2.984375 | 3 | [] | no_license | a = [3,4,3,55, "chunky"]
a.each_with_index{ |a, i| puts "#{i}: #{a}" }
| true |
03da31f85c55f7da9816d5d6411414333eaac007 | Ruby | sonikishan/RubyMonk | /yield_isnot_method.rb | UTF-8 | 190 | 3.140625 | 3 | [] | no_license | def foo
puts yield
puts method(:foo)
# uncommnet the following line and see what happens!
# puts method(:yield)
end
foo { "I expect to be heard." }
def bar
yield
end
bar | true |
a2c2287752418faed37fdf931f84caf067b18ec6 | Ruby | bowenng/AppAcademy | /Foundations/procs_project/lib/part_2.rb | UTF-8 | 705 | 3.890625 | 4 | [] | no_license | def reverser(str, &func)
func.call(str.reverse)
end
def word_changer(str, &func)
new_str = []
str.split(" ").each {|word| new_str << func.call(word)}
new_str.join(" ")
end
def greater_proc_value(number, f1, f2)
n1 = f1.call(number)
n2 = f2.call(number)
if n1 > n2
return n1
else... | true |
9ea2ce1a6334935c37e1e669d950f5b86e82963b | Ruby | Levara/lux-fw | /lib/overload/string.rb | UTF-8 | 2,354 | 2.5625 | 3 | [] | no_license | class String
def constantize
Object.const_get('::'+self)
end
# simple markdown
def as_html
self.gsub($/, '<br />')
end
# convert escaped strings, remove scritpts
def to_html opts={}
value = self.gsub(/</, '<').gsub(/>/, '>').gsub(/&/,'&')
value = value.gsub(/<scrip... | true |
50124eb3be7f112a21301a04243e01aec5f14f60 | Ruby | iamabhishekt/leetcode-ruby-1 | /17.letter-combinations-of-a-phone-number.rb | UTF-8 | 1,250 | 3.875 | 4 | [] | no_license | # -*- coding: utf-8 -*-
#
# @lc app=leetcode id=17 lang=ruby
#
# [17] Letter Combinations of a Phone Number
#
# https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/
#
# Given a string containing digits from 2-9 inclusive, return all
# possible letter combinations that the number could repres... | true |
d69667fe92e38fc9d392030723278427bc049e03 | Ruby | taisytran/myscheduler | /spec/myscheduler/event_spec.rb | UTF-8 | 1,236 | 2.609375 | 3 | [] | no_license | RSpec.describe Myscheduler::Event do
# begin time = now; end time = tomorrow
let(:event_1) { Myscheduler::Event.new(1, Time.now, Time.now + 86_400) }
# begin time = 2 days ago; end time = 2 next days
let(:event_2) { Myscheduler::Event.new(2, Time.now - 172_800, Time.now + 172_800) }
context '#all' do
bef... | true |
2529167821f519eec77ce0895ee0d5ba462fe294 | Ruby | rmk8796/Ruby | /Bank_application/transaction.rb | UTF-8 | 353 | 3.53125 | 4 | [] | no_license | # Details of Transaction
class Transaction
attr_reader :amount
def initialize(amt)
@amount = amt
end
# Prints individual transaction statement
def statement
if @amount.positive?
"#{@amount.round(2).to_f}\t\t\t\t\t\tCredited in Bank "
else
"\t\t\t#{-@amount.round(2).to_f}\t\t\tDebite... | true |
4f44309dd60aae34013bf6c2da21cdd7a33f3dc0 | Ruby | akshatpaul/motion-prime | /spec/unit/config/store_spec.rb | UTF-8 | 2,249 | 2.859375 | 3 | [] | no_license | describe MotionPrime::Config do
before { @config = MotionPrime::Config.new }
describe "[]" do
before { @config = MotionPrime::Config.new(foo: "bar") }
it "returns the value if there is one" do
@config[:foo].should == "bar"
@config["foo"].should == "bar"
end
it "returns a new Configatr... | true |
775d826ad0515ab38ba4067601f7faad47f75d0f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/b6c206afc94940ccad11b199faae5426.rb | UTF-8 | 288 | 3.15625 | 3 | [] | no_license | class Gigasecond
def self.from(date)
seconds_to_date_from(date_as_seconds_plus_a_billion_from(date))
end
def self.seconds_to_date_from(seconds)
Time.at(seconds).to_date
end
def self.date_as_seconds_plus_a_billion_from(date)
date.to_time.to_i + (10**9)
end
end
| true |
613f9283b66e8782e15e4b0686497586c7f92514 | Ruby | SebastianCelejewski/EndomondoComplementer | /lib/complementer.rb | UTF-8 | 4,533 | 3.078125 | 3 | [] | no_license | require 'nokogiri'
require 'time'
require './lib/track'
require './lib/track_point'
module EndomondoComplementer
class Complementer
def initialize input_data_directory, output_file_name
@input_data_directory = input_data_directory
@output_file_name = output_file_name
end
def run
puts ... | true |
70eb24968909f2cc9c02b65f725218a1c8e4752f | Ruby | mrbabbs/blogandstuff | /_plugins/categories.rb | UTF-8 | 1,707 | 3.03125 | 3 | [
"CC0-1.0"
] | permissive | =begin
Category plugin, read a template from file
=end
module Jekyll
class CategoryGenerator < Generator
def generate(site)
categories = {}
mappings = {}
site.categories.keys.each do |k| # create a mapping to change the keys
mappings[k] = k.gsub(" ","-")+".html"
... | true |
2be0ed76ae486212e9259db4821052b83abff755 | Ruby | minachuong/lying_war | /io_helpers.rb | UTF-8 | 973 | 2.953125 | 3 | [] | no_license | class TestCase
attr_accessor :naomi_block_weights, :ken_block_weights
def initialize(n_blks, k_blks)
@naomi_block_weights = string_to_blocks(n_blks)
@ken_block_weights = string_to_blocks(k_blks)
end
private
def string_to_blocks(blk_string)
blk_string.chomp.split(' ').map(&:to_f)
end
end
clas... | true |
9af017192b99425f19797dde77c27e23fdae8fab | Ruby | DossierSansTitre/magma-lang | /lib/magma/sema/expr.rb | UTF-8 | 949 | 2.625 | 3 | [] | no_license | require 'magma/sema/expr_assign'
require 'magma/sema/expr_binary'
require 'magma/sema/expr_call'
require 'magma/sema/expr_cast'
require 'magma/sema/expr_literal'
require 'magma/sema/expr_unary'
require 'magma/sema/expr_variable'
module Magma
module Sema
module Expr
def self.assign(id, type, expr)
E... | true |
858a96a90d88051244b62bbf71a779c2676f266f | Ruby | audiogon/sendgrid_postback | /lib/sendgrid_postback/mail_interceptor.rb | UTF-8 | 1,213 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'mail'
require 'mail/message'
module SendgridPostback
class MailInterceptor
# Intercept emails before they are sent, primarily to create a UUID that will be added to the mail headers.
# SendgridPostback will post back events for messages as they are processed.
# This is done here, rather than i... | true |
90dae7af85775a4a4e9c142d0b71cc77f90fb94e | Ruby | jkjoeeekim/W2D5 | /todo_board_project/todo_board.rb | UTF-8 | 1,825 | 3.21875 | 3 | [] | no_license | require 'byebug'
require_relative './list'
class TodoBoard
def initialize
@labels = {}
end
def get_command
puts 'Enter a command, or `-help` for a list of commands'
cmd, list_label, *args = gets.chomp.split(' ')
list = @labels.values_at(list_label).first
case cmd
when 'mklist'
@lab... | true |
75ba3b2ad6744efa6f7d8145c5dbc099f77e6dc3 | Ruby | jonashermann/a_real_web_server_and_browser | /a_tiny_web_browser.rb | UTF-8 | 1,243 | 3.140625 | 3 | [] | no_license | require 'socket'
require 'json'
host = "localhost"
port = 3000
params = Hash.new {|hash, key| hash[key] = Hash.new}
#input validation: Require GET or POST
input = ''
while input != 'GET' && input != 'POST'
print 'What type of request do you want to submit [GET] or [POST]?'
input = gets.chomp
end
#Get inputs ... | true |
b934018558fd6c037f03f2486f85b4a676e0f326 | Ruby | joshwcomeau/learn_ruby | /05_silly_blocks/silly_blocks.rb | UTF-8 | 188 | 3.421875 | 3 | [] | no_license | def reverser
arr = yield.split(" ")
arr.map! do |word|
word.reverse
end
arr.join(" ")
end
def adder(n=1)
val = yield
val + n
end
def repeater(n=1)
n.times { yield }
end | true |
3c39f48d1fc84229eeaae6e0f5a314c117bec643 | Ruby | GpGardner/Intro_Ruby | /Chapter_1/method.rb | UTF-8 | 561 | 4.125 | 4 | [] | no_license | #(1)
name = ''
def greeting(name)
return "Hello, " + name + ". How are you?"
end
puts greeting("George")
#(2)
x = 2
# 2
puts x = 2
# prints 2
# returns nil
p name = "Joe"
# prints "Joe"
# returns "Joe"
four = "four"
# returns four
print something = "nothing"
# print "Nothing"
# returns nil
#(3)
def multiply(x,y)
x... | true |
1944d26cba67ee1f66d5db8490de273d8d3297f9 | Ruby | cheperboy/montlevic | /app/models/diverse.rb | UTF-8 | 564 | 2.65625 | 3 | [] | no_license | # fonctionne en association avec les Facdiv
class Diverse < Facture
set_table_name "factures"
def name_diverse
the_date = self.date.to_s
the_cout = self.cout.to_s
the_saison = self.saison.name.to_s
@name_diverse = the_saison + " - " +
date.to_s + " - " +
... | true |
217e6d75a9ef8be72e532cda8d65eafb9f1da4f2 | Ruby | dubistdu/Code_Wars | /weight_for_weight.rb | UTF-8 | 779 | 3.84375 | 4 | [] | no_license | # https://www.codewars.com/kata/weight-for-weight/train/ruby
# order of weight is organized by sum of all digits of each weight
# order of list is smallest sum first. If there are identical sums, the order is ordered by string.
# No negative numbers will be given but it is possible that the list is empty
#
# Take away... | true |
d94e4548f9e058425f9d6de56500bf8986c4eb0f | Ruby | zecvv/homework-week2 | /exercise1/email2.rb | UTF-8 | 400 | 3.53125 | 4 | [] | no_license | #Exercise1: Email Class
#By: José Carlos Gonçalves
#Email: a6595@alunos.ipca.pt
class Email
attr_accessor:subject,:from,:date
def initialize (subject,array={})
@subject=subject
@from=array[:from]
@date=array[:date]
end
email = Email.new("Keep on coding! :)", { :date => "2014-12-01", :from => "... | true |
af5b52c998fd383b8b2aef610d4cdbb6c171c8c9 | Ruby | ruby/typeprof | /smoke/hash-fetch.rb | UTF-8 | 441 | 3.3125 | 3 | [
"MIT"
] | permissive | h = { a: :A, b: :B }
def foo(h)
h.fetch(:a) #=> :A | :B
end
def bar(h)
h.fetch(:a, :C) #=> :A | :B | :C
end
def baz(h)
n = nil
[h.fetch(:a) do |k| #=> :A | :B | :C
n = k #=> :A | :B
:C
end, n]
end
foo(h)
bar(h)
baz(h)
__END__
# Classes
class Object
private
def foo: ({a: :A, b: :B} h) -> (:A... | true |
16e63067aab433a7eea20f5aeaea939491c8f365 | Ruby | salbonico/ruby-puppy-v-000 | /lib/dog.rb | UTF-8 | 207 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@@all << self
end
def self.clear_all
@@all.clear
end
def self.all
@@all.each do |object|
puts object.name
end
end
end
| true |
b8e391b173b7973fdd84142578517de1c216053c | Ruby | MHS-QA-Forked/cracking-the-coding-interview | /spec/1.4_spec.rb | UTF-8 | 432 | 2.796875 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../chapter1/1.4'
describe 'replace spaces' do
it 'replaces whitespaces with %20' do
str = 'hello world'
expect(replace_spaces(str)).to eq('hello%20world')
end
end
describe 'replace spaces without library' do
it 'replaces whitespaces with %20' do
str =... | true |
d3793fc615d53023f420053f593d7d921705f2aa | Ruby | arbylee/code_jam_bowling | /app/turn.rb | UTF-8 | 283 | 3.84375 | 4 | [] | no_license | class Turn
attr_reader :throw1,:throw2, :total
def initialize(throw1, throw2)
@throw1 = throw1
@throw2 = throw2
@total = @throw1 + @throw2
end
def strike?
return @throw1 == 10
end
def spare?
return @throw1 != 10 && @throw1 + @throw2 == 10
end
end | true |
04f45ee03efeb742c6b74c1d2f7a449344b2115a | Ruby | earnold/dynamic-attributes | /lib/dynamic_attributes.rb | UTF-8 | 5,450 | 2.546875 | 3 | [
"MIT"
] | permissive | module DynamicAttributes
class UndefinedTableColumn < StandardError; end
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def has_dynamic_attributes(*attrs)
include InstanceMethods
cattr_accessor :dynamic_attributes_options, :dynamic_attributes_fields
... | true |
ca3579313942a6fe71a5d334a9f5551fab5f8065 | Ruby | mattvella07/ruby-warrior-solutions | /beginner/level_7.rb | UTF-8 | 514 | 3.015625 | 3 | [] | no_license | class Player
def play_turn(warrior)
if warrior.feel.wall?
warrior.pivot!
elsif warrior.feel.empty?
if !@health.nil? and warrior.health < @health and warrior.health < 14
warrior.walk!(:backward)
elsif warrior.health < 20 and warrior.health >= @healt... | true |
145dadee2cdfd594c02cdf1c1d63e9eb697374de | Ruby | 1fatfox/Chess | /Piece.rb | UTF-8 | 313 | 2.75 | 3 | [] | no_license | class Piece
attr_accessor :pos,:board,:color
def initialize(color,board,pos)
@color = color
@board = board
@pos = pos
end
def to_s
symbol.to_s
end
def empty?
end
def valid_moves
end
def symbol
:x
end
private
def move_into_check?(end_pos)
end
end
| true |
6f6c570088d38e8bac25dc14f2fd488f7950359d | Ruby | learn-co-students/atlanta-web-033020 | /08-dynamic-orms/lib/basic_orm.rb | UTF-8 | 251 | 2.75 | 3 | [] | no_license | class BasicORM
def self.table_name
"#{self.name.downcase}s"
end
def self.all
query = <<-SQL
select * from #{self.table_name}
SQL
results = DB[:conn].execute(query)
results.map { |record| self.new(record) }
end
end
| true |
04362ad86fa43664231d64d26eea5bb767fc36d9 | Ruby | vedantshetty/Odin_Project_Code | /Ruby/integer_to_roman.rb | UTF-8 | 745 | 3.484375 | 3 | [] | no_license | $roman_mapping = {
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 => "I"
}
$roman_mapping_keys = $roman_mapping.keys.sort {|a,b| b <=> a}
def integer_to_roman(n)
return $roman_mapping[n] if $ro... | true |
9669bc390df1a4e3527765440c1c3b68af9c439b | Ruby | danott/dottfiles | /bin/til | UTF-8 | 487 | 2.734375 | 3 | [] | no_license | #!/usr/bin/env ruby
def ask(question)
print "#{question} [yn]: "
gets.match(/y/i)
end
today = Time.now.strftime("%Y-%m-%d")
filename = "#{today}.md"
Dir.chdir("/Users/danott/Code/www.danott.co/site/today-i-learned")
unless File.exists?(filename)
File.open(filename, "w") do |f|
f.puts "---"
f.puts "dat... | true |
edf57b0600501676619e49021c7831b1d8568f0b | Ruby | LoganBresnahan/phase-0 | /week-6/attr/my_solution.rb | UTF-8 | 1,425 | 4.1875 | 4 | [
"MIT"
] | permissive | #Attr Methods
# I worked on this challenge [by myself, with:]
# I spent [#] hours on this challenge.
class NameData
attr_accessor :name
end
class Greetings
def initialize
@namedata = NameData.new
end
def greeting
greets = @namedata.name=("Logan") #Must have = sign to work.
puts "Hello #{greets}. How are... | true |
5105f2ad77b8fdd028942e6da6ee7f69a2703153 | Ruby | maxpetruk/learnToProgram | /ch1/calc.rb | UTF-8 | 526 | 3.96875 | 4 | [] | no_license | # puts 1+2
=begin
puts 1.0 + 2.0
puts 2.0 * 3.0
puts 5.0 - 8.0
puts 9.0 / 2.0
=end
=begin
puts 1+2
puts 2*3
puts 5-8
puts 9/2
=end
=begin
puts 5 * (12-8) + -15
puts 98 + (59872 / (13*8)) * -52
=end
puts "how many hours are in a year?"
puts 365*24
puts "how many minutes are in a decade?"
puts 10*24*60
puts "how m... | true |
8cc338378497d31e7d05f22dbfaf003199be1b73 | Ruby | tbk303/disko | /lib/store.rb | UTF-8 | 1,268 | 2.828125 | 3 | [] | no_license | require 'json'
require 'singleton'
class Store
include Singleton
def initialize
super
end
def load_all!
@patterns = []
Dir.glob(File.join ENV['DISKO_DIR'], '*.json') do |file|
begin
pattern_json = JSON.parse(File.read file)
@patterns << Pattern.from_json(pattern_json)
... | true |
3a0fffbd38a74bf98ddcbd0ed6cd702eac2313c2 | Ruby | troynt/AdventOfCode2019 | /challenges/1/the_tyranny_of_the_rocket_equation_spec.rb | UTF-8 | 579 | 3.0625 | 3 | [] | no_license |
require_relative 'the_tyranny_of_the_rocket_equation'
describe 'TheTyrannyOfTheRocketEquation', :day1 do
def with_data(file_path)
cur_dir = File.dirname(__FILE__)
f = File.open(File.join(cur_dir, file_path))
nums = f.readlines.map(&:to_i)
TheTyrannyOfTheRocketEquation.new(nums)
end
it 'should ... | true |
a4a42a741ec862e8f7ff6a535ec996b07a9198f4 | Ruby | wincent/wikitext | /bin/wikitext | UTF-8 | 3,678 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env ruby
# Copyright 2008-present Greg Hurrell. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this lis... | true |
9c5498977085d5b567b2e52dc920f6eb4f7e32eb | Ruby | RyoYamamotoJP/japanese_calendar | /lib/japanese_calendar/deprecation/weekday_wrapper.rb | UTF-8 | 1,293 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'japanese_calendar/deprecation/reporting'
module JapaneseCalendar
module Deprecation #:nodoc: all
WEEKDAY_DIRECTIVES = {
'%Q' => '%JA',
'%q' => '%Ja'
}.freeze
WEEKDAY_PATTERN = Regexp.union(WEEKDAY_DIRECTIVES.keys)
private_constant :WEEKDAY_DIRECTI... | true |
5c317374cae6ab45f980246f2740b58a98cd935a | Ruby | subishaos/PriceCalculator | /lib/database_value.rb | UTF-8 | 508 | 2.71875 | 3 | [] | no_license | class DatabaseValue
class << self
def item_create
Item.create(name: "milk", unit_price: 3.97)
Item.create(name:"bread", unit_price: 2.17)
Item.create(name: "banana", unit_price: 0.99)
Item.create(name: "apple", unit_price: 0.89)
end
def sale_prices_create
SalePrice.create(sale_price_value: 5.00,... | true |
8511abbcbe44d5977bacd13c0226654e4a1a1884 | Ruby | hectron/robinfood | /app/lib/recommendations/presentation/inline_food_item.rb | UTF-8 | 609 | 2.546875 | 3 | [] | no_license | module Recommendations
module Presentation
class InlineFoodItem
# @!attribute [r] item
# @return [FoodItem]
attr_reader :item
def initialize(item)
@item = item
end
def link
"[#{item.name} from #{item.restaurant}](#{item.url})"
end
def dietary_re... | true |
63d6696be3043a7c883635f17fcab54fdd68fdd2 | Ruby | tywestlie/reunion | /lib/activity.rb | UTF-8 | 587 | 3.40625 | 3 | [] | no_license | class Activity
attr_reader :name, :participants
def initialize(name)
@name = name
@participants = {}
end
def add_participants(name, paid)
@participants[name] = paid
@participants
end
def cost
activity_cost = 0
@participants.each do |name, paid|
activity_cost += paid
end... | true |
a7a567e7bb07a89d524a151e2031daf875961ab8 | Ruby | patrickschneider23/eg-01-ruby-jwt | /send_envelope.rb | UTF-8 | 5,728 | 2.640625 | 3 | [
"MIT"
] | permissive | require './example_base'
require './ds_config'
require 'base64'
class SendEnvelope < ExampleBase
@@ENVELOPE_1_DOCUMENT_1 = %(
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body style="font-family:sans-serif;margin-left:2em;">
<h1 style="font-family: 'Trebuch... | true |
7dd2663b417d3bf310afbaa0373401f841c7032f | Ruby | jrkroymann10/hangman | /lib/HumanGuesser.rb | UTF-8 | 1,059 | 4.125 | 4 | [] | no_license | require 'pry'
class HumanGuesser
attr_reader :name
attr_accessor :letters
def initialize(name = 'human')
@name = name
@letters = []
end
def guess_word
puts ''
print "would you like to guess the word (w), guess a letter (l), or save the game (save), #{@name}? "
ans = gets.chomp.downcase
... | true |
fe4e4d7e00f534bdd1cab01cf5d099bc84afece6 | Ruby | learn-co-students/london-web-career-031119 | /09-putting-it-all-together/done/db/seeds.rb | UTF-8 | 743 | 2.671875 | 3 | [] | no_license | Fandom.destroy_all
Fan.destroy_all
Track.destroy_all
Artist.destroy_all
metallica = Artist.create(name: 'Metallica')
taylor_swift = Artist.create(name: 'Taylor Swift')
Track.create([
{title: 'Sad but true', artist: metallica},
{title: 'Enter sandman', artist: metallica},
{title: 'Master of puppets', artist: met... | true |
81a0c2e46b36b12551e7d3c51531b8840f1b5b0b | Ruby | PaulDip/ruby | /ex_11.rb | UTF-8 | 112 | 2.859375 | 3 | [] | no_license | puts "Quel chiffre aime tu ?"
user_number = gets.chomp.to_i
user_number.times do
puts "Salut, ça farte ?"
end
| true |
665ceed2641c2a2e6dc2dacdff0693f35becbc82 | Ruby | keius/prepwork-projects | /Battleship/lib/battleship.rb | UTF-8 | 966 | 3.703125 | 4 | [] | no_license | require_relative "board"
require_relative "player"
class BattleshipGame
attr_reader :player, :board
def initialize(player, board = Board.new)
@player = player
@board = board
end
def attack(pos)
if @board.empty?(pos)
@board[pos] = :x
else
@board[pos] = :o
end
end
def count... | true |
dcb2f6c26971deffce8b748ae326a8a9a1a18095 | Ruby | slonia/aoc2016 | /day13/part1.rb | UTF-8 | 3,186 | 3.6875 | 4 | [] | no_license | require 'set'
require 'pry'
class Maze
INF = 1_000_000
def initialize(size)
@size = size
@maze = Array.new(size) { Array.new(size, 0)}
@source_x, @source_y, @dest_x, @dest_y = 1, 1, 1, 1
end
# A* implementation
def goto(dest_x, dest_y)
@dest_x = dest_x
@dest_y = dest_y
dest_node = [@d... | true |
810ae7c4a0e6f22adf6c6828a61900fdd9a95f00 | Ruby | AgonIdrizi/MasterMind | /Board.rb | UTF-8 | 329 | 3.609375 | 4 | [] | no_license | class Board
include Enumerable
attr_accessor :board
def initialize
@board = [[" "," "," "," "]*12]
end
def each(&block)
self.each {|member| block.call(member)}
end
def print_board(player_arr,i)
board[i] = player_arr
puts"\n\n"
board.each_entry {|row| p row.join(" | ")}
puts"\n\n"
... | true |
aa62f456678fe0770c2d6faa8de3ca2932aef32b | Ruby | lastobelus/berkshelf | /lib/berkshelf/cookbook_source.rb | UTF-8 | 5,769 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | module Berkshelf
# @author Jamie Winsor <jamie@vialstudios.com>
class CookbookSource
class << self
@@valid_options = [:group, :locked_version]
@@location_keys = Hash.new
# Returns an array of valid options to pass to the initializer
#
# @return [Array<Symbol>]
def valid_opti... | true |
1bb87a88b847709b2ce8707cf9a4b02e7f536d14 | Ruby | Zietieflr/Experimentation | /integer_as_string_truths.rb | UTF-8 | 171 | 2.9375 | 3 | [] | no_license | str_int = "exit";
#puts str_int === str_int.to_i ? true : false;
#puts Integer(str_int) != true ? true : false;
n = str_int.to_i;
puts n.to_s == str_int ? true : false; | true |
bfa46a286b53672c89372d8262829629775aa88b | Ruby | restc/Project-Euler-solutions | /p14.rb | UTF-8 | 1,301 | 3.953125 | 4 | [] | no_license | # The following iterative sequence is defined for the set of positive integers:
#
# n → n/2 (n is even)
# n → 3n + 1 (n is odd)
#
# Using the rule above and starting with 13, we generate the following sequence:
#
# 13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
# It can be seen that this sequence (starting at 13 and finish... | true |
bc73db1ece8c1dea63360d74b2fc8df9d11bc032 | Ruby | okubo-0921/HealthCare_app | /app/models/chart.rb | UTF-8 | 613 | 2.921875 | 3 | [] | no_license | class Chart < ApplicationRecord
belongs_to :user, optional: true
def bmi
# 体重kg ÷ 身長m^2
weight.to_f / (length.to_f / 100) ** 2
end
def proper
# 身長m^2 × 22
(length.to_f / 100) **2 * 22
end
def basal_metabolism(age)
# ハリス・ベネディクト方程式(今回は男性を想定)
# 男性: 13.397×体重kg+4.799×身長cm−5.677×年齢+88.... | true |
0450903bbae4307ed5c4b12033d85fca9d89c273 | Ruby | gostevpavel/Less_1 | /idealgewicht.rb | UTF-8 | 304 | 3.453125 | 3 | [] | no_license | puts "Привет! Напиши свое имя."
name=gets.chomp
puts "Какой твой рост?"
height = gets.chomp
weight = height.to_i-110
puts "#{name}, твой идеальный вес #{height.to_i-110} кг" if weight>0
puts"Твой вес уже оптимальный" if weight.to_i<0 | true |
ff8ef01c36ed92193aa5874574d3e1417834e259 | Ruby | playax/moip-assinaturas | /lib/moip-assinaturas/webhooks.rb | UTF-8 | 1,286 | 2.5625 | 3 | [
"MIT"
] | permissive | module Moip::Assinaturas
class Webhooks
attr_accessor :model, :event, :date, :env, :resource, :events
class << self
def build(json)
object = new
object.model = get_model(json['event'])
object.event = get_event(json['event'])
object.events = {}
object.date... | true |
df15901073f9e8ec78476903f50495322b994a23 | Ruby | jskirst/Moonlite | /app/controllers/api/v1/users_controller.rb | UTF-8 | 897 | 2.515625 | 3 | [] | no_license | module Api
module V1
class UsersController < ApplicationController
skip_before_action :verify_authenticity_token, if: :json_request?
before_action :authenticate_api_user
# GET /api/v1/user.json
# Optional parameters: username or id or email
# Required parameters: token
def sho... | true |
8ad80abed5b7ea57fa973c9bd1709fcc9e7dab25 | Ruby | Wendalf/cartoon-collections-001-prework-web | /cartoon_collections.rb | UTF-8 | 662 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarves)# code an argument here
# Your code here
dwarves.each_with_index do |dwarf, i|
puts "#{i+1}. #{dwarf}\n"
end
end
def summon_captain_planet(planeteer_calls)# code an argument here
# Your code here
planeteer_calls.collect do |element|
element.capitalize << "!"
end
end
de... | true |
1eb07ebb3bbe5a5438d2a828e7eace8b27e4a454 | Ruby | RobertM905/Katas | /persistence/spec/persistence_spec.rb | UTF-8 | 1,240 | 3.25 | 3 | [] | no_license | require 'persistence'
describe Persistence do
it 'gives a response of 0 if the input is 0' do
persistence = Persistence.new
expect(persistence.test(0)).to eq(0)
end
it 'gives a response of 0 whenn the input is a single digit' do
persistence = Persistence.new
expect(persist... | true |
777f2a3c38ff596418b5f5ad317e489b116074a2 | Ruby | daemonza/BookHero | /app/controllers/config_controller.rb | UTF-8 | 1,370 | 2.515625 | 3 | [] | no_license | require 'yaml'
class ConfigController < ApplicationController
# Get the current settings values
def settings
# Get the currently set path
config_file = File.expand_path('../../config/bookhero.conf',File.dirname(__FILE__))
settings = YAML::load(File.open(config_file))
@configured_library_path = s... | true |
fef98427cd2da7298d68cd7b9dca39f41e4b5b4a | Ruby | psingh0912/the_odin_project | /ruby/stock_picker.rb | UTF-8 | 1,173 | 4.46875 | 4 | [] | no_license | =begin
Implement a method #stock_picker that takes in an array of stock prices, one for each hypothetical day. It should return a pair of days representing the best day to buy and the best day to sell. Days start at 0.
> stock_picker([17,3,6,9,15,8,6,1,10])
=> [1,4] # for a profit of $15 - $3 == $12
Quick... | true |
66ec53c8e0aadcf13c673a625ac14549717bbf7f | Ruby | cervantesjess1994/looping-while-until-online-web-prework | /lib/until.rb | UTF-8 | 88 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_until = 6
end
until using_until == 10
using_until += 1
puts "Wingardium Leviosa"
end
| true |
a54e96fc8de47f3a8bf60dbefdbfcb93ad49a198 | Ruby | freebz/Beginning-Ruby | /ch06/ex6-14.rb | UTF-8 | 86 | 2.609375 | 3 | [] | no_license | class Square
def self.test_method
puts "Hello from the Square class!"
end
end
| true |
de6aa19d0900c83166708dbe070faa9b17de59cb | Ruby | keithvenh/EOTE | /db/seeds.rb | UTF-8 | 8,602 | 2.578125 | 3 | [] | no_license | require 'csv'
Character.create(
name: "Aleni",
race: "Cerean",
career: "Explorer",
soak: 3,
wound_threshold: 12,
strain_threshold: 15,
defense_ranged: 0,
defense_melee: 0,
brawn: 2,
agility: 3,
intellect: 3,
cunning: 3,
willpower: 2,
presence: 2,
category: "P... | true |
2a6755d57f9cba13c28e2ce44ebbcd75917f9399 | Ruby | igorsobreira/playground | /problems/pugpe_challenge/1.rb | UTF-8 | 528 | 3.375 | 3 | [] | no_license | # implementacao em ruby do 1.py
require 'test/unit'
def pack (l)
groups = [[]]
l.each do |i|
index = groups.size - 1
if groups[index].include? i
groups[index].push(i)
else
groups.push [i]
end
end
groups.shift
groups
end
class ChallengeOne < Test::Unit::TestCase
def test_pack... | true |
bf4367d0e039a2320472d4978931fbcd0bcba2f6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/412.rb | UTF-8 | 368 | 3.4375 | 3 | [] | no_license | def sorted_string(s)
s.split(//).sort.join
end
def combine_anagrams(words)
groups = {}
words.each do |w|
groupkey = sorted_string(w.downcase)
groups[groupkey] = (groups[groupkey] || []) << w
end
groups.values
end
# inputwords = ['Cars', 'for', 'potatoes', 'racs', 'four','scar', 'creams'... | true |
d01828210de2701cc0ebc7ab21413bcfa6665b81 | Ruby | zhangruochi/Codewars | /Length_Count.rb | UTF-8 | 694 | 3.890625 | 4 | [] | no_license | #!/usr/bin/env ruby
#info
#-name : zhangruochi
#-email : zrc720@gmail.com
=begin
Linked Lists - Length & Count
Implement Length() to count the number of nodes in a linked list.
length(null) === 0
length(1 -> 2 -> 3 -> null) === 3
Implement Count() to count the occurrences of an integer in a linked list.
coun... | true |
7b98b7ebe127980cd0880188edb88115e29a1a86 | Ruby | ManuAc/fuber | /app/models/trip.rb | UTF-8 | 1,343 | 2.796875 | 3 | [] | no_license | class Trip < ActiveRecord::Base
enum status: [
:booked,
:started,
:ended,
:cancelled
]
belongs_to :user
belongs_to :cab
belongs_to :start_location, class_name: 'Location'
belongs_to :end_location, class_name: 'Location'
validates_presence_of :user, :cab
def start(location)
self.st... | true |
f9b64a8b6ac71741424e4cc0ca3df54459705e7d | Ruby | nbadw/water_chemistry | /app/models/gis/coordinate.rb | UTF-8 | 744 | 2.734375 | 3 | [] | no_license | # encoding: utf-8
require 'coordinate/degrees_minutes_seconds'
require 'coordinate/parsers/degrees_minutes_seconds'
require 'coordinate/degrees_minutes'
require 'coordinate/parsers/degrees_minutes'
require 'coordinate/decimal_degrees'
require 'coordinate/parsers/decimal_degrees'
module Coordinate
class << self
d... | true |
1048724f3167130003c6412a224793e366ffec07 | Ruby | mirjoy/meal_planning_app | /app/models/meal.rb | UTF-8 | 779 | 2.796875 | 3 | [] | no_license | class Meal < ActiveRecord::Base
belongs_to :user
has_many :ingredients
attr_reader :current_user
def self.service
@service ||= MealService.new(@current_user)
end
def self.structify_meals
service.meals["matches"].map do |match|
OpenStruct.new(match)
end
end
def self.meals_wanted(num)
structify_mea... | true |
90b1ac33cb83ebedc3e2b269c69de0400e58eb89 | Ruby | jukeboxhero/samples | /sph_db.rb | UTF-8 | 4,176 | 2.578125 | 3 | [] | no_license | module I18n
module Backend
class SphDb
(class << self; self; end).class_eval { public :include }
module Implementation
include Base
def initialized?
@initialized ||= false
end
# Stores translations for the given locale in memory.
def store_translatio... | true |
ec9d74d009912335a185601024b621d9f7a0052c | Ruby | nnittop909/student_login | /app/models/login.rb | UTF-8 | 890 | 2.578125 | 3 | [] | no_license | class Login < ApplicationRecord
belongs_to :student
before_destroy :create_time_consumption, :set_status
def log_out_time
Time.zone.now
end
def calculate_time_consumption
log_out_time.to_time - self.created_at.to_time
end
def create_time_consumption
InternetUsage.create!(:student_id => self.student.id,... | true |
cf58c9e0d1c793be9e99c94471b04546203b6538 | Ruby | JediChou/jedichou-study-devops | /Ruby/PPR1.9/BuildIn/tc_Errno.rb | UTF-8 | 1,435 | 2.90625 | 3 | [] | no_license | #####################################################################
# File name: tc_Errno.rb
# Create date: 2013-10-8 15:06 PM
# Update date:
# Description: Cross write unit test to study build-in classes
#####################################################################
# Author : Jedi Chou
# From : Programm... | true |
064d7203c24720ecd4c6b611670dddd99ea96ee2 | Ruby | dulshanb/Programming.- | /Lab 6/task_6-2_console.rb | UTF-8 | 244 | 3.03125 | 3 | [] | no_license | #
# лабораторная работа №6
# часть 2
#
$LOAD_PATH.unshift('.')
require 'task_6-2.rb'
puts "xi = 0.01:"
n, y = find_n(0.01)
puts "n = #{n}, y = #{y}"
puts "xi = 0.0001:"
n, y = find_n(0.0001)
puts "n = #{n}, y = #{y}"
| true |
44c31c3fc38da4531c4ed7b2edd960f806ba7470 | Ruby | Nikos4Life/InsecurePassword | /lib/InsecurePassword/PasswordChecker.rb | UTF-8 | 739 | 3 | 3 | [] | no_license | require 'pry'
class PasswordChecker
def initialize()
end
def check_password(email, password)
if check_password_charset? == true && email_included? == false
true
else
false
end
end
def check_password_charset?(password)
if (password =~ /^(?=.*[a-zA-Z])(?=.*[0-9])(?=.D).{8,}/)
tru... | true |
8be879048873d4f14f2064fad1c30a0e877aecf2 | Ruby | combatcellist/furima-32476 | /spec/models/item_spec.rb | UTF-8 | 2,765 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
describe Item do
before do
@item = FactoryBot.build(:item)
end
context '出品ができる時' do
it "全ての情報が入力されていれば出品できる" do
@item = FactoryBot.create(:item)
expect(@item).to be_valid
end
end
context '出品できない時' do
it "商品名がないと出品できない" do
@item.name = nil
@ite... | true |
c6f86d30245836b92e8e016f4c1d93e91b433f5d | Ruby | NicoRodz/LearningRuby | /lenguaje/arreglos.rb | UTF-8 | 113 | 2.875 | 3 | [] | no_license | arreglo = [3, 'perro', true]
arreglo_dos = Array.new(5)
arreglo << 'hola' #push
puts arreglo
puts arreglo_dos
| true |
5bee0ada412ed8eed552faa4e68a506fb622fcc0 | Ruby | teamcapybara/capybara | /lib/capybara/node/simple.rb | UTF-8 | 5,650 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Capybara
module Node
##
#
# A {Capybara::Node::Simple} is a simpler version of {Capybara::Node::Base} which
# includes only {Capybara::Node::Finders} and {Capybara::Node::Matchers} and does
# not include {Capybara::Node::Actions}. This type of node is returned... | true |
7e934bcc155f63199dfd361019c78c41b2f894bc | Ruby | rlishtaba/rb_scope | /lib/rb_scope/session/method_dispatch.rb | UTF-8 | 4,259 | 2.625 | 3 | [] | no_license | module RbScope
class Session
class << self; attr_reader :defaults end
# This table says which methods from the niScope dll
# are hooked to instances of the Session class.
# Arguments are passed to each methods with an Hash
niscope_methods = [
[:calib... | true |
7a300f90fe773fd3d90e54a27aadea4d555dc374 | Ruby | JordanStafford/PDP | /1-2-1 code examples needed/binary_search_string.rb | UTF-8 | 1,060 | 3.640625 | 4 | [] | no_license | books = ["book 1", "book 2", "book 3", "book 4", "book 5", "book 6", "book 7", "book 8",
"book 9", "book 10", "book 11", "book 12", "book 13", "book 14", "book 15", "book 16", "book 17", "book 18", "book 19",
"book 20", "book 21", "book 23", "book 24", "book 25", "book 26", "book 27", "book 28", "book 29", "book 30... | true |
725e4eed248163f75413f26e53fa71160170203e | Ruby | mathias/hackety-hack.com | /controllers/programs_controller.rb | UTF-8 | 3,675 | 3.109375 | 3 | [] | no_license | # We'd like to let people show their programs. The routes in this file let us
# do this.
# We're also going to let people write programs in the browser, just in case
# they'd like to share something, but the upload doesn't work, or they want to
# copy on part of their program, or anything else.
get "/programs/new" do
... | true |
4b8a4532bf65e9d7ef807aeef2d61c627cbd4bc6 | Ruby | uragap/head_first | /zd1/prohod_po_ssilkam.rb | UTF-8 | 1,934 | 2.6875 | 3 | [] | no_license | require_relative 'job_with_rap.rb'
agent = Mechanize.new
@count_pages = 1
page = agent.get("https://genius.com/artists/songs?for_artist_page=117146&id=King-of-the-dot&page=#{@count_pages}&pagination=true")
array_of_links_of_songs = []
page.css('div#container.mecha--deprecated div#main ul li a.song_name.work_in_progress... | true |
f7f333d7aa126b71a078a4f35d6d28e17edc22ba | Ruby | AndyGreenberg/Intro-to-Programming-Ruby | /variables/name.rb | UTF-8 | 224 | 3.796875 | 4 | [] | no_license | # Variables -> Exercise 1, 3-4
puts "Type your first name: "
name = gets.chomp
puts "Hello, #{name}"
10.times do
puts name
end
puts "What is your last name: "
last = gets.chomp
puts "Your full name is #{name} #{last}" | true |
9d11dbb93ef3d9d12534b46b261c051dad1159a4 | Ruby | nvhoang1503/rails5-react-api | /lib/exceptions/common_exceptions.rb | UTF-8 | 2,245 | 2.59375 | 3 | [] | no_license | module Exceptions
module CommonExceptions
class CommonException < StandardError
end
class PersistException < CommonException
attr_reader :message
attr_reader :status
def initialize(hash)
@message = hash[:message]
@status = hash[:status] || 400
end
def mes... | true |
6d1761f9a6dc202796d06fa63b94bd2a92daa44e | Ruby | niekvenlo/JW-encoder | /two_spec.rb | UTF-8 | 1,372 | 3.203125 | 3 | [] | no_license | # NEED TO ADD BETTER TESTS. Need to compare actual known input/output pairs!
describe JW do
describe "#encode" do
context "correct input" do
it "returns an array of numbers" do
expect(JW.encode("")).to be_an_instance_of(Array)
expect(JW.encode("d")).to be_an_instance_of(Array)
end
... | true |
e926ab934128dc825cd46d02be87b9b45fdf35b0 | Ruby | MVictoriaV/aydoo-2018-ruby | /maquina_expendedora/model/maquina_expendedora_de_bebidas.rb | UTF-8 | 702 | 2.625 | 3 | [] | no_license | require_relative './vaso'
require_relative './hacedor_de_cafe'
require_relative './hacedor_de_te_con_leche'
require_relative './azucarero'
class MaquinaExpendedoraDeBebidas
def initialize
@hacedor_de_cafe = HacedorDeCafe.new
@hacedor_de_te_con_leche = HacedorDeTeConLeche.new
@azucarero = Azucarero.new
... | true |
2f7cabfc144c2e69a726d9aa33b412dab4bff03e | Ruby | toi0621/ruby | /lesson7-1.rb | UTF-8 | 189 | 3.265625 | 3 | [] | no_license | puts "計算を始めます"
puts "2つの値を入力してください"
a =gets.to_i
b =gets.to_i
puts "計算結果を出力します"
puts "a*b=#{a*b}"
puts "計算を終了します" | true |
5aa564a8680ba60edb29c0b2dcca8eba2c47bd5c | Ruby | arnaudbenard/Flightboard_app | /app/models/keyword.rb | UTF-8 | 436 | 2.609375 | 3 | [] | no_license | class Keyword
include Mongoid::Document
field :name, :type => String
field :weight, :type => Integer
field :type, :type => String
field :domain, :type => String
def self.grab_keywords(number)
@fake_resume = "Fake resume "
@random = Keyword.all.shuffle.slice(0, number)
number.times do |i|
put... | true |
60bb6cf91031ada2417e655a51eb64a2469129ea | Ruby | NirvairGill/Ruby-book-codes | /Hashes/Exercise_3.rb | UTF-8 | 215 | 3.90625 | 4 | [] | no_license | #suppose our hash is:
hash = {:a=>1, :b=>2, :c=>2, :d=>4, :e=>5, :f=>6}
#To print keys
puts hash.keys
#To print values
puts hash.values
#To print both keys and values
puts hash.each {|k,v| puts "#{k}: #{v}"} | true |
100ce509c33f799cd8e2c6179e46385c93d7b911 | Ruby | sotom591-flatiron/intro-to-simple-array-manipulations-dc-web-100818 | /lib/intro_to_simple_array_manipulations.rb | UTF-8 | 834 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_push(array, string)
updated_array = string
array.push(updated_array)
end
def using_unshift(array, string)
array.unshift(string)
end
def using_pop(array)
array.pop
end
def pop_with_args(array)
array.pop(2)
end
def using_shift(array)
array.shift
end
def shift_with_args(array)
array.shift(2)
end
def using_... | true |
89c86d4cfb8ef5c8f11c88f69667e4bd5518a618 | Ruby | naseemmoussa/ListChallenges | /ls.rb | UTF-8 | 3,681 | 3.265625 | 3 | [] | no_license | def median(list)
sorted = list.sort
if sorted.size % 2 == 1
return sorted[sorted.size / 2]
else
return sorted[sorted.size / 2] + sorted[sorted.size / 2 - 1] / 2.0
end
end
def middleway(list1,list2)
d = 0
b = 0
if list1.size % 2 == 1
d = list1[list1.size / 2]
els... | true |
6a6ebe8c3f7a2a71f78e36e32c9aefbf4670be06 | Ruby | dhable/seven-lang | /week1-ruby/day2/clean_tree_init.rb | UTF-8 | 1,486 | 4.21875 | 4 | [] | no_license | =begin
Week 1 - Ruby
Day 2
Problem: The Tree class was interesting, bit it did not allow you to specify
a new tree with a clean user interface. Let the initializer accept a nested
structure of hashes. You should be able to specify a tree like this:
{'grandpa' => {
'dad' => {'child 1' => {}, 'child ... | true |
e45ee0a5268917b29ac38ad0e783d998d233a755 | Ruby | AristoRap/music_scraper | /track.rb | UTF-8 | 317 | 2.71875 | 3 | [] | no_license | # Model
class Track
attr_reader :title, :artist, :url
def initialize(title, artist, url, remixer, label, genre, release_date, price)
@title = title
@artist = artist
@url = url
@remixer = remixer
@label = label
@genre = genre
@release_date = release_date
@price = price
end
end
| true |
4ddfa7dc04c0ff23675d8d039b47256c32186fd0 | Ruby | thinkybeast/ruby-exercises | /advanced_topics/easy_testing/7.rb | UTF-8 | 388 | 2.9375 | 3 | [] | no_license | # Write a minitest assertion that will fail if value is not an instance of the Numeric class exactly. value may not be an instance of one of Numeric's superclasses.
require 'minitest/autorun'
require 'minitest/reporters'
Minitest::Reporters.use!
class Exercise7 < Minitest::Test
def test_instance_of_numeric
val... | true |
2dc7af0a5d601d9d1d1f5244dc1b9a86aaff999b | Ruby | JohnNewman1/oystercards | /lib/journey_log.rb | UTF-8 | 528 | 3.046875 | 3 | [] | no_license | require_relative 'journey.rb'
class JourneyLog
attr_reader :journey
attr_accessor :current
def initialize(journey = Journey)
@journey = journey
@journeys = []
end
def start(station)
@journeys << @current if @current != nil
@current = @journey.new
@current.start(station)
end
def fi... | true |
b5e061d4c26cc5901a704620b5eddd4df29a7e3d | Ruby | patchkit-net/patchkit-patcher-unity | /Assets/PatchKit Patcher/Scripts/Api/Generator/model_generator.rb | UTF-8 | 944 | 2.6875 | 3 | [
"MIT"
] | permissive | require_relative "base_generator.rb"
class ModelGenerator < BaseGenerator
def initialize(api_name, name, data)
super()
@api_name = api_name
@name = name
@data = data
end
def write_json_property(property_name)
write "[JsonProperty(\"#{property_name}\")]"
end
def write_property(property_n... | true |
a35c2c774fbbecb39b55ad2dae2fc7ffd774ae80 | Ruby | Jenysk/practicas | /exercisefor.rb | UTF-8 | 167 | 3.15625 | 3 | [] | no_license |
datos= ["name\n"=>gets.chomp, "age\n" => gets.chomp, "haircolor\n" => gets.chomp, "height\n" => gets.chomp ]
datos.each_with_index do |datos|
puts datos
end
| true |
b76ed8275f73102cf5bffbeae5ca8141770b8ba1 | Ruby | bradyaturner/adventofcode | /2017/day04/solution.rb | UTF-8 | 542 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env ruby
class DayFourSolver
def initialize(path)
@file = File.read(path)
end
def solve
num_valid = 0
@file.each_line do |line|
words = line.split.map { |word| get_word(word) }
num_valid += 1 if words == words.uniq
end
puts "Solution: #{num_valid}"
end
end
class D4P... | true |
326c0ee719e0ab5d7c8834914a1017d3f513a12f | Ruby | kpennachio/OO-Art-Gallery-nyc-web-career-010719 | /app/models/artist.rb | UTF-8 | 929 | 3.390625 | 3 | [] | no_license | class Artist
attr_reader :name, :years_experience
@@all = []
def self.all
@@all
end
def self.total_experience
@@all.inject(0){|sum,a| sum + a.years_experience}
end
def self.most_prolific
#number of paintings/years of total_experience
#return artist instance with the highest
array ... | true |
4dd90fabd09e04516d1315e643a90030aebf7014 | Ruby | aravi3/Projects | /W2D3/Poker/lib/deck.rb | UTF-8 | 483 | 3.0625 | 3 | [] | no_license | require_relative 'card'
class Deck
CARD_TYPES = [
:two,
:three,
:four,
:five,
:six,
:seven,
:eight,
:nine,
:ten,
:jack,
:queen,
:king,
:ace
]
CARD_SUITS = [
:spade,
:club,
:heart,
:diamond
]
attr_accessor :card_deck
def initialize
@card_deck = []
create_deck
end
def create_... | true |
33875855b19030fef6ecba786e533b4132ae3886 | Ruby | j2blake/vivo-snapshot | /cmd_prepare_self_editor_account/cmd_prepare_self_editor_account.rb | UTF-8 | 10,594 | 2.5625 | 3 | [] | no_license | =begin
--------------------------------------------------------------------------------
Write triples to the user accounts model of the VIVO to create the
self-editor-account (unless it exists already), and to make it a proxy editor for
all of the URLs in the list.
----------------------------------------------------... | true |
47f63ef821a3a34db3a30562c0a76aad3c9fa53a | Ruby | kunishi/algebra-ruby2 | /test/test-m-polynomial-factor-zp.rb | UTF-8 | 1,360 | 2.625 | 3 | [
"MIT"
] | permissive | #########################################################
# #
# This is test script for 'm-polynomial-factor-zp.rb' #
# #
#########################################################
require 'test/unit'
require 'a... | true |
399b46448162f39212570471f6224b9e8d3ec890 | Ruby | dmoore5050/cheer_exercise | /yeah.rb | UTF-8 | 437 | 4.21875 | 4 | [] | no_license | puts "Hi! What's your name?"
name = gets.chomp
name.downcase.each_char do |letter|
letter_check = ["a","e","f","h","i","l","m","n","o","r","s","x"]
if letter_check.include?( letter )
article = "an"
else
article = "a"
end
puts "\# Give me #{article} #{letter.upcase}!"
end
garbled_name = name.split("").shuff... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.