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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
424a3ca71e792ecd2e332cc0f9dc72bd6e9a9304 | Ruby | CFaught/launch_school_ruby_exercises | /methods/greeting.rb | UTF-8 | 221 | 3.765625 | 4 | [] | no_license | #
# Intro to Programming: Methods
#
# Author: Caleb Faught
#
# Date: 1/3/2016
#
# This program is an example of a method with a string parameter
def greeting(name)
"hello " + name +". How are you?"
end
puts greeting("bob")
| true |
4f98d275ef3de713d0f44a46012a1ee7c55c78a5 | Ruby | zacstewart/retrospection_app | /app/decorators/sleep_decorator.rb | UTF-8 | 212 | 2.53125 | 3 | [] | no_license | class SleepDecorator < Draper::Base
decorates :sleep
def time_asleep
Time.diff(sleep.slept_at, sleep.woke_at, '%H and %N')[:diff]
end
def seconds_asleep
sleep.woke_at - sleep.slept_at
end
end
| true |
c77a2f7b8b3efdd371faf91e8d4f516ab301e3b6 | Ruby | sferik/gitter | /app/models/tweets.rb | UTF-8 | 1,459 | 2.71875 | 3 | [] | no_license | require 'core_ext/enumerable'
class Tweets
class << self
def weeks(time)
date = time.to_date
weeks = []
begin
weeks << (date.beginning_of_week..date.end_of_week)
date += 7
end while date < Date.today
weeks
end
def collect_with_max_id(collection=[], max_id=... | true |
2c5b941542931340743480ac6f5673ae33735790 | Ruby | elliotcohen/hm-news | /app/models/content.rb | UTF-8 | 511 | 2.609375 | 3 | [] | no_license | class Content
include Mongoid::Document
include Mongoid::Timestamps
#associations
belongs_to :user
has_many :upvotes
#fields
field :text, :type => String
field :score, :type => Integer, :default => 0
validates :user_id, :presence => true
def upvote(user)
v = Upvote.new(:user => user,... | true |
30743a1cf352ac8d2555cb9a2bf1eb0e04c63235 | Ruby | ViaLeeny/reverse-each-word-london-web-career-042219 | /reverse_each_word.rb | UTF-8 | 377 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word (sentence)
new_array = sentence.split(" ")
next_array = []
new_array.each do |string|
next_array << string.reverse
end
return next_array.join(" ")
end
def reverse_each_word (sentence)
first_array = sentence.split(" ")
second_array = []
first_array.collect do |string|
second_array ... | true |
6161bb00070870fd5f39fbb3502aaa846a485095 | Ruby | jnmerchant/text_miner | /lib/validator.rb | UTF-8 | 892 | 2.875 | 3 | [] | no_license | class Validator
def is_binary?(text)
!!/^[01]+$/.match(text)
end
def is_binary_even?(text)
!/[1]$/.match text
end
def is_hex?(text)
!!/^[0-9a-f]+$/i.match(text)
end
def is_word?(text)
!!/^\d*[a-z\-][a-z\-\d]*$/i.match(text)
end
def are_words?(text, options={})
word_count = text... | true |
9053e57e49718597ffa57b38058e6c87111a4773 | Ruby | Rowland2080/tictactoe | /tictactoe.rb | UTF-8 | 4,006 | 4.25 | 4 | [] | no_license | class Game
attr_accessor :name
def initialize
@board = Array.new(9," ").map.with_index {|cell,index| cell = index + 1}
@player1 = Player.new(name)
@player2 = Player.new(name)
end
WIN_COMBINATIONS = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8,],[0,4,8],[2,4,6]]
def turn_count
@board.coun... | true |
592f38f54a63fdcecc49a20b4635b9691eaf2fc5 | Ruby | mikestepanov/CodeFights | /Bots/Spacebot (SpaceX)/Ruby/cpu_emulator.rb | UTF-8 | 1,556 | 2.8125 | 3 | [] | no_license | def cpuEmulator(subroutine)
registers = label_registers
idx = 0
while idx < subroutine.size
answer = move(registers, subroutine[idx])
if answer.size == 2
registers = answer.last
idx = answer.first
next
end
idx += 1
end
registers["R42"].to_s
end
def label_registers
register... | true |
2bfa22f3b65ab919112939a9295356358dcab33e | Ruby | MJCune1/test_esoft | /1127573207_MANUEL_JOHANY_COLORADO_2018-12-23.rb | UTF-8 | 1,694 | 3.796875 | 4 | [] | no_license |
def matrix_pro n,m
# validating n & m being greater than 2
return if n <= 2 || m <= 2
# defining array with random unique values
limit = n * m
array = []
array[0] = 1
y = 1
greater_than_average = 0
while y < limit do
found = 1
x = 0
nuevo = rand(limit)+1
while x < y && found ==... | true |
f100965312693704160ef97275e86d9788decf07 | Ruby | bgroveben/OdinProject | /ruby/RubyMonk/ruby_primer/calculator.rb | UTF-8 | 361 | 3.875 | 4 | [] | no_license | =begin
Problem Statement
Create a class Calculator, which performs addition and subtraction of two numbers at a time.
The sample code explains the expected API.
=end
class Calculator
def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
end
=begin
adding 2 and 3 gives 5 ✔
adding 4 and -4 gives 0 ✔
... | true |
424d888aaef5ca023c6613fbe01984377dfb0719 | Ruby | johanek/puppet-parse | /lib/vendor/puppet/relationship.rb | UTF-8 | 2,066 | 2.890625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# subscriptions are permanent associations determining how different
# objects react to an event
require 'puppet/util/pson'
# This is Puppet's class for modeling edges in its configuration graph.
# It used to be a subclass of GRATR::Edge, but that class has weird hash
# overrides that dramaticall... | true |
bfeaba8abb5c141e71db227b9039b109e04ee01d | Ruby | gcolajan/ideologia | /serveur/bibliotheques/jeu/CaseDepart.rb | UTF-8 | 639 | 3 | 3 | [] | no_license | require 'Case'
class CaseDepart < Case
def initialize(popMonde)
super(0)
@popMondiale = popMonde
$ARGENT_CASE_DEPART = 1600
end
# Permet de calculer le gain lors du passage par la case départ
# Retourne le gain afin de l'afficher chez le client
def actionCaseDepart(joueur)
popJoueur = joueur.calculerPop... | true |
efa29c6a1a3d18d4be9f8bdac333b15133260c43 | Ruby | yanap/learning | /ruby/meta/sorcery/mimic_method.rb | UTF-8 | 336 | 3.625 | 4 | [] | no_license | #encoding: utf-8
# 他の言語要素に偽装したメソッド
def BaseClass(name)
name == "string" ? String : Object
end
class C < BaseClass "string" # クラスに見えるメソッド
attr_accessor :an_attribute # キーワードに見えるメソッド
end
obj = C.new
obj.an_attribute = 1 # 属性に見えるメソッド | true |
dd9bebea947905dd5e8478172c7d4c1feedfb3ad | Ruby | steeplefingers/coding-challenges | /clearent coding challenge/features/step_definitions/steps.rb | UTF-8 | 2,679 | 3.390625 | 3 | [] | no_license | # people is an array of persons.
# person is an array of wallets.
# wallet is an array of cards.
# card is a hash of names/balances.
$people = []
Given(/^(a|the|another) person has (?:a|another) wallet$/) do |article|
# this step implies a new person with a wallet
if article == "a" or article == "another"
add_ne... | true |
7ef933b958ae68a17aca347b2719057498b4bd2e | Ruby | DonHanna790/ror-class | /week10/Driver_Log.rb | UTF-8 | 902 | 3.515625 | 4 | [] | no_license | trips_log = []
class Customer
end
class Trip_log
n = 0
def add
loop do
puts "Please enter name of the driver"
driver = gets.chomp
puts "Enter the start time of the trip"
start_time = gets.chomp
puts "Enter the end time of the trip"
end_time = gets.chomp
puts "Enter t... | true |
1de5e9c684fde4707096a75be47033bfdba09ef3 | Ruby | lindenbacker/FIT5H_EuP | /Ruby/Aufgaben/car3.rb | UTF-8 | 3,649 | 4.25 | 4 | [] | no_license | #1. Erstellen Sie eine Klasse Car mit den Eigenschaften:
#ps, typ, verbrauch
#Stellen Sie sicherm dass die Eigeschaft typ beim ersten Buchstaben einen Großbuchstaben erstellt.
#Stellen SIe sicherm dass bei der Eingabe überprüft wird, ob es sich um einen string handelt, der mindestes 3 Ziffern lang ist. einer Zahl ke... | true |
7327fe1257e5d78c39ad4c111fd358f2e3afa2b1 | Ruby | jjmora/THP-Tic-Tac-Toe | /lib/show.rb | UTF-8 | 1,874 | 3.734375 | 4 | [] | no_license | # Show : cette classe sera une sorte de view. Elle affichera l'état du plateau de jeu à un instant T.
require 'pry'
require_relative 'board'
require_relative 'game'
require_relative 'application'
class Show
attr_accessor :hash
def show_board(hash)
puts ""
puts " | _A_ | _B_ | _C_ |"
puts " | |... | true |
2a72d2396dec52bdbd41df05440c33cbfa0fdc58 | Ruby | harshmalik9423/ruby_password_generator | /pass_gen.rb | UTF-8 | 445 | 3.625 | 4 | [] | no_license | #!/usr/bin/ruby
#String containing all possible characters
gen_array = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a + ('!'..'?').to_a
puts "Please specify the length of password you need (min 8): "
len = gets.chomp.to_i
if len>= 8
#Generating random combination out of array of specified length
(0..len-1).ea... | true |
aaf10295fd82b3524b7d6ef58141c5fc886701e5 | Ruby | Ostavaleo/notepad | /memo.rb | UTF-8 | 1,001 | 3.328125 | 3 | [] | no_license | # Класс «Заметка», разновидность базового класса «Запись»
class Memo < Post
# Отдельный конструктор здесь не нужен, т. к. у заметки нет дополнительных
# переменных экземпляра.
# Этот метод пока пустой, он будет спрашивать ввод содержимого Заметки
def read_from_console
puts "Новая заметка (все, что пишите д... | true |
e653f1634a34b36555275440bc9b4110f00f2412 | Ruby | mirakui/follotter-crawler | /lib/queue_client.rb | UTF-8 | 758 | 2.78125 | 3 | [] | no_license | require 'rubygems'
require 'open-uri'
require 'pp'
require 'pit'
require 'follotter_logger'
require 'yaml'
module Follotter
class QueueClient
include FollotterLogger
def initialize
@seek = 0
@queue = nil
end
def load_queue
url = 'http://localhost:4000/queue/next'
str = open(... | true |
fdb7074f08fd3e6a91083cb72bb2a9b521b5a8c3 | Ruby | ruby-marc/ruby-marc | /lib/marc/marc8/map_to_unicode.rb | UTF-8 | 979,855 | 2.625 | 3 | [
"MIT"
] | permissive | module MARC
module Marc8
# Data to map from marc8 bytes to unicode codepoints.
#
# Ported from pymarc python to ruby using some regexps and such. Original pymarc:
#
# https://github.com/edsu/pymarc/blob/master/pymarc/marc8_mapping.py
module MapToUnicode
CHARSET_34 = { # Extended Arabic
... | true |
b0c7734cf3dadd0119b898f0919c1acfa5dae2b6 | Ruby | joshkestenberg/object_oriented_programming1 | /exercise1.rb | UTF-8 | 324 | 3.40625 | 3 | [] | no_license | class BankAccount
def initialize(acct_name)
@acct_name = acct_name
@balance = 0
@interest_rate = 0.05
end
attr_reader :balance
def deposit(sum)
@balance += sum
end
def withdraw(sum)
@balance -= sum
end
def gain_interest
@balance = @balance + @balance * @interest_rate
end
... | true |
f13bdd02f1bcbfbc0fc0aa3dbf15bcfd59e876f4 | Ruby | briri/cedilla | /test/unit/test_resource.rb | UTF-8 | 2,975 | 2.84375 | 3 | [] | no_license | require_relative '../test_helper'
class TestResource < Test::Unit::TestCase
def setup
end
# --------------------------------------------------------------------------------------------------------
def test_initialization
end
# -------------------------------------------------------------------------... | true |
fa3fd2e2a1995446c3e2bdffa36b8529a9573e54 | Ruby | marcelof98/Course-rails | /modulo_02/03_cond.rb | UTF-8 | 465 | 4.0625 | 4 | [] | no_license | puts "CASE"
print "Digite uma idade: "
idade = gets.chomp.to_i
# Caso
case idade
when 0..2
puts "bebê"
when 3..12
puts "criança"
when 13..18
puts "adolescente"
else
puts "adulto"
end
puts "IF"
print "Digite X: "
x = gets.chomp.to_i
# Se
if x > 3
puts "X é MAIOR!"
else
puts "X é menor!"
end
put... | true |
fff6a51164ace390a18915e9d94c088d15672616 | Ruby | Shopify/opensrs | /lib/opensrs/xml_processor.rb | UTF-8 | 3,750 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module OpenSRS
module XmlProcessor
class << self
def build(data)
builder = ::Nokogiri::XML::Builder.new
envelope = ::Nokogiri::XML::Node.new("OPS_envelope", builder.doc)
header = ::Nokogiri::XML::Node.new("header", builder.doc)
version = ::Nokogiri::XML::Node.new("v... | true |
6457cbc0100ad41915ff471700b16bcbe8f550a9 | Ruby | TiSer/manager | /app/models/milestone.rb | UTF-8 | 4,043 | 2.78125 | 3 | [] | no_license | class Milestone < ActiveRecord::Base
belongs_to :project
has_many :deals
# has_many :bookings, :throught => ???
validates_presence_of :name, :invoice_name
def by_time_amount
start_data = self.start_date
end_data = self.end_date
@bookings = self.project.bookings.where(:date => start_data..end_... | true |
cfaf032ee4123a415d4cf3a1a9848133043cda7f | Ruby | pogist/gosu-spritesheet | /lib/gosu/spritesheet.rb | UTF-8 | 1,307 | 2.921875 | 3 | [
"MIT"
] | permissive | require "gosu/spritesheet/version"
require "gosu/spritesheet/animation_block"
module Gosu
class MissingAnimationKeys < StandardError; end
class UnknownAnimationKeys < StandardError; end
class Spritesheet
def initialize(tiles: [], animations: nil, duration: 0.2)
@tiles = tiles
@default_duration =... | true |
cb91c80a798f788395617a6e93442a692e4dfec5 | Ruby | manveru/dota2-chat-emoticons | /generate.rb | UTF-8 | 2,282 | 2.609375 | 3 | [] | no_license | require 'vdf4r'
require 'erubis'
images = nil
File.open('src/scripts/emoticons.txt') do |file|
parser = VDF4R::Parser.new(file)
images = parser.parse["emoticons"]
end
emotes = []
images.each do |obj|
image = obj[1]
cmd_split = "convert +repage assets/images/emoticons/#{image["image_name"]} -crop 32x32 tmp/t... | true |
07d5901ed83955e0db22e67761b66c9149a2321f | Ruby | sriranjani48/Hackerrank | /Left Rotating Array/array_left_rotation.rb | UTF-8 | 482 | 3.890625 | 4 | [] | no_license | class LeftRotatedArray
def left_rotation(arr, d)
temp = 0
rotated_arr = []
for i in 0...arr.length
if i <= d
temp = arr[i]
arr[i] = arr[arr.length-1]
arr[arr.length-1] = temp
rotated_arr << arr[i]
end
end
rotated_arr
end
end
array = LeftRotatedArray.new
print array.left_rotation([1,2,... | true |
78389d689c2f56508fc10d38b88cd25e39c3fa16 | Ruby | Nerderrhein/nerdbot | /plugins/yourls.rb | UTF-8 | 795 | 2.515625 | 3 | [
"MIT"
] | permissive | class Cinch::Yourls
#automaticly shorten URLS with the nerderrhein yourls
include Cinch::Plugin
listen_to :channel
set :help, <<-EOF
http[s]://...
Automaticly shortens all links with a custom yourls installation that are posted in the channel.
EOF
def shorten(url)
url = open("#{config[:yourlsserver... | true |
f44efe04f135f3bad8e9146d845ed211dab6ae17 | Ruby | lambda2/paper_piece | /lib/paper_piece/locales.rb | UTF-8 | 598 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | module PaperPiece
module Locales
def self.included(base)
base.extend ClassMethods
base.define_language "fr"
base.load_translations
end
module ClassMethods
attr_reader :language
attr_reader :translations
def define_language(lang)
raise "Unable to find specifie... | true |
abfbd02184da1c77f8dc597506dc254765d7ecdb | Ruby | jonnymoore12/tic_tac_toe | /lib/board.rb | UTF-8 | 673 | 3.5625 | 4 | [] | no_license | class Board
attr_reader :positions
def initialize
@positions = { 1 => ' ', 2 => ' ', 3 => ' ', 4 => ' ', 5 => ' ',
6 => ' ', 7 => ' ', 8 => ' ', 9 => ' '}
end
def board_instructions
" 1 | 2 | 3 \n" +
"- - - - -\n" +
" 4 | 5 | 6 \n" +
"- - - - -\n" +
" 7 | 8 | 9 "
e... | true |
b0084d69c7a1b87ff4dad2b226a3380d8d95719a | Ruby | eliskim27/mod5-api | /db/seeds.rb | UTF-8 | 2,705 | 2.6875 | 3 | [] | no_license | all_littles = [
{
username: "test little 1",
password: "test",
fieldsofinterest: ["law", "medicine"],
applicationquestion1: "alex",
applicationquestion2: "little1",
applicationquestion3: "thing3",
applicationquestion4: "thing4",
applicationquestion5: "... | true |
f36667844a0d05e432c21968a95ac72ebe011e04 | Ruby | stevenjackson/AlecAlphabet | /data/scripts/scraper.rb | UTF-8 | 1,190 | 2.96875 | 3 | [] | no_license | require 'watir-webdriver'
require_relative 'dictionary_writer'
class Scraper
def scrape
@writer = DictionaryWriter.new 'scraped.json'
@browser = Watir::Browser.new
('v'..'z').each { |letter| do_letter letter }
@browser.close
@writer.close
end
def do_letter letter
@browser.goto "http:... | true |
7f492b4667e5a25053d08db067d08c7186cffffa | Ruby | Jonesyd/programming_ruby | /04_conditionals/02_ex.rb | UTF-8 | 224 | 3.671875 | 4 | [] | no_license | def all_caps_if(string)
if string.length > 10
string.upcase
else
string
end
end
puts all_caps_if("Hello, world")
puts all_caps_if("hello")
puts all_caps_if("hello everyone in the world, it's a beautiful day")
| true |
6eea1deb78772338c5a73e1fe206b591fdaf4e8d | Ruby | oslet/rubylang | /4.3.rb | UTF-8 | 237 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
newbook="红楼梦";
books1=%W{西游记 水浒传 三国演义 #{newbook}};
puts "books1所有元素:#{books1}";
books2=%w{西游记 水浒传 三国演义 #{newbook1}};
puts "books2所有元素为:#{books2}";
| true |
5d35b0394c90d9997b5254ba7ed341e4737829dc | Ruby | alexkrewson/ruby_testing | /lib/enumerable_test.rb | UTF-8 | 3,491 | 3.84375 | 4 | [] | no_license | # class EnumerableTest
module Enumerable
def do_me
"done"
end
def my_each
i = 0
while i < self.size
yield(self[i])
i+=1
end
puts ""
self
end
def my_each_... | true |
72e7e75d78e452aeb5601ca8f710d78eb1fb84bd | Ruby | ymason/ironhack | /Week_04/String_Calculator/lib/string_calculator.rb | UTF-8 | 392 | 3.4375 | 3 | [
"MIT"
] | permissive | class StringCalculator
def add(numbers)
numbers.split(',').reduce(0) { |sum, n| sum + n.to_i}
end
end
# if numbers.empty?
# puts "0"
# else
# numbers_array = numbers.split(',')
# numbers_array.reduce(0) do | sum, n |
# sum += n.to_i
# numbers = numbers.split(',')
# sum = 0
# numbers.... | true |
964d02414f060c18251aba69d1ca63f954481154 | Ruby | tofupup/rax-ruby-cloud | /challenge4.rb | UTF-8 | 3,661 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
=begin
Copyright 2013 John Schutz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable... | true |
88cc9d048acf720007a74bb4b78625638bad2585 | Ruby | SamBall2393/JMS-302 | /homework/week_9/runs_scored.rb | UTF-8 | 730 | 3.640625 | 4 | [] | no_license | #Samantha Ballard and Amanda Barrentine
def get_runs player
puts "How many runs did the #{player} have? When done, type 'done'."
runs_total = 0
while true
runs = gets.chomp
if runs.downcase == 'done'
break
end
runs_total += runs.to_i
end
put... | true |
ac2a7745e8b4666a914a43c5261ec9f36d96f8db | Ruby | dkosowski87/paypal-demo | /app/clients/paypal.rb | UTF-8 | 760 | 2.515625 | 3 | [] | no_license | class Paypal
RETURN_URL = "http://#{AppConfig.app_host}/payments/done".freeze
CANCEL_URL = "http://#{AppConfig.app_host}/payments/cancel".freeze
class RequestFailed < StandardError; end
def create_payment(data)
request_body = build_request_body(data)
payment = PayPal::SDK::REST::Payment.new(request_bo... | true |
157bf8c4be46311fa1add75b3ef3da81001ccc46 | Ruby | oterogalvis/justMyNotes | /ruby/example_11.rb | UTF-8 | 206 | 3.046875 | 3 | [] | no_license | File.open("example_11.txt", "a+") do |file|
print "Enter your name: "
name = gets.chomp
file.print "Name: #{name}\n"
print "Enter your email: "
email = gets.chomp
file.print "Email: #{email}\n"
end | true |
bfaaa0ad5a3ef52164ce34d2faded4158b6803a0 | Ruby | talha-ahsan/fal_info_bot | /falinfobot.rb | UTF-8 | 3,175 | 2.984375 | 3 | [] | no_license | # This simple bot responds to every "bonobo competitors?" message with a list of competitors trying to reach the top of bonobo mountain
require 'discordrb'
bot = Discordrb::Commands::CommandBot.new token: ENV['discord_api_key'], client_id: ENV['discord_client_id'], prefix: '&'
puts "This bot's invite URL is #{bot.invi... | true |
2e6b5d896c71e56a0e2eeba8b43df047c44d7755 | Ruby | geminoa/mywordnet | /test/test_wn_dmnc.rb | UTF-8 | 397 | 2.546875 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require "minitest/autorun"
require "mywn"
# Dmnc = Domain - Category
class TestWnDmnc < MiniTest::Test
def setup
@comet = "comet"
end
def test_wn_dmnc_class
assert_kind_of Array, @comet.wn_dmnc
end
def test_word_match
comet_dmnc = [
"astronomy"
]
comet_dmnc.each ... | true |
15f00433d0eb95b70f61c466d02ada7ed00a15fb | Ruby | janebranden/launch-school-intro-to-programming | /01_basics/basics6.rb | UTF-8 | 185 | 3.796875 | 4 | [] | no_license | # basics6.rb
# Write a program that calculates the squares of 3 float numbers of your choosing and outputs the result to the screen.
puts 2.5 * 2.5
puts 3.91 * 3.91
puts 1.257 * 1.257 | true |
0eb078df05e19d0eb7ea64254ee4b07ecf789281 | Ruby | AfonsoTsukamoto/football_api | /lib/football_api/match_stats.rb | UTF-8 | 1,151 | 2.796875 | 3 | [
"MIT"
] | permissive | module FootballApi
class MatchStats
attr_accessor :id, :local_team_stats, :visitor_team_stats
def initialize(hash = {})
@id = hash[:id]
@local_team_stats = Stats.new(hash[:localteam])
@visitor_team_stats = Stats.new(hash[:visitorteam])
end
end
class Stats
attr_acce... | true |
a5aff01d0da7e1d1c7b0c723c9569132442b4b45 | Ruby | roschaefer/rasp | /spec/asp/production_spec.rb | UTF-8 | 1,632 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Asp::Production do
context "without block" do
subject { Asp::Production.new("anything") }
its(:asp_representation) { is_expected.to eq "anything." }
end
context "block containing a string" do
subject { Asp::Production.new("something") { "for_a_reason" } }
its(:asp_... | true |
4997638d08b87cacb5c1b743979b788d78cafe76 | Ruby | ayerest/OO-Get-Swole-seattle-web-071519 | /lib/gym.rb | UTF-8 | 1,048 | 3.359375 | 3 | [] | no_license | class Gym
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def memberships
#get a list of all memberships at a gym
#iterate through list of all memberships, select those with
#gym instance equal to specific gym
Membersh... | true |
35d9ccc6a5cb167791c6bc3a1a84f9db3a93dc16 | Ruby | stage5clinger/ls-intro-to-programming-exercises | /flow_control/uppercase.rb | UTF-8 | 203 | 4.34375 | 4 | [] | no_license | # uppercase.rb
def uppercase(phrase)
case
when phrase.length > 10
puts phrase.upcase
else
puts phrase
end
end
puts "Enter a phrase"
phrase = gets.chomp
uppercase(phrase) | true |
31052abd1e6e8c6e28f7fdf9ec72de6e4cb18307 | Ruby | encratite/linguistics | /application/XSAMPA.rb | UTF-8 | 604 | 2.75 | 3 | [] | no_license | require 'nil/file'
module XSAMPA
def self.loadData
lines = Nil.readLines('data/X-SAMPA')
output = []
lines.each do |line|
tokens = line.split(' ')
if tokens.size != 2
raise "Invalid X-SAMPA entry: #{line.inspect}"
end
xsampa, ipa = tokens
output << [xsampa, ipa]
... | true |
ed455ee271d11d2579b1c3fa9f71fc4a66a06951 | Ruby | jpmec/ember_data_example | /app/controllers/todos_controller.rb | UTF-8 | 1,548 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class TodosController < ApplicationController
# GET /todos.json
def index
render json: Todo.all
end
# GET /todos/1.json
def show
todo = Todo.find(params[:id])
render json: todo
end
# POST /todos.json
def create
todo = Todo.new
if update_todo(todo)
render json: todo, status: :... | true |
4c988a96cd5e491790ec135e577383ff93779f68 | Ruby | inkrement/calabash | /features/android/pages/welcome_page.rb | UTF-8 | 662 | 2.53125 | 3 | [] | no_license | require 'calabash-android/abase'
class WelcomePage < Calabash::ABase
def trait
"* text:'Telegram'"
end
def await(opts={})
wait_for_elements_exist([trait])
self
end
def skip_message()
touch(skip_button)
wait_for_skip_done
end
def wait_for_skip_done
result = :invalid
regis... | true |
5c3269577a6d28eb82f42031fb0f90a864120e38 | Ruby | sajoy/expense_oganizer | /lib/category.rb | UTF-8 | 2,517 | 2.859375 | 3 | [] | no_license | class Category
attr_reader(:name, :id, :budget)
define_method(:initialize) do |attributes|
@name = attributes[:name]
@id = attributes[:id]
@budget = attributes[:budget]
end
define_method(:save) do
result = DB.exec("INSERT INTO categories (name) VALUES ('#{@name}') RETURNING id;")
@id = res... | true |
12b471f0c62669784cc1b2ca6ca16cb0eeeb8d66 | Ruby | trusona/pizza_server | /app/domain/validators/create_pizza_topping.rb | UTF-8 | 423 | 2.53125 | 3 | [] | no_license | module Validators
class CreatePizzaTopping
attr_accessor :errors
def initialize
@errors = { pizza_topping: [] }
end
def run(topping_ids:, topping_id:)
unless Rules::ElementIsUniqueInCollection.run(topping_ids, topping_id.to_i)
@errors[:pizza_topping] = ["This pizza topping alread... | true |
5c421af6650cf1563c079b7948b5736af010b6c3 | Ruby | markus851/eddy | /lib/definitions/segments/generated/qty.rb | UTF-8 | 1,761 | 2.953125 | 3 | [
"MIT"
] | permissive | module Eddy
module Segments
# ### Segment Summary:
#
# - Id: QTY
# - Name: Quantity Information
# - Purpose: To specify quantity information
class QTY < Eddy::Models::Segment
# @param store [Eddy::Data::Store]
# @return [void]
def initialize(store)
@id = "QTY"
... | true |
caa65a00974d67b48af5c3dea0228dba4335f98e | Ruby | hrysd/nippo | /lib/nippo/generator.rb | UTF-8 | 1,347 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'fileutils'
require 'yaml'
require_relative 'configuration'
require_relative 'time_helper'
module Nippo
class Generator
class << self
def setup(title, current_dir)
unless File.exist?(Configuration.file)
config_hash = {
title: title,
root_dir: current_dir
... | true |
4d185a77ec58b349e62763ecbe75bd549c1d5bd2 | Ruby | jtprince/dotfiles | /bin/markdown-replace-relative_url-links.rb | UTF-8 | 715 | 2.890625 | 3 | [
"Unlicense"
] | permissive | #!/usr/bin/env ruby
files = ARGV
ABSOLUTE_BASE = "https://faenrandir.github.io/a_careful_examination"
NEW_EXT = ".permanentlinks.md"
if files.size == 0
puts "usage: #{File.basename(__FILE__)} <file>.md"
puts "output: <file>#{NEW_EXT}"
puts
puts "replaces all '{{ \"/<link>/\" | relative_url }}' with:"
puts ... | true |
f2a4567b77fdf00e30af17c33f1bb0d330b58a2b | Ruby | dev-cyprium/event-organiser | /app/helpers/sessions_helper.rb | UTF-8 | 394 | 2.546875 | 3 | [] | no_license | module SessionsHelper
def login(user)
session[:user_id] = user.id
end
def logout
session[:user_id] = nil
end
def current_user
return nil if session[:user_id].nil?
user_id = session[:user_id]
User.find(user_id)
end
def logged_in?
session[:user_id]
end
def active_user_or(string)
user = current_... | true |
be0b307765a60b130a5ed043b5a5fc71c647e25e | Ruby | data-design/ruby-to-web | /scripts/012-sqlite-select.rb | UTF-8 | 1,680 | 3.0625 | 3 | [] | no_license | #### Data retrieval with SQLite
require_relative './helper'
require 'csv'
require 'sqlite3'
# Assuming the previous script was run and the database
# with this particular filename has been created and populated:
db_filename = TWEET_CONGRESS_DB_NAME
db = SQLite3::Database.new(db_filename.to_s)
# By default, the sqlite3... | true |
01c34237c8a538bbf1119ef1b2a6c4e10fbc8caa | Ruby | erector/erector | /spec/erector/widgets/field_table_spec.rb | UTF-8 | 5,282 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
module Erector
module Widgets
describe FieldTable do
describe "a basic, brittle characterization test, just to get up and running" do
class PasswordForm < Erector::Widget
def content
form :action => "/u... | true |
60925aec8e05cde10b37954397ff1cce6df8bc0a | Ruby | chelsubhadeep/BasicRubyProgram | /prog_14.rb | UTF-8 | 480 | 4.125 | 4 | [] | no_license | #Krishnamurti Number
def krishnamurti_num(num)
q=num
sum=0
while(q!=0)
r=q%10
sum+=factorial(r)
q=q/10
end
return sum
end
def factorial(r)
fac=1
for i in 1..r
fac=fac*i
end
return fac
end
def initialization()
print "Enter the number:"
num=gets.to_i
if (krishnamurti_num(num)==n... | true |
6c9261100dd58b133722a244fd087cc33096f6c9 | Ruby | David24m/weekend-one-homework | /pet_shop.rb | UTF-8 | 2,024 | 3.296875 | 3 | [] | no_license | def pet_shop_name(shop)
name = shop[:name]
return name
end
def total_cash(cash)
name = cash[:admin][:total_cash]
return name
end
def add_or_remove_cash(cash, money_in)
money = cash[:admin][:total_cash] += money_in
return money
end
def pets_sold(number)
name = number[:admin][:pets_sold]
return name
en... | true |
2deceaddeb9d2c9a0cd511a26f2cd2b9f7410912 | Ruby | mindreframer/api-stuff | /github.com/coopernurse/barrister-ruby/conform/server.rb | UTF-8 | 1,388 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/env ruby
require File.expand_path('../../lib/barrister.rb', __FILE__)
require 'sinatra'
class A
def add(a, b)
return a+b
end
def calc(nums, op)
total = 0
if op == "multiply"
total = 1
end
nums.each do |n|
if op == "add"
total += n
elsif op == "mu... | true |
803505aae549f2fb6b7fdd87877b670f042cde62 | Ruby | sycko/warehouse_app | /test/models/warehouse_test.rb | UTF-8 | 1,198 | 2.75 | 3 | [] | no_license | require 'test_helper'
class WarehouseTest < ActiveSupport::TestCase
def setup
@warehouse = Warehouse.new(name: "Example", street: "Street",
city: "City", state: "State", zip: "12345", phone: "123456789")
end
test "should be valid" do
assert @warehouse.valid?
end
test "name should be pres... | true |
211e6149da106558b0b0dc8d93bc54f7f5210625 | Ruby | atpons/knock2 | /app.rb | UTF-8 | 1,356 | 2.8125 | 3 | [] | no_license | require "dotenv"
require "oauth2"
require "google_drive"
require "pp"
Dotenv.load
def workseet
client = OAuth2::Client.new(
ENV["client_id"],
ENV["client_secret"],
site: "https://accounts.google.com",
token_url: "/o/oauth2/token",
... | true |
fff9f2f407288b8a7d9addf38bf6a17fe1a73893 | Ruby | jbampton/scrapers | /ruby/nokogiri/khan.rb | UTF-8 | 394 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
def get_energy_points(user)
uri = URI.parse("https://www.khanacademy.org/profile/#{user}/")
doc = Nokogiri::HTML(uri.open)
res = doc.xpath('//script[contains(.,"prefersReducedMotion")]')
.to_s.scan(/points":(\d+),"prefersReducedMotion/)
res.... | true |
5f1ed4acaa92d6cf901139d72a6e04d93bae9710 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/7528.rb | UTF-8 | 214 | 3.015625 | 3 | [] | no_license | def combine_anagrams(words)
h = Hash.new
result = []
words.each {|word| h[word.downcase.chars.sort()] = [word] + h.fetch(word.downcase.chars.sort(),[]) }
result = h.map { |k,arr| arr }
return result
end
| true |
1eb02a10a9c60cfd690a833d9608ab10b3f0a91f | Ruby | yinazee/cinephile | /app/models/genre.rb | UTF-8 | 376 | 2.625 | 3 | [
"MIT"
] | permissive | class Genre < ActiveRecord::Base
has_many :movie_genres
has_many :movies, :through => :movie_genres
#this also ties in with the directors assocaited with the movie.
validates_presence_of :name
validates :name, uniqueness: true
def slug
name.downcase.gsub(" ","-")
end
def self.find_by_slug(slug)
... | true |
962fc18306cebb151676ef2bd6eeb8713dfc304f | Ruby | shell0323/ruby-chapter9 | /fizzbuzz.rb | UTF-8 | 297 | 3.859375 | 4 | [] | no_license | def fizz_buzz(num)
if num % 15 == 0
return "FizzBuzz"
elsif num % 5 == 0
return "Buzz"
elsif num % 3 == 0
return "Fizz"
else
return num.to_s
end
end
puts "1以上の数字を入力してください"
input = gets.to_i
puts "結果は…\n#{fizz_buzz(input)}"
#puts fizz_buzz(input)
| true |
d5fa2c9695632a33a3a2673a7317e30da3a0fcd5 | Ruby | arufino/interactive-weather-app | /weather_forecast.rb | UTF-8 | 553 | 3.5 | 4 | [] | no_license | require "yahoo_weatherman"
def your_location(location)
puts "Please insert your zip code:"
@location = gets.chomp
end
def weather_forecast(location)
client = Weatherman::Client.new
weather = client.lookup_by_location(location)
forecast = weather.forecasts
forecast.each do |x|
puts "The weather ... | true |
d8a98384cb1b0aa1cdcba2d5c8e573fad33f2425 | Ruby | changfenxia/ruby-basics | /lesson_1/exercise_2.rb | UTF-8 | 427 | 3.34375 | 3 | [] | no_license | # Площадь треугольника
puts 'Введите длину основания треугольника: '
base = gets.to_f
puts 'Введите высоту треугольника'
height = gets.to_f
puts "Площадь треугольника с основанием #{base} единиц и высотой #{height} единиц равняется #{base * height / 2} квадратных единиц."
| true |
c397404428f0b3d0d4527fbd34ebc3c20a531a86 | Ruby | iliabylich/pattern_matching | /examples/fact.rb | UTF-8 | 324 | 3.46875 | 3 | [] | no_license | module Fact
extend self
def fact(n) where n == 0
1
end
def fact(n) where n > 120
raise ArgumentError, "Invoked #fact with #{n} > 120."
end
def fact(n)
n * fact(n - 1)
end
end
puts Fact.fact(5)
begin
puts Fact.fact(1_000)
rescue ArgumentError => e
puts "Caught #{e}"
puts e.backtrace
... | true |
f5ec192e22558f9165041ec46a3fbee39f15bccd | Ruby | diogobroco/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 643 | 2.90625 | 3 | [] | no_license | puts 'Cleaning database...'
Restaurant.destroy_all
puts 'Creating restaurants...'
restaurants_attributes = [
{ name: 'Dragon Fly', address: 'Chinatown', category: 'chinese', phone_number: '34950093402394' },
{ name: 'Pizza East', address: 'Shoreditch', category: 'italian', phone_number: '312121341' },
{ name: 'T... | true |
db3b601881e67c6a389088f4dc2b22d1ae8cf502 | Ruby | limpid037/coderbyte | /WordCount.rb | UTF-8 | 109 | 2.765625 | 3 | [] | no_license | def WordCount(str)
words = str.split
return words.length
end
WordCount(STDIN.gets)
| true |
1a6e735e36b203b552de10d03db8e660d78ddc2c | Ruby | cielavenir/procon | /aizu/tyama_aizuITP1~5D.rb | UTF-8 | 83 | 2.5625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
puts ' '+(1..gets.to_i).select{|i|i%3==0||i.to_s.include?('3')}*' ' | true |
bb6992809691660ac705dec90cebc40438d0e894 | Ruby | HottScall/oystercard-challenge | /spec/oystercard_spec.rb | UTF-8 | 1,978 | 2.9375 | 3 | [] | no_license | require 'oystercard'
describe Oystercard do
let(:station){double :Entry}
it "is expected to have a balance of zero" do
expect(subject.balance).to eq(0)
end
describe '#top_up' do
it "can top up balance" do
expect{ subject.top_up 1 }.to change{ subject.balance }.by (1)
end
end
it 'raises ... | true |
93996097c3b68cc73d441ac5ca3c610808ae31de | Ruby | edgardoburgos94/finca_raiz_scraper | /scraper.rb | UTF-8 | 4,282 | 2.71875 | 3 | [] | no_license | require 'nokogiri'
require 'httparty'
require 'byebug'
require 'action_view'
require 'launchy'
class FincaRaizScraper
attr_accessor :base_url, :path, :accepted_price_per_square_meter, :max_price
def initialize(options = default_search_params)
@base_url = options.fetch(:base_url)
@path = options.fetch(:path)
... | true |
3c5c05f81787128ebe9ebf0c804ed8a052c92c08 | Ruby | Carlumbo/best_movies-0.1.1.gem | /best_movies/lib/best_movies/movie.rb | UTF-8 | 387 | 2.734375 | 3 | [
"MIT"
] | permissive | class BestMovies::Movie
attr_accessor :title , :ranks , :descriptions, :leading_actors , :year
@@all = []
def initialize(title, ranks, descriptions, leading_actors, year)
@title= title
@ranks = ranks
@leading_actors = leading_actors
@descriptions = descriptions
@year = year
... | true |
477568d9b45e29f5bec636efaab252aebf38dee3 | Ruby | huned/rupee | /lib/rupee/mixins/find_instance.rb | UTF-8 | 773 | 3.3125 | 3 | [
"MIT"
] | permissive | module Rupee
# For finding instances within a class
module FindInstance
# Converts the supplied value to an instance of the specified class (if it
# isn't already one). For example, within the Source object you could find
# the Bloomberg object one of two ways:
#
# Rupee::Source.find :bloomber... | true |
795599c82d1cf2dadc41599b2f7cada272674053 | Ruby | barangerbenjamin/food-delivery-day-2 | /app/views/sessions_view.rb | UTF-8 | 233 | 2.875 | 3 | [] | no_license | class SessionsView
def ask_for(something)
puts "#{something}?"
return gets.chomp
end
def logged_in
puts "You've signed in!"
end
def wrong_credentials
puts "Wrong username or password, try again!"
end
end | true |
d2d550004d46cec5ce87e14345c9b501b323ef7c | Ruby | mugyu/chinchin | /test/test_playing_game.rb | UTF-8 | 1,728 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
test_dir = File.dirname(__FILE__)
lib = File.expand_path("../lib", test_dir)
app = File.expand_path("../app", test_dir)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
$LOAD_PATH.unshift(app) unless $LOAD_PATH.include?(app)
require "test/unit"
require "chinchin/playe... | true |
36e71daaf68421117e719620dee3adcae44ef5fc | Ruby | anthonyalvarez/Ruby-Programming-Examples | /objects.rb | UTF-8 | 967 | 4.1875 | 4 | [] | no_license | class Animal
def initialize
puts "Creating a New Animal"
# for default values
end
def set_name(new_name)
@name = new_name
end
def get_name
@name
end
def name
@name
end
def name=(new_name)
if new_name.is_a?(Numeric)
puts... | true |
ac31d22fdb21622f0cea283417388e8db002369a | Ruby | zaxway/CS-1632-Quality-Assurance-Spring-2018-Project-2 | /City.rb | UTF-8 | 2,290 | 3.375 | 3 | [] | no_license | class City
attr_accessor :direction, :newLocationArr, :currentLocation
def initialize
@locations = ["Hillman", "Museum", "Cathedral", "Hospital"];
# display locations for interesections and streets they are on.
@hillman = ["Fifth Avenue", "Foo St."];
@hospital = ["Fourth Avenue", "Foo St."];
@ca... | true |
5435d2b7f99b07257cdac5a337c2be8bbf7725d8 | Ruby | zack-fisch/LRTHW | /ex31.rb | UTF-8 | 754 | 4.1875 | 4 | [] | no_license | def prompt
print ">"
end
puts "You enter a dark room with two doors. Do you go through door #1 or door #2?"
prompt; door = gets.chomp
if door == "1"
puts "There is a giant bear here eating a cheese cake. What do you do?"
puts "1. Take the cake."
puts "2. Scream at the bear."
prompt; bear = gets.chomp
if bear... | true |
412f3d2e96b043822f814a74175325cdeb49b456 | Ruby | leekearney/simple_cms | /lib/position_mover.rb | UTF-8 | 1,164 | 3.25 | 3 | [] | no_license | module PositionMover
def move_to_position(new_position)
max_position = self.class.where(position_scope).count
unless max_position.nil?
new_position = [[1, new_position.to_i].max, max_position].min
end
if position == new_position # do nothing
return true
elsif position.nil? #not in list yet
incre... | true |
49d9c34032e52d18b8d5c3e1a675838345e5be3b | Ruby | EdwardKinley/bears_rivers_fish | /rivers.rb | UTF-8 | 213 | 3.171875 | 3 | [] | no_license | class River
attr_reader(:name, :fish_in_river)
def initialize(name, fish_in_river = [])
@name = name
@fish_in_river = fish_in_river
end
def fish_count
return @fish_in_river.count
end
end
| true |
4e7c63fad0d847c011392a86fbeed2e4eea79b12 | Ruby | jillian/rack_server | /framework.ru | UTF-8 | 917 | 2.546875 | 3 | [] | no_license | require_relative 'action'
require 'warden'
class Framework
require 'rack'
def self.app
failure_app = Proc.new { |env| ['401', {'Content-Type' => 'text/html'}, ["UNAUTHORIZED"]] }
@app ||= begin
Rack::Builder.new do
use Rack::Session::Cookie, secret: "MY_SECRET"
# use Warden::Manager do |manager|
... | true |
994700dfaf368e2839e2fb222c596a3abcbaa997 | Ruby | tilezen/transport-spider | /spider.rb | UTF-8 | 5,233 | 2.609375 | 3 | [
"MIT"
] | permissive | require './osm.rb'
require 'set'
require 'json'
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"
opts.on("-v", "--verbose", "Run verbosely") do
options[:verbose] = true
end
opts.on("-uSTRING", "--user-agent=STRING",
"Set the user agent to ST... | true |
e99b41469182959fe65c810d77d9faf6e2cf02a6 | Ruby | softscienceprojects/oo-relationships-practice-london-web-080519 | /app/models/lyft/ride.rb | UTF-8 | 485 | 3.390625 | 3 | [] | no_license | class Ride
attr_reader :distance, :passenger, :driver
@@all = []
def initialize(distance, passenger, driver)
@distance = distance
@passenger = passenger
@driver = driver
@@all << self
end
def self.all
@@all
end
def self.average_distance #DONE
... | true |
9145b2b6ad905ad179ca40cced645fbe1a2666b2 | Ruby | gmcinnes/pragmatic_context | /lib/pragmatic_context/contextualizable.rb | UTF-8 | 1,291 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'pragmatic_context/default_contextualizer'
module PragmaticContext
module Contextualizable
def Contextualizable.included(base)
base.class_eval do
end
base.extend ClassMethods
end
module ClassMethods
attr_accessor :contextualizer
def contextualize_with(klass)
... | true |
6effde7b3f307047cae47a934104351c8ba21055 | Ruby | kldgarrido/TaskListProject | /test_dao.rb | UTF-8 | 2,255 | 2.640625 | 3 | [] | no_license | require_relative 'dao'
require_relative "model"
require "test/unit"
class Test_dao < Test::Unit::TestCase
def test_obj_parse
exp_result = Task.new(3914, "buy amazon kindle", false, "2017-04-14T21:37:49.548Z", "2017-04-14T21:37:49.548Z" )
data = Hash.new
data["id"]=3914
data["title"]="buy amazon kindle"
... | true |
c0a0ca9d4b26a495993fe2b7df1fa8ffc653d6a5 | Ruby | pirj/ruby-bandwidth | /lib/bandwidth/types/dtmf.rb | UTF-8 | 1,071 | 2.609375 | 3 | [
"MIT"
] | permissive | module Bandwidth
module Types
class DTMF
include Instance
# @return [String] A string of the digits pressed during the gather period, not including the terminating digit, in the order they were received. May be an empty string if no digits were received before the timeout
attribute :digits
... | true |
707808355b57c29929a9b3f1287fe7021129742f | Ruby | itggot-adam-rohdell/dungeon-crawler | /lib/item.rb | UTF-8 | 275 | 2.875 | 3 | [] | no_license | class Item
attr_reader :value
attr_reader :x
attr_reader :y
def initialize(x,y,value)
@value = value
if @value == 'p'
@item = Gosu::Image.new('media/potion.png')
end
@x = x
@y = y
end
def draw
@item.draw(@x,@y,0)
end
end | true |
5c33dc7d38cbbf9cc313d56953c20805dd94c732 | Ruby | cronokun/mazes | /bin/demo | UTF-8 | 1,210 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
$: << File.join(File.dirname(__FILE__), "/../lib")
require "optparse"
require "maze"
include Maze
options = {
columns: 4,
rows: 4,
algorithm: Builders.constants
}
OptionParser.new do |opts|
opts.on("-aFORMAR", "--algorithm ALGORITHM", "Choose an algorithm to generate a maze (default -- user ... | true |
020ebdad3cdb179a9fe71377e99fb62f52e2b6fd | Ruby | sunny-b/WGU_C950 | /ruby/graph.rb | UTF-8 | 1,235 | 2.953125 | 3 | [] | no_license | class Graph
def initialize
@vertices = HashTable.new(20)
@locations_hash = HashTable.new(20)
end
def add_vertex(location)
vertices.insert(location.id, Vertex.new(location))
locations_hash.insert(location.address.hash.abs, location)
end
def add_weighted_edge(origin, destination, weight)
v... | true |
ec5bfa1aa3ecf6185a4f53dd0315dfb555d29e36 | Ruby | BaobabHealthTrust/ebrs_services | /app/models/person.rb | UTF-8 | 2,776 | 2.515625 | 3 | [] | no_license | class Person < ActiveRecord::Base
self.table_name = :person
self.primary_key = :person_id
belongs_to :core_person, foreign_key: "person_id"
has_many :person_names
has_many :person_addresses
include EbrsAttribute
def addresses
PersonAddress.where(person_id: self.id)
end
def mother
result = n... | true |
5678dcf880001f0ccf9577300a40bd53c077aa4c | Ruby | bofuam/ruby19 | /path.rb | UTF-8 | 678 | 3.46875 | 3 | [] | no_license | #file: path.rb
class Path
attr_reader :points
attr_reader :max_length
MAX_LENGTH = 10
def initialize(max = MAX_LENGTH, points)
@points = points[]
@max_length = max
end
def add_point(point)
if @points.size > @max_length
puts "full array"
else
@points.push(point)
end
end
de... | true |
e98359f7cb85952b5db02d675696ce1272d0e4d2 | Ruby | yinghau76/RubyTest | /test_rescue.rb | UTF-8 | 141 | 3.046875 | 3 | [] | no_license | values = ["1", "2.3", /pattern/]
result = values.map begin |v|
Integer(v) rescue Float(v) rescue String(v)
end
puts result.inspect
| true |
0ec021f06cbef1b653fe0f71455ba05297decfc5 | Ruby | Ballycyrk/sea-c17-ruby | /class3/1_99_bottles_of_beer_on_the_wall.rb | UTF-8 | 1,523 | 4.25 | 4 | [] | no_license | # Section 7.5 on page 49
# 4 points
#
# Write a program that prints out the lyrics to that beloved classic,
# "99 Bottles of Beer on the Wall." Here's what the output should look like:
#
# 99 bottles of beer on the wall, 99 bottles of beer!
# Take one down, pass it around, 98 bottles of beer on the wall!
# 98 bottles o... | true |
d260e85373f594926aff0b227fdc79016856f515 | Ruby | webesteban/test | /app/services/artist/get_albums.rb | UTF-8 | 531 | 2.640625 | 3 | [] | no_license | class Artist::GetAlbums
def self.call(artist_id)
artist = Artist.find(artist_id)
if !artist
response = {:success => false, msg: "Artist not found"}
status = 404
return{response: response, status:status}
end
data = artist.albums.map{ |album|
{
id: album.id,
name: album.name,
image: a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.