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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
aa45ba9ada4a2c97418e2175436ffa6bdfb67bca | Ruby | funcoding/guessword | /app/controllers/home_controller.rb | UTF-8 | 1,142 | 2.96875 | 3 | [] | no_license | class HomeController < ApplicationController
def index
end
#Get word/game
def game
if params[:guess] == nil
choose_word
else
letter= params[:guess]
choice(letter)
end
end
protected
def choose_word
choose = (2 .. 10).to_a.sample #A number is selected in ... | true |
515559e5f72f6d5e8bae75689e0470a54fa9c06b | Ruby | f-w-robots/MZG | /hwserver2/models/unix_connection.rb | UTF-8 | 625 | 2.96875 | 3 | [] | no_license | class UNIXConnection
def initialize path_in, path_out, on_message
@path_out = path_out
File.unlink(path_in) if File.exists?(path_in)
@server = UNIXServer.new(path_in)
Thread.new do
loop do
line = on_request
on_message.call(line)
end
end
end
def send_allow?
File... | true |
4e2c415fe1488b3015201e3c54bc19cd331d2025 | Ruby | Straktor/projecteuler | /problems/p04/p4.rb | UTF-8 | 425 | 3.671875 | 4 | [] | no_license | #!/usr/bin/ruby
stopper = 1
a = 999
b = 999
largestPalindrome = 0;
def isPalindromic(n)
n = n.to_s
if n == n.reverse
return true;
end
return false;
end
while a > stopper
b = 999
while b > stopper
currentProduct = a*b
if isPalindromic(currentProduct)
stopper = b
if currentProduct > largestPalindro... | true |
c2aee54e7b82c54ad9b9af8498c70df1d91a6483 | Ruby | seedthelearning/givingtree | /app/models/money_util.rb | UTF-8 | 81 | 2.640625 | 3 | [] | no_license | module MoneyUtil
def convert_to_cents(dollars)
dollars.to_i * 100
end
end | true |
9a30ba4205e4392870255d2fb902cfa9047128bf | Ruby | mfssanhueza/desafio_estructuras_control | /ej5.rb | UTF-8 | 408 | 3.671875 | 4 | [] | no_license | a = false
b = false
# if a == true
# if b == true
# puts 'Lograste A y B!'
# else
# puts 'Lograste A! Pero no B!'
# end
# else
# puts 'No lograste A ni B!'
# end
if a == true && b == true
puts 'Lograste A y B'
elsif a == true && b == false
puts 'Lograste A, pero no B'
elsif a == fa... | true |
bceddb0fd0a7ae44dab745bf89707c1189cb5d96 | Ruby | jasonpaulso/tic-tac-toe-rb-q-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,293 | 4.125 | 4 | [] | no_license | #Board Helper Method
def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end
#Move Helper Method
def move(board, position, value = "X")
position = position... | true |
be33199b4e66bb539c7a6a133cae30d517aa3735 | Ruby | rwheadon/director_portal_partial | /app/models/coupon.rb | UTF-8 | 1,908 | 2.5625 | 3 | [] | no_license | class Coupon < ActiveRecord::Base
belongs_to :event
has_many :reservation_carts
validates :code, :uniqueness => true
def is_valid_today?
(self.effective_start_date <= Date.today) and (self.effective_end_date >= Date.today)
end
def number_used
used_count=0
# Invoice.where(:user_coupon_code =>... | true |
3ffc9de1d375f252f5adca16636c6bd28bdbe81d | Ruby | Not-A-Sith-Lord/course-examples | /week2/solutions/day5/movie_trivia/spec/movie_filter_spec.rb | UTF-8 | 1,127 | 3.25 | 3 | [] | no_license | require_relative "../lib/movie_filter"
# Fake movie class to act as a stand-in for
# the IMDB gem's movie class.
class FakeMovie
# Has a poster method just like IMDB's movie
attr_accessor :poster
end
RSpec.describe "MovieFilter" do
let(:movie_no_poster) { FakeMovie.new }
let(:movie_with_poster) do
the_... | true |
12d97bb3514a6ded8ea5ba80c58051d0285ce7bd | Ruby | chrisotto/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 3,167 | 4.09375 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
def create_grocery_list(shopping_items)
# steps:
# create an empty hash
grocery_list = {}
# add items
# convert input into separate items
shopping_items = shopping_items.split
# add items to... | true |
f71fb84731e4c8703f8927871525cd00b9cf09ce | Ruby | oduolaakeem/codility | /lib/codility/sorting/triangle.rb | UTF-8 | 743 | 3.3125 | 3 | [
"MIT"
] | permissive | # Triangle
#
# Determine whether a triangle can be built from a given set of edges.
#
# A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R)
# is triangular if 0 ≤ P < Q < R < N and:
#
# - A[P] + A[Q] > A[R],
# - A[Q] + A[R] > A[P],
# - A[R] + A[P] > A[Q].
#
# Solution score - https://codility.... | true |
fcf0e8e0c3f011c828b1c64254067a493170e738 | Ruby | RonAddy/PocketBully_Rails | /app/controllers/api_controller.rb | UTF-8 | 942 | 2.65625 | 3 | [] | no_license | # This controller will be used for reference by other controllers inheriting it's methods
# This controller is needed to make the auth methods private
class ApiController < ApplicationController
def require_login
authenticate_token || render_unauthorized("Access Denied")
end
# will be assigned user if nil, pre... | true |
7e38148a147dfd681615e64a62c11557e554d158 | Ruby | panceri/luz | /lib/luz/coupon.rb | UTF-8 | 830 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'date'
module Luz
class Coupon
attr_accessor :id, :discount, :type, :date, :qtd
def initialize(array)
raise ArgumentError, 'Wrong input size' unless array.size == 5
raise ArgumentError, 'Invalid discount type' unless array[2].to_s.match(/(percent|absolute)/)
... | true |
6839f3fa858d3641d82306f8771dede8b6053336 | Ruby | jonahx/tny-url | /domain/url_hash.rb | UTF-8 | 238 | 3.515625 | 4 | [] | no_license | class UrlHash
CHARS = [*'0'..'9', *'a'..'z', *'A'..'Z']
def self.valid?(str)
str =~ /^[a-zA-Z0-9\-]+$/
end
def initialize(num_chars)
@hash = (1..num_chars).map { CHARS.sample }.join
end
def to_s
@hash
end
end
| true |
1fe9580577c8501111dcd2df699894322d221b00 | Ruby | GrantjHanrahan/wdi27-homework | /Hoang_Anh_Tran/week5/monday/games-on-rails/app/controllers/rockpaper_controller.rb | UTF-8 | 1,082 | 2.578125 | 3 | [] | no_license | class RockpaperController < ApplicationController
# Loads view app/views/rockpaper/home.html.erb
def home
end
def play
choices = ["rock", "paper", "scissors"]
@player = params[:throw]
@computer = choices.sample
@winner = ''
if ( @player == "rock" && @computer == "rock" )
@winner... | true |
db302ad64f1c709df436a3be8858e585d84885eb | Ruby | CoderNight/tampa-coder-night-013 | /004/convert.rb | UTF-8 | 2,965 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
require 'bigdecimal'
class Rate
attr_accessor :from, :to, :conversion
def initialize(attrs={})
@from = attrs[:from]
@to = attrs[:to]
@conversion = attrs[:conversion]
end
def parse(doc)
@from ... | true |
bdd30e879cf21e12aa0653063d313050f94c5830 | Ruby | robinwu9000/App-Academy-Work | /w2d3/robert_and_robin/chess/pieces.rb | UTF-8 | 960 | 3.5 | 4 | [] | no_license | class Piece
attr_accessor :position
attr_reader :color
def initialize(color, position, board)
@color, @position, @board = color, position, board
@moved = false
end
def moved?
moved
end
def has_been_moved
@moved = true
end
def empty?
false
end
def valid_moves
moves.sele... | true |
49ad78f0644b662c55c3605790eb870bda1ad056 | Ruby | ElOchi/Calculator-Ruby | /calculator.rb | UTF-8 | 1,028 | 4.15625 | 4 | [] | no_license | def square_root(value)
display Math.sqrt(value)
end
def sphere_area(diameter)
# pi * D ^ 2
display(Math::PI * diameter ** 2)
end
def hyp(a, b)
display(Math.sqrt(a ** 2 + b ** 2))
end
def add(a,b)
display(a + b)
end
def substract(a,b)
display(a - b)
end
def multiply(a,b)
display(a * b)
end
def divide(a... | true |
a7e1a5346e11ab9c9bed4d712a4e3024eb0bc4c5 | Ruby | primaulia/lion-king | /animal.rb | UTF-8 | 225 | 3.40625 | 3 | [] | no_license | class Animal
attr_accessor :name
def initialize(name)
@name = name
end
def eat(food)
"#{@name} eats #{food}"
end
def self.phyla
['Ecdysozoa', 'Lophotrochozoa', 'Radiata', 'Deuterostomia']
end
end
| true |
df402280309f63d9490bedd461d0529f65399629 | Ruby | JoeWroe/makers-academy-course-consolidation | /takeaway-challenge/lib/menu.rb | UTF-8 | 378 | 2.828125 | 3 | [] | no_license | class Menu
def initialize(dishes:, prices:, menuFormatter:)
@dishes = dishes
@prices = prices
@menuFormatter = menuFormatter
end
def avaliable_dishes
dishes.dishes_list
end
def dish_prices
prices.prices_list
end
def formatted_menu
menuFormatter.formatted_menu(self)
end
pri... | true |
c65159834839b56ed6dacb13607ff0ff7c081c4e | Ruby | carlosfvc/ruby_basics_hashes | /ruby_basics_hashes/hash_firstcar.rb | UTF-8 | 260 | 3.4375 | 3 | [] | no_license | car = {type: "sedan",
color: "blue",
mileage: 80_000
}
#add year symbol and year integer value
car [:year] = 1984
p car
#dele one key and its value from the hash
car.delete(:mileage)
p car
#retrieving blue or color key from hash
puts car[:color] | true |
c95136206ad15f9c2e81381b70df613374e10da9 | Ruby | MichalGasiorowski/coursera_prog_lang | /hw7ruby_test_small.rb | UTF-8 | 3,258 | 3.703125 | 4 | [] | no_license | require "./hw7.rb"
ZERO = 0.0
ONE = 1.0
TWO = 2.0
THREE = 3.0
FOUR = 4.0
FIVE = 5.0
SIX = 6.0
SEVEN = 7.0
EIGHT = 8.0
NINE = 9.0
TEN = 10.0
#Point Tests
a = Point.new(THREE,FIVE)
if not (a.x == THREE and a.y == FIVE)
puts "Point is not initialized properly"
end
if not (a.eval_prog([]) == a)
puts "Point eval_p... | true |
f947a7ba03eb5be69fe2ad086d0956075c568ef8 | Ruby | emmilco/Chess-W2D1 | /class_inheritance.rb | UTF-8 | 675 | 3.34375 | 3 | [] | no_license | class Employee
attr_reader :name, :title, :salary, :boss
def initialize(name, title, salary, boss = nil)
@name = name
@title = title
@salary = salary
@boss = boss
end
def bonus(multiplier)
salary.to_i * multiplier
end
end
class Manager < Employee
attr_reader :employees
def init... | true |
976b55056c5a6b237c01cce26d46152d3891523f | Ruby | CodeCoreYVR/september_2015_fundamentals | /ruby_2/fizz_buzz_array.rb | UTF-8 | 255 | 3.765625 | 4 | [] | no_license | array = [] # array = Array.new
for number in 1..100
if number % 3 == 0 && number % 5 == 0
array << "FIZZBUZZ"
elsif number % 3 == 0
array << "FIZZ"
elsif number % 5 == 0
array << "BUZZ"
else
array << number
end
end
print array
| true |
221b473c60fbd8d8e664c4ecdef28e5faaa0eaa5 | Ruby | anggiimaisa/my-library | /app/command/library/put_book_command.rb | UTF-8 | 387 | 2.75 | 3 | [] | no_license | require './app/command/command'
class PutBookCommand < Command
def execute(args)
shelves = args["shelves"]
book = args["book"]
shelves.each do |book_shelf|
if book_shelf.book.empty?
book_shelf.book = book
return { 'message' => "Allocated address: #{book_shelf.shelf.print}" }
... | true |
4994665e255052910ff31ca4744db2234ba462fd | Ruby | Shopify/linecook-gem | /lib/linecook-gem/cli.rb | UTF-8 | 5,997 | 2.59375 | 3 | [] | no_license | require 'thor'
require 'linecook-gem'
class Image < Thor
desc 'keygen', 'Generate a new encryption key'
def keygen
puts Linecook::Crypto.keygen
end
desc 'list', 'List images'
method_option :name, type: :string, required: false, banner: 'NAME', desc: 'Name of the image to fetch.', aliases: '-n'
metho... | true |
93bfbcbfe00c6259aac1b870e6d06de359bcb8f6 | Ruby | DanylNysom/project_euler | /006.rb | UTF-8 | 443 | 3.890625 | 4 | [] | no_license | #!/usr/bin/ruby
# Computes the difference between the square of the sum of the numbers 1..100 and
# the sum of the squares of teh numbers 1..100
def sum_of_squares(max)
sum = 0
(1..max).each do|current|
sum = sum + current**2
end
return sum
end
def square_of_sums(max)
sum = 0
(1..max).... | true |
0c9dc179577e9828caa87706b44a51d3242296ee | Ruby | Mackenzie-Frey/brownfield-of-dreams | /app/services/github_service.rb | UTF-8 | 631 | 2.5625 | 3 | [] | no_license | class GithubService
def initialize(token)
@token = token
end
def get_repos
get_json('user/repos')
end
def get_followers
get_json('user/followers')
end
def get_following
get_json('user/following')
end
def get_email(invite_github_handle)
get_json('users/' + invite_github_handle)
... | true |
cbce834cb29bd86fb6a9ec28b5d35d1413e164b4 | Ruby | itorterat/CodeWars | /8_kyu/l1_set_alarm/l1_set_alarm.rb | UTF-8 | 161 | 2.65625 | 3 | [] | no_license | # URL:
# https://www.codewars.com/kata/568dcc3c7f12767a62000038
#
# Title:
# L1: Set Alarm
#
# v1
def set_alarm(employed, vacation)
employed && !vacation
end
| true |
c1eaaf8f36fff9529a937caa94ac67e5f8138033 | Ruby | kiran-gurujada/pickaxe | /chapter25/looking_at_classes.rb | UTF-8 | 1,741 | 3.84375 | 4 | [] | no_license | # Knowing about objects is one part of reflection, but to get the whole
# picture, you also need to be able to look at classes the methods and
# constants they contain.
#
# Look at a class heirarchy using Class#superclass, or Module#ancestors.
def pretty_print_heirarchy(klass)
begin
print klass
klass = klass... | true |
6903032e550cd56301c37c1aa8062e8a883f1c71 | Ruby | chikuim/ruby | /numeric.rb | UTF-8 | 207 | 2.78125 | 3 | [] | no_license | name="A"
weight=50
p name+"さんの体重は"+weight.to_s+"kgです"
p "#{name}さんの体重は#{weight}kgです"
p '#{name}さんの体重は#{weight}kgです'
names=["Git","HTML","CSS"]
p names[1]
| true |
6382865e48245e13471f82b2a2b03fdc2a373867 | Ruby | thechanmoon/nyc-web-111919 | /08-inheritance-review/lib/cat.rb | UTF-8 | 1,451 | 3.75 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cat < Animal # Single Inheritance
# pulls in the code as class stuff
extend AModuleName::ClassMethods
# pull in the code as instance stuff
include AModuleName::InstanceMethods
def initialize(name)
super(name)
@lives = 9
self.class.all << self
end
# this works
def lands_on_feet
... | true |
cbc2b8db903f416c9adda95cc42ffbb3542775ab | Ruby | bryanhou1/ttt-with-ai-project-v-000 | /lib/game.rb | UTF-8 | 1,122 | 3.65625 | 4 | [] | no_license | class Game
attr_accessor :board, :player_1, :player_2
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 initialize (player_1 = Players::Human.new("X"), player_2 = Players::Human.new("O"), board = Board.new)
@player_1 = player_1
@player_2 = player_2
@board = board
end
d... | true |
824034c35905c3d7694a553acf1a993fc9a11122 | Ruby | jgeorgex/mastery-curriculum | /hello_steve.rb | UTF-8 | 450 | 4.53125 | 5 | [] | no_license | #The user sees a greeting, which asks them to enter their name.
#The user enters their name.
#If the user's name begins with 'S', the program shouts the user's name back at them.
#If the user's name begins with any other letter, the program just says 'Hi, ' plus their name.
p "Hi, whats your name?"
user_name = gets.ch... | true |
12fe6c6907ab762498bd0bc9258abd7458bf316d | Ruby | includedavis/farmdavis | /spec/user_helper.rb | UTF-8 | 970 | 2.625 | 3 | [] | no_license | module UserHelpers
# gen_user
# ========
# Create a new user and add to DB
# Params:
# pass - Password for user (OPTIONAL)
# Returns:
# New user object
def gen_user(pass = "test")
FactoryGirl.create(:User, password: pass, password_confirmation: pass)
end
# gen_roled_user
# =============... | true |
33672defda4be47bbe4d804bf22fac9e693b1b18 | Ruby | trentdm/AlgosOnRails | /src/algos/app/controllers/algos/searchings/linears_controller.rb | UTF-8 | 1,094 | 2.546875 | 3 | [] | no_license | class Algos::Searchings::LinearsController < ApplicationController
def index
@properties = AlgoProperties.new
if !params[:algo_properties].nil?
@properties.input = params[:algo_properties][:input]
@properties.parameter = params[:algo_properties][:parameter]
elsif
@properties.input... | true |
f7063a58556fc7a58c0f4727f1a791d5caca0dc6 | Ruby | mrkchoi/W2D3 | /03_poker/lib/card.rb | UTF-8 | 275 | 3.890625 | 4 | [] | no_license |
class Card
attr_reader :suit, :value
def initialize(suit, value)
@suit = suit
@value = value
end
def inspect
if suit == '♥' || suit == '♦'
"#{value}#{suit}".colorize(:red)
else
"#{value}#{suit}".colorize(:black)
end
end
end
| true |
d5633418ea94256901239f7f4fb230c188283fd2 | Ruby | klueless-io/sample_cmdlet_patterns | /lib/sample_cmdlet_patterns/commands/prompt_expand.rb | UTF-8 | 1,551 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../command'
require 'tty-config'
require 'tty-prompt'
module SampleCmdletPatterns
module Commands
# expand
class PromptExpand < SampleCmdletPatterns::Command
def initialize(options)
@options = options
end
# Execute PromptExpand subc... | true |
edf477e61daad5166bd51e7f633864e27f6a268f | Ruby | braj011/tweet-shortener-london-web-082718 | /tweet_shortener.rb | UTF-8 | 2,024 | 4.1875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
require 'pry'
def dictionary
convert = {
"hello" => "hi",
"to" => "2",
"two" => "2",
"too" => "2",
"for" => "4",
"four" => "4",
"be" => "b",
"you" => "u",
"at" => "@",
"and" => "&"
}
end
# FUNCTION 1 - replaces long words with their expected short form
def w... | true |
48523d077a0ab270dc831496988488c51d9625e4 | Ruby | emceegithub/oxford-comma-cb-000 | /lib/oxford_comma.rb | UTF-8 | 334 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 1
return array[0]
elsif array.length == 2
return array.join(" and ")
elsif array.length >= 3
string = ""
lastElement = array.last
array.pop
string = array.join(", ")
string = "#{string}, and #{lastElement}"
return string
else
#do not... | true |
5aa89c89ff4050f99d29d2239ca30175eb96b63c | Ruby | piercebelton/ruby_day2 | /car_challenge.rb | UTF-8 | 2,826 | 4.0625 | 4 | [] | no_license | # Story: As a programmer, I can make a vehicle.
# Hint: Create a class called Vehicle, and create a variable called my_vehicle which contains an object of class Vehicle.
#
# Story: As a programmer, I can make a car.
# Hint: Create a class called Car, and create a variable called my_car which contains an object of cla... | true |
bc02d0a85c6ee1dfcadf558c9914ca6f5b161de8 | Ruby | jitendrak1/ApexftAssignment | /apexft/app/models/apexftdatum.rb | UTF-8 | 2,007 | 2.78125 | 3 | [] | no_license | class Apexftdatum < ApplicationRecord
validates :stockprice, :strikeprice, :timetomaturity, :interest, :volatility, :presence => true
validates :stockprice, :strikeprice, :timetomaturity, :interest, :volatility, :numericality => true
def self.cnd(x)
a1, a2, a3, a4, a5 = 0.31938153, -0.356563782, 1.781477937, -... | true |
0f5b93450774de7dffff32b217b8b74ee1b7d11c | Ruby | harrietty/advent_of_code_2018 | /day4/spec/pt1.spec.rb | UTF-8 | 1,067 | 2.90625 | 3 | [] | no_license | require 'rspec'
require 'time'
require_relative '../pt1'
RSpec.describe "format_and_order" do
it 'orders the input' do
input = "[1518-08-06 00:13] falls asleep
[1518-06-10 00:37] wakes up
[1518-07-08 00:20] wakes up
[1518-05-13 00:24] falls asleep
[1518-11-07 00:32] falls asleep"
expected = [
{
... | true |
b210b2dddb19338a61b6964213fb3f5828f3d7b9 | Ruby | krismosk/grocery-store | /class_methods.rb | UTF-8 | 73 | 2.703125 | 3 | [] | no_license | class Test
def self.test
"Test"
end
end
puts Test.test # "Test"
| true |
82a934eca1af59b0121f0f558a820ed2fe7a9201 | Ruby | EternalSwordsman/GMBot | /GMbot/lib/gmbot/Item.rb | UTF-8 | 4,944 | 3.671875 | 4 | [] | no_license | class Item
@item_type = ""
@attack_desc = ""
attr_reader :slot, :name, :attack_bonus, :defense_bonus, :damage_bonus, :description
# You can use this function three ways:
# initialize(slot, name, attack_bonus, defense_bonus, damage, description, attack_type)
# This creates an item with the stats specif... | true |
41df6b4d28d3ede712780f25900e24725eaaf64c | Ruby | milikkan/intro-to-programming-with-ruby | /ch05-loops_and_iterators/ex02.rb | UTF-8 | 117 | 3.046875 | 3 | [] | no_license | input = ""
while input != "STOP" do
puts "performing some action here..."
puts "Input?"
input = gets.chomp
end | true |
de02724439b96b90759176ade19c955aaaec12b9 | Ruby | ashmckenzie/vliner | /lib/vliner/scraper.rb | UTF-8 | 2,341 | 2.71875 | 3 | [] | no_license | class Vliner::Scraper
SECONDS_IN_AN_HOUR = 3600
SECONDS_IN_A_MINUTE = 60
GEELONG_TO_MELBOURNE = 'https://www.vline.com.au/apps/jp/tripplanner/GetTripRes.asp?return=0&origin=Geelong%20Station:%20Railway%20Terrace&destination=Melbourne,%20Southern%20Cross&DepDate=24/Oct/2011&RetDate=23/Oct/2011' #&ADFC=1&COFC=0&C... | true |
fb80691e962cddc7e43f175b9a8118f2851b3c79 | Ruby | ajberk/FFProject | /db/seeds.rb | UTF-8 | 1,875 | 2.734375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
6b8c942e57e637528f1ef9b2a0f30554371cc81e | Ruby | LeahESc/ruby-objects-has-many-lab-onl01-seng-ft-090820 | /lib/song.rb | UTF-8 | 401 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Song
attr_accessor :name, :artist
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def artist_name
self.artist ? self.artist.name : nil
end
# def add_song_by_name(title)
# song = self.new
# song.title = title
# ... | true |
917310e4e3bc48d91d383412762e4f7498c098d3 | Ruby | nickcen/leetcode | /p36.rb | UTF-8 | 750 | 3.40625 | 3 | [] | no_license | # @param {Character[][]} board
# @return {Boolean}
def is_valid_sudoku(board)
0.upto(8).each do |x|
0.upto(8).each do |y|
return false unless is_valid_cell(board, x, y)
end
end
true
end
def is_valid_cell(board, x, y)
xs = 0.upto(8).map{|i| '.' == board[x][i] ? nil : board[x][i]}.compact
return ... | true |
2fce08b1e9e10ab83214bc1a6c18b1245ac48171 | Ruby | natecraft1/legacyy | /app/controllers/pages_controller.rb | UTF-8 | 685 | 2.640625 | 3 | [] | no_license | class PagesController < ApplicationController
def home
@users = User.all
@first_user = User.first
if @first_user != nil
@image_array = switch_it_up(@first_user)
end
# sort = @first_user.years.sort_by { |year|
# year.year.to_i
# }
# @image_array = []
# sort.map {|x|
# unless x.avatar_file_na... | true |
aa79fdbdb8a903ad6fbf451e357485ebb72e43c0 | Ruby | mkhettry/wecook | /script/cross_validation.rb | UTF-8 | 3,346 | 2.921875 | 3 | [] | no_license | require 'script/model_builder.rb'
TEST_PERCENTAGE = 80
# 100 files
# idx = 75
# 75..99, 0..54
def get_training_range(total_size, idx)
num_files = (total_size * TEST_PERCENTAGE) / 100
if (idx + num_files <= total_size)
[idx...(idx + num_files)]
else
[idx...total_size, 0...num_files - (total_size - idx)]
... | true |
7c2bc80a22e4b3854e984aa88f13cd89a533f44c | Ruby | louprinster/resort-reservation | /app/helpers/application_helper.rb | UTF-8 | 560 | 2.8125 | 3 | [] | no_license | module ApplicationHelper
def num_of_days_helper(start_date, end_date)
if start_date == end_date
num_of_days = 1
else
num_of_days = (start_date...end_date).count
end
num_of_days
end
def rate_helper(rental_type, date)
if (date.strftime("%u").to_i == 5) || (date.strftime("%u")... | true |
dd763d13099324f6dd0663dd444b9ebdb4ddea15 | Ruby | torreta/Vault | /utilities/states.rb | UTF-8 | 161,693 | 2.65625 | 3 | [] | no_license |
# states for every country, migth need coordinates later, but thats a job for another day.
# idea: maybe add coordinates to triangulate borders, so its easier to geolocate based on
# coordinates.
# think this might be a good service. if a ip is given....
State.create([
{name: "Andaman and Nicobar Islands",countr... | true |
dcb46bbf8ee3fd51a9b1c6c8a5836c7442d99a3b | Ruby | johnbaldwin/keyp-ruby | /lib/keyp.rb | UTF-8 | 6,224 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | require 'keyp/version'
require 'keyp/bag'
require 'json'
require 'yaml'
require 'time'
##
# This is the main module for the Keyp library
#
# = Overview
#
#
# Keyp is not yet supported on Windows
#
# = Developer notes
#
# NOTE: Do not implement a copy method to explicitly copy one bag to another.
# This is too prone to... | true |
90d231df8d25aaf763976ea9c4904069b97219a5 | Ruby | anton-sher/project-euler | /project-euler.rb | UTF-8 | 1,524 | 3.34375 | 3 | [] | no_license | def sum_proper_divisors(n)
s = 1
i = 2
while i * i < n do
s += i + n/i if n % i == 0
i += 1
end
s += i if i * i == n
return s
end
def is_prime(n)
return false if n <= 1
for d in (2..(Math.sqrt(n).to_i)) do
return false if n % d == 0
end
return true
end
def gcd (a, b)
return gcd(b, a) if a < b
r = a... | true |
ef9c166a946ae22e1674d8f6415065d260411b1f | Ruby | spejamchr/code | /other_ruby/lambdas/lib.rb | UTF-8 | 4,967 | 3.421875 | 3 | [] | no_license | # a variable, 1, is itself a valid lambda term
# if t is a lambda term, then l[ t ] is a lambda term (called a lambda abstraction);
# if t and s are lambda terms, then t[s] is a lambda term (called an application).
module LogAround
def peep(method, &block)
ali = "_orig_#{method}".to_sym
alias_method ali, met... | true |
a1991f6bf30a8894b8f48a1a147f5c112b727f5f | Ruby | 007mike/rb101_109_small_problems | /easy9/grocery_list.rb | UTF-8 | 238 | 3.671875 | 4 | [] | no_license | def buy_fruit(arr)
fruits = []
arr.each { |subarr| subarr[1].times { fruits << subarr[0] } }
fruits
end
p buy_fruit([["apples", 3], ["orange", 1], ["bananas", 2]]) ==
["apples", "apples", "apples", "orange", "bananas","bananas"] | true |
ecf06a193fe24d246125d350b8f3f5e645d58170 | Ruby | NMTCC/sensu-tcc-plugins | /plugins/handlers/hubotpush.rb | UTF-8 | 926 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Pushes Sensu Reports to a listening Hubot
#
# This Handler sends client name, check name, status code, and check
# output to a properly configured Hubot HTTP listener.
#
# Data is sent though an HTTP post.
#
# One setting is required in hubotpush.json
# host : The ip and port of the Hubot HTT... | true |
d2c1a5fc1e8455520f88d6bf691052e2d76782da | Ruby | perez-e/WDI_Homework_1 | /frame_your_phrase.rb | UTF-8 | 1,088 | 3.703125 | 4 | [] | no_license | puts "Please enter a phrase to be framed"
phrase = gets.chomp.split
max_word_length = phrase.map {|word| word.length}.max
puts "*"*(max_word_length+6) # top frame
space = max_word_length+3 # space inside minus 1 space character
# content inside the frame
phrase.each {|word| puts "* #{word}" << " "*(space-word.l... | true |
4fcf581664660401e0450ad30c27e12f80956123 | Ruby | ryanmcgarvey/Ryan-goes-to-training | /rails2_studio/code/meta/class_from_struct.rb | UTF-8 | 273 | 3.703125 | 4 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | class Address < Struct.new(:street, :city, :zip, :state)
def to_s
"#{self.street}\n#{self.city}, #{self.state} #{self.zip}"
end
end
add = Address.new("123 Main", "Springfield", "75123", "IL")
puts add.to_s # >> 123 Main
# >> Springfield, IL 75123
| true |
2e8499b75e00508d54a44f341d3bbbf1e1c5b10b | Ruby | neddy/Launch-School | /Exercises/101-109_Small_Problems/6_Easy/ex_2.rb | UTF-8 | 545 | 4.65625 | 5 | [] | no_license | # ex_2.rb
# Delete vowels
# Write a method that takes an array of strings, and returns an array of the same string values, except with the vowels (a, e, i, o, u) removed.
#
# Example:
def remove_vowels(arr)
arr.each do |string|
string.gsub!(/[aeiou]/i, '')
end
arr
end
puts remove_vowels(%w(green YELLOW bla... | true |
56bc2180bf83dd2f8c7bc003a71d3c360b2e985d | Ruby | Bilobaba/THPTravail | /Semaine2/jour_3/TwitterBot/BotKevin.rb | UTF-8 | 2,024 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
#use twitter gem
require "twitter"
Consumer_key = "T5m80d6v6dFD9IazQV689VQ5p"
Consumer_secret = "qbiUmo2GNJsqc6TKk2jua1utjU660WXyJK1ivzBGzPTuCA6Odk"
Access_token = "718464663986552832-Mu0xSV9UrGaIyJ5J6QjvlMeZX8LBeLb"
Access_token_secret = "UjqEHbk18NpqclPQmp9PrD3UgMXvRXzAI2u66QU4... | true |
77eef0ca02b4015004ed1ad29d3bb3583096eb12 | Ruby | dewolfe/improving | /difference-of-squares/difference_of_squares.rb | UTF-8 | 318 | 3.109375 | 3 | [] | no_license | require 'pry'
class Squares
attr_accessor :num
def initialize(num)
@num = num
end
def square_of_sum
((1..num).inject(:+))**2
end
def sum_of_squares
(1..num).inject(0){|t,n| t += n**2}
end
def difference
square_of_sum - sum_of_squares
end
end
module BookKeeping
VERSION = 4
end
| true |
7b7ecf980ba6642f268ec83e8a36bb045f0603df | Ruby | DenisKurbatov/snp-internship | /exer4/anagrams.rb | UTF-8 | 106 | 2.84375 | 3 | [] | no_license |
def combine_anagrams(words)
hash = words.group_by {|word| word.chars.sort}
array = hash.values
end
| true |
e12405f7c3a9143ca6e93b5a9fdea7433704efb7 | Ruby | Elunaer/theodinproject | /stock_picker.rb | UTF-8 | 535 | 3.765625 | 4 | [] | no_license | STOCKS = [17,3,6,9,15,8,6,1,10].freeze
def stock_picker(stocks)
#the best day to buy
@to_buy = stocks.min
@buy_day = stocks.index(@to_buy)
#the best day to sell
@to_sell = stocks.max
@sell_day = stocks.index(@to_sell)
end
stock_picker(STOCKS)
profit = @to_sell - @to_buy
puts "You bought stock ... | true |
4d8c6afa70520b059e8d931939cf9151de755bd8 | Ruby | Vashiramusa/enum-methods | /enumerable_methods.rb | UTF-8 | 3,186 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
module Enumerable # rubocop:disable Metrics/ModuleLength
def my_each
return to_enum unless block_given?
i = 0
while i < size
yield(self[i])
i += 1
end
end
def my_each_with_index
return to_enum unless block_given?
size.times do |i|
yield(s... | true |
c4b915aec9aec0fc1697372f334a1e54d2a0a594 | Ruby | jkamizato/tic_tac_toe | /tabuleiro.rb | UTF-8 | 2,240 | 3.53125 | 4 | [] | no_license | class Tabuleiro
attr_reader :jogador1, :jogador2, :quem_joga, :quem_venceu
def initialize
jogadas_vencedoras
inicia_jogador
set_quem_joga 1
end
def inicializa_tabuleiro
@tabuleiro = Hash.new
for posicao in 1..9
@tabuleiro[posicao] = 0
end
end
def inicia_jogador
@jogador... | true |
7bf2ab3b911f21b125cfde895c94b306c6e575be | Ruby | adzshaf/library | /lib/book.rb | UTF-8 | 456 | 3.375 | 3 | [] | no_license | # frozen_string_literal: true
class Book
attr_reader :isbn, :title, :author
def initialize(isbn, title, author)
@isbn = isbn
@title = title
@author = author
end
def has_title?(title)
@title.downcase.include? title.downcase
end
def has_author?(author)
@author.downcase.include? author.... | true |
e7711c22c1c57260fc5141d7516193f700ac6ada | Ruby | jspaw/ruby-tests | /PassgenSpecs/pg3/passgen.rb | UTF-8 | 175 | 2.703125 | 3 | [] | no_license | class Passgen
def genPass (num)
@array = []
num.times {@array << "a"}
@array
end
def getPasses (num)
@array = []
num.times {@array << "a"}
@array
end
end
| true |
da059926326329ab9a17b18f644ab3af0389cd18 | Ruby | valobox/epub | /lib/epub/item/css.rb | UTF-8 | 6,222 | 2.671875 | 3 | [
"MIT"
] | permissive | module Epub
class CSS < Item
attr_accessor :css, :sass
def initialize(epub, id)
super(epub, id)
@type = :css
@normalized_dir = "OEBPS"
end
def standardize
log "Standardizing css #{@filepath}..."
# Create the sass from css
css_to_sass
# fonts need resiz... | true |
d4f8946eb38c44ec2090bc8fa02cae786117aa0a | Ruby | kaochenlong/candidates | /app/services/sms_service.rb | UTF-8 | 223 | 2.78125 | 3 | [] | no_license | class SmsService
def initialize(phone_number)
@phone_number = phone_number
end
def send_msg(text = "")
#.......
puts "---" * 20
puts "send #{text} to #{@phone_number}!!"
puts "---" * 20
end
end
| true |
d9e554a029dc2238ad3a093050a78df3bc7c67a6 | Ruby | h74zhou/commerce-api | /app/graphql/mutations/create_product.rb | UTF-8 | 504 | 2.515625 | 3 | [] | no_license | module Mutations
class CreateProduct < BaseMutation
# arguments passed to the `resolve` method
argument :title, String, required: true
argument :price, Float, required: true
argument :inventory_count, Integer, required: true
# return type from the mutation
type Types::ProductType
def res... | true |
421f63d1158337f1b68e472029d7e59d2a1e8c00 | Ruby | madou2000/cookbook | /bor/ch12/load_module.rb | UTF-8 | 554 | 3.09375 | 3 | [] | no_license | # The Book of Ruby - http://www.sapphiresteel.com
$:<<"g:/rorapps/bor/ch12"
load( "testmod.rb",false)
#puts(require( "testmod" ))
# Here any executable code in the loaded file will be run
# but the code iself will be loaded in an anonymous module
# so cannot be referenced here...
# None of this code can be executed!
... | true |
a117eea7a13e331230a02cfced6bd5ce20d6b2fa | Ruby | XanderStrike/SBSG | /app/helpers/schedules_helper.rb | UTF-8 | 1,545 | 2.9375 | 3 | [] | no_license | module SchedulesHelper
def schedule_by_employee_csv(shift_assignments, employee_assignments)
csv_hash = {"1" => ["", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]}
7.times do |day|
shift_assignments[day].count.times do |assignment|
employee = Employee.find(employ... | true |
49c6a163ff540a4781df9abc534ec8bdf49e4cef | Ruby | philiplambok/authentication-workflow-object | /app/services/auth_header_service.rb | UTF-8 | 686 | 3.03125 | 3 | [] | no_license | class AuthHeaderService
def initialize(opts)
@auth_header = opts[:auth_header]
end
def valid?
if header_not_empty and header_have_valid_format and header_can_decode
true
else
false
end
end
def token
auth_header = @auth_header.split
auth_header[1]
end
private
def... | true |
628c548b2112997e2e7ab64562eccfecef024c00 | Ruby | romanroibu/IDE-labs | /lab#2/Rubulator OS X/Rubulator/calculator.rb | UTF-8 | 2,501 | 3 | 3 | [] | no_license | require 'mathn'
require 'singleton'
class CalculatorClass
include Singleton
def initialize
@operator = ""
@first_operand = ""
@second_operand = ""
end
def add_digit(digit)
if @operator.empty?
@first_operand << digit.to_s if (@first_operand.size < 10)
else
@second_ope... | true |
b7b7d80206ec25603939a38500ffff6e779f2266 | Ruby | mpedersen2054/tealeaf | /course1/week1/blackjack.rb | UTF-8 | 1,321 | 4.34375 | 4 | [] | no_license |
# Initialize the player and dealer with 0 card value
def ace
puts "Would you like your ace to be worth 1 or 11?"
puts "Type in 1 or 11 into the prompt, and then press enter"
end
def card_drawer
@player_total = 0
draw_card = rand(1..52)
while @player_total < 22
if draw_card < 33
number_value = r... | true |
78b0f16742d3256c360d400e14f56043a0c7c2c8 | Ruby | yoshioota/simple_cipher | /lib/simple_cipher/core.rb | UTF-8 | 1,807 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'active_support/concern'
module SimpleCipher
module Core
extend ActiveSupport::Concern
module ClassMethods
def encrypt(plain_text)
cipher = OpenSSL::Cipher.new(SimpleCipher.config.cipher).encrypt
set_key_and_iv(cipher)
encrypted_text = cipher.update(plain_text) + ciphe... | true |
3646ca0b4fc5982b508887d8e6d311c5ef86e83d | Ruby | SBR2015/maro1 | /q09/exe.rb | UTF-8 | 83 | 2.8125 | 3 | [
"MIT"
] | permissive | require_relative '../q06/ans.rb'
def subtract(a,b)
a + b
end
puts subtract(5,3)
| true |
f061cf44c89b98706555b65861131474e9bfcd88 | Ruby | wrenisit/futbol | /test/teams_test.rb | UTF-8 | 785 | 2.703125 | 3 | [] | no_license | require './lib/team'
require_relative 'test_helper'
class TeamTest < MiniTest::Test
def test_it_exists
team = Team.new({team_id: "1", franchiseid: "23", teamname: "Atlanta United", abbreviation: "ATL", stadium: "Mercedes-Benz Stadium",link: "/api/v1/teams/1"})
assert_instance_of Team, team
end
def test_... | true |
eded21588d91c9f49f4803740924ab9c11c6d0c3 | Ruby | journeywithrails/boss | /test/unit/version_one_taxes_test.rb | UTF-8 | 9,481 | 2.75 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
class VersionOneTaxesTest < Test::Unit::TestCase
# tests the module ::Tax::TaxesVersionOne, using user object
fixtures :taxes, :users
def setup
end
def teardown
end
def test_should_walk_set_of_tax_1_and_tax_2
names = Set.new
::Tax::TaxesVer... | true |
1f4fb9cc236017a4587c5ee9cfa365d3a5b65feb | Ruby | journeywithrails/boss | /test/unit/tax_test.rb | UTF-8 | 5,592 | 2.53125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
include Sage::BusinessLogic::Exception
class TaxTest < Test::Unit::TestCase
def test_should_create_a_new_copy
root = Tax.new(
:included => false,
:rate => BigDecimal("4.1"),
:name => "bob's tax",
:profile_key => "tax_1",
... | true |
54e26cef99c68569abcc0b01118991cd7df263dd | Ruby | matthewfu/query-parser | /tests/term_parser_tests.rb | UTF-8 | 940 | 2.609375 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | # coding: utf-8
require 'minitest/autorun'
require_relative '../term_parser'
class TermParserTests < Minitest::Test
def test_single_term
tree = TermParser::QueryParser.new.parse('foo')
assert_equal({:query => [{:term => 'foo'}]}, tree)
end
def test_multiple_terms
tree = TermParser::QueryParser.new.p... | true |
758c1b78af2f153181741f773a8078a12d9138c1 | Ruby | fweep/vim-zsh-path-completion | /spec/unit/expand_path_spec.rb | UTF-8 | 3,920 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | describe "s:expand_path" do
# FIXME: turn some of these into integration tests
let!(:sid) { VIM.command("echo g:zsh_path_completion_SID") }
def expand_path(path_components)
VIM.command("echo #{sid}expand_path(#{path_components})")
end
describe "with an empty directory" do
it "expands 's' to blank"... | true |
a2044f65ec72fc0162db63eecc736109d5cb87a4 | Ruby | ICanDoAllThingThroughChrist/oo-banking-v-000 | /lib/bank_account.rb | UTF-8 | 574 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #require 'pry'
class BankAccount
attr_accessor :balance, :status, :deposit
def initialize (name)
@name = name
@balance = 1000
@status = "open"
end
def name
@name
end
def deposit=(a_deposit)
@a_deposit = a_deposit
end
def deposit(a_deposit)
#binding.pry
@balance =
@balance... | true |
4b308c5a0be4419a65bf48c0ac140f398b62ead4 | Ruby | briankung/change_kata | /lib/change_kata.rb | UTF-8 | 175 | 2.734375 | 3 | [] | no_license | class ChangeKata
def initialize(amount=nil)
end
def quarter
return 25
end
def dime
return 10
end
def nickel
5
end
def penny
1
end
end
| true |
0e778194cd1b92380aa35a54867a28e5154e5ca6 | Ruby | imnithin/iplt20 | /app/models/match.rb | UTF-8 | 865 | 2.625 | 3 | [] | no_license | class Match < ActiveRecord::Base
has_many :teams
has_many :users, through: :user_matches
has_many :user_matches
has_one :team1, class_name: "Team", foreign_key: "id", primary_key: 'team1'
has_one :team2, class_name: "Team", foreign_key: "id", primary_key: 'team2'
def team_name(id)
team_and_code = Has... | true |
5a9e4c97b780dff35b2e5da7afc29d29f4ae8909 | Ruby | durhamka/game-of-life | /board_spec.rb | UTF-8 | 665 | 3.140625 | 3 | [] | no_license | require 'rspec'
require_relative './board'
describe Board do
describe '#to_s' do
it 'returns a string of the board' do
board = Board.new([[0,0,0,0,0]])
expect(board.to_s).to eq('00000')
end
it 'returns a string of the board with multiple rows' do
board = Board.new([[0,0,0,0,0],
... | true |
1102e5d15fd33d71d73a3e44914c2d6e2a5c8b89 | Ruby | gustavoguimaraes/meta_programming_ruby | /my_attr_writer.rb | UTF-8 | 940 | 3.8125 | 4 | [] | no_license | module MyAttr
def my_writer(attr_name)
define_method("#{attr_name}=") do |value|
instance_variable_set("@" + attr_name.to_s, value)
end
end
end
class Cat
#Use extend instead of include so that my_reader is a class method
extend MyAttr
my_writer :name
def initialize(name)
@name = name
... | true |
9d8d3c2d3ec23134e367bdd60b407af2ae01c214 | Ruby | LynnJack/Rails-TTT | /app/controllers/games_controller.rb | UTF-8 | 1,428 | 2.90625 | 3 | [] | no_license | class GamesController < ApplicationController
def new
@game = Game.new
@game.save
redirect_to game_path(@game)
end
def update_board
@game = Game.last
a = params[:row].to_i
b = params[:column].to_i
if @game.counter.even? && !@game.board[a][b]
@game.board[a][b] = 'O'
elsif... | true |
dc11570c78108bfd678b6d8632d47d92a5a21f58 | Ruby | bmatto/negativeDarkMatter | /Second_Ruby/gol_test.rb | UTF-8 | 683 | 2.75 | 3 | [] | no_license | require 'minitest/autorun'
require './gol'
class GameTest < Minitest::Test
def setup
@game = Game.new()
@verse = Array.new(10){Array.new(10)}
@lifeform = Lifeform.new()
end
def test_game_exists
assert_instance_of(Game, @game)
end
def test_verse_exists
assert_equal(@game.verse, @verse)
... | true |
175f44ab7f777006bc559fc7d1f557e0de7cd613 | Ruby | sschweber/elevators | /elevators.rb | UTF-8 | 913 | 3.875 | 4 | [] | no_license | require './building.rb'
require './persons.rb'
require './floors.rb'
class Elevators
def initialize (max_persons, resting_floor)
@max_persons = max_persons
@capacity = 0
@resting_floor = resting_floor
@current_floor = resting_floor
@direction = "up"
end
def current
return @current_floor
end
def inc... | true |
4c9f14251e829e3254a1be1602449b18dd83e6f5 | Ruby | Fem-Fem/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 829 | 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 |name, index|
puts "#{index + 1}. #{name}"
end
end
def summon_captain_planet(power)# code an argument here
# Your code here
power.collect do |name|
corrected = name.capitalize
perfect = corrected + "... | true |
6f1c06bb581903347d32a9f4affcacb3ce696021 | Ruby | mpissanos/crypto-calculator | /app/models/currency.rb | UTF-8 | 276 | 2.8125 | 3 | [] | no_license | class Currency < ApplicationRecord
def calculate(amount)
(current_price.to_f * amount.to_f).round(4)
end
def current_price
url = 'https://api.coinmarketcap.com/v1/ticker/'
request = HTTParty.get(url + self.slug)
response = JSON.parse(request.body)
end
end
| true |
c915f3941229001969df129d5ef5e8442ffefa03 | Ruby | nebirhos/hamckle | /lib/hamckle/settings.rb | UTF-8 | 657 | 2.546875 | 3 | [
"MIT"
] | permissive | module Hamckle
class Settings
def initialize(path)
@path = File.expand_path(path)
@data = Hashie::Mash.new(load_yaml)
end
def data
@data.to_h
end
def method_missing(method, *args)
@data.send(method, *args)
end
def save!
File.open(@path, 'w') { |f| YAML.dump... | true |
34fd9dbe8961345263086f31dcd57956ea5c96b2 | Ruby | frogfather/week2_weekend | /bar.rb | UTF-8 | 868 | 3.546875 | 4 | [] | no_license | class Bar
attr_reader :age_limit, :price, :rooms
def initialize(age_limit, price)
@age_limit = age_limit
@price = price
@rooms = []
@next_id = 0
end
def get_room_count
return @rooms.count
end
def get_person_count
return @people.count
end
def add_person_to_room(person, room)
... | true |
e5df9a5119fd6a5037a4a6b6dfabd011eace5a9a | Ruby | vinsol/basic_presenter | /spec/basic_presenter/concern_spec.rb | UTF-8 | 4,661 | 2.8125 | 3 | [
"MPL-2.0",
"MPL-1.1",
"MIT",
"BSD-3-Clause"
] | permissive | require 'spec_helper'
#require 'forwardable'
class DomainClass
include BasicPresenter::Concern
attr_accessor :first_name, :last_name
def initialize(first_name, last_name)
@first_name = first_name
@last_name = last_name
end
end
#class BasePresenter
# # extend Forwardable
# # Presenter Class should ... | true |
52507801aed78cb924ca44b7e68bcdd8ef3899ba | Ruby | beeplove/chess | /lib/piece/king.rb | UTF-8 | 145 | 2.609375 | 3 | [] | no_license | class King < Piece
def name
"K"
end
def potential_moves
potential_diagonal_moves(true) + potential_straight_moves(true)
end
end
| true |
239c63cdc7d60b20acb0922fb5d87fb790c7805b | Ruby | EricRicketts/LaunchSchool | /SQL/DatabaseApplications/interacting_with_a_database_in_code/pg_statements.rb | UTF-8 | 396 | 2.6875 | 3 | [] | no_license | require 'pg'
conn = PG::Connection.new(dbname: 'rb185')
result = conn.exec("SELECT * FROM films;")
puts
result.values.each do |row|
p row
end
puts
names_and_films = <<SQL_S1
SELECT d.name, string_agg(f.title, ', ') AS "films"
FROM directors AS d
INNER JOIN films AS f
ON d.id = f.director_id
GROUP BY d.name;
SQL_S1... | true |
5e088fd1b99471cb3fa380b09236383c48732e30 | Ruby | SabriH/gitdemo | /reverseZin.rb | UTF-8 | 122 | 2.921875 | 3 | [] | no_license | print'Geef een Zin'
zin = gets()
newZin = newZin.split(/\s/).reverse.join(/\s/)
print 'de nieuwe zin is: ', newZin, "\n"
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.