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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
86c8e8112dc1def153a821853cb11bfc3bf972a6 | Ruby | abillig/rails-activerecord-model-rails-lab-web-0616 | /app/controllers/movie_stats.rb | UTF-8 | 3,130 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'byebug'
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def movie_stats(string)
byebug
page = Nokogiri::HTML(open("https://en.wikipedia.org/wiki/#{string}"))
title=""
directed_by_string = ""
running_time... | true |
6d1dc580ab5a2f11c850eaf6d20d2d0f4bef7231 | Ruby | ananace/ruby-wifi_accessor | /lib/wifi_accessor/data.rb | UTF-8 | 484 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module WifiAccessor
class Network
class Data
attr_reader :used, :total
def initialize(avail: nil, used: nil, total: nil)
@available = avail
@used = used
@total = total
end
def infinite?
total.nil? && @available.nil?
end... | true |
051420ef39dcd6b8a21c5b78a8498cacd25833c7 | Ruby | cschell/adventofcode | /2019/02/puzzle_01.rb | UTF-8 | 565 | 3.21875 | 3 | [] | no_license | codes = File.read("input.txt").split(",").map(&:to_i)
codes[1] = 12
codes[2] = 2
instruction_pointer = 0
loop do
instruction,
parameter_1_idx,
parameter_2_idx,
target_idx = codes[instruction_pointer..(instruction_pointer + 3)]
case instruction
when 1
codes[target_idx] = codes[parameter_1_idx] + cod... | true |
657f119d3f8fca77dc0dd9d1eca1cd626e5fef4c | Ruby | Rem/ruby-objects-belong-to-lab-online-web-sp-000 | /lib/author.rb | UTF-8 | 109 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Author
attr_accessor :name, :genre
def initalize (name,genre)
@name = name
@genre = genre
end
end
| true |
5de2eccddf4d7e48b9dc745ee0143770f3ea891f | Ruby | sprkweb/tardvig | /spec/toolkit_spec.rb | UTF-8 | 1,335 | 2.75 | 3 | [
"MIT"
] | permissive | RSpec.describe Tardvig::Toolkit do
MyClass = Class.new
class MyToolkit < Tardvig::Toolkit
tool :mystring, 'mystring'
tool :myobj, MyClass
tool :myrandom do
rand 1..999_999
end
end
let(:toolkit) { MyToolkit.new }
it 'just gives access to the tools which don\'t have to be initialized' d... | true |
fe8f464044de63ba4b692c87c42e4e6366189fd5 | Ruby | rubiety/goplay | /app/models/game.rb | UTF-8 | 5,751 | 3.15625 | 3 | [] | no_license | # == Game
# Implements a game. Each game has a +white_player+ and a +black_player+
# as well as an associated board size specified when creating the game
# (as Go can be played with whatever board size you want).
#
# === Game States
# In order to keep track of status as the game progresses,
# a basic status system ... | true |
05bcb2a52bce8b6ae92b767480a6f5d754943974 | Ruby | Macaroni2629/Launch-School | /120_object_oriented_programming/120_exercises/inheritance/method_lookup_part_3.rb | UTF-8 | 866 | 4.28125 | 4 | [] | no_license | # Method Lookup (Part 3)
# Using the following code, determine the lookup path used when invoking bird1.color. Only list the classes or modules that were checked by Ruby when searching for the #color method.
module Flyable
def fly
"I'm flying!"
end
end
class Animal
attr_reader :color
def initialize(colo... | true |
ffdfff294f8e7df8bba61c740f90a0a89dbd724b | Ruby | tibbsa/launchschool | /RB120/OOP-Book/lesson_1/my_car.rb | UTF-8 | 1,598 | 4.28125 | 4 | [] | no_license | # https://launchschool.com/books/oo_ruby/read/classes_and_objects_part1#exercises
class MyCar
attr_accessor :color
attr_reader :model
attr_reader :year
attr_reader :speed
def initialize(year, model, color)
@year = year
@model = model
@color = color
@speed = 0
puts "** Your #{self.color}... | true |
1e7d19b122f06f6e24b4a8a9e3c245cf945dbdc1 | Ruby | whaley-ethan/todo-capstone-1.1 | /db/seeds.rb | UTF-8 | 845 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
authors = Author.create(
[
{ name: 'Jack London' },
{ name: 'Jane Austen' }
]
)
TodoItem.create(
[
{
author: authors.first,
title: 'Explore the wilds',
description: 'I want to get more in touch with nature so that I can write better novels'
},
... | true |
8bf1a3d77500b7a6db1e7b1f1cc65437124fe5d0 | Ruby | Vignesh11/Ruby | /functions.rb | UTF-8 | 140 | 3.421875 | 3 | [] | no_license | def add(num1,num2)
return num1 + num2
end
puts add(1,2).to_s
#pass by value
def change(x)
x= 5
end
x =1
change(1)
puts x
| true |
f40a1b3cfb6267ebc4c935823fed76672b19233d | Ruby | vraravam/resource_full | /lib/spec/resource_full/matcher/identified_by_matcher.rb | UTF-8 | 1,064 | 2.703125 | 3 | [
"MIT"
] | permissive | module Spec
module ResourceFull
module Matcher
class IdentifiedByMatcher
def initialize(attribute)
@expected_attribute = attribute.to_sym
end
def matches?(target)
@target = target
actual_attribute = @target.class.resource_identifier
# TODO: D... | true |
9f4a1416dfc0c01f86e1d84b0bc3219a9b365ede | Ruby | akhinchey/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,237 | 3.9375 | 4 | [] | no_license | # split string by space into array with two items
# rejoin in reverse
#
# split again by char
#
# iterate through each char
#
# if statement
# if char is vowel
# elsif char is consonant
# end
#
# rejoing words
def secret_agent_name (name)
vowels = 'aeiou'
consonants = 'bcdfghjklmnpqrstvwxyz'
na... | true |
1e3ed41847a165ed467336755600bfbb31bffe2f | Ruby | matadon/resque-promises | /spec/support/hashlike_mock.rb | UTF-8 | 503 | 3.234375 | 3 | [] | no_license | class HashlikeMock
attr_accessor :base
def initialize
@base = Hash.new
end
def []=(key, value)
@base[key.to_s] = value
end
def [](key)
@base[key.to_s]
end
def delete(key)
@base.delete(key.to_s)
end
def keys
@base.keys
end
def ... | true |
8ae72532658fa48d5d0f4afc2113975ab49fa957 | Ruby | Catherina87/media-ranker | /test/models/user_test.rb | UTF-8 | 2,503 | 2.578125 | 3 | [] | no_license | require "test_helper"
describe User do
describe "validations" do
it "is valid when all fields are present" do
user = users(:user_one)
result = user.valid?
expect(result).must_equal true
end
it "is invalid without username" do
user = users(:user_one)
user.username = nil ... | true |
fc4411f16f6f565dfe47ea485253f9d508fa2b25 | Ruby | progpyftk/learn_to_code_with_ruby_udemy | /Section 9/iterate_over_array.rb | UTF-8 | 677 | 3.828125 | 4 | [] | no_license | fruits = ["apple", "orange", "grape", "Banana"]
i = 0
while i < fruits.length
puts fruits[i]
i += 1
end
i = 0
until i == fruits.length
puts fruits[i]
i += 1
end
# the break keyword - used to stop loops or blocks
i = 0
while i < fruits.length
puts fruits[i]
if fruits[i] == "grape"
puts... | true |
e6b397823142c79dc4843513287e93e4d9832edd | Ruby | taroooyan/twikeshigeter | /config.god | UTF-8 | 720 | 2.703125 | 3 | [] | no_license | ## god -c config.god で起動する.
## godとloop do ... end 以外のブロック処理の相性が悪いらしいので間にforemanを挟むことで回避する.
FILE_PATH = スクリプトのパス
God.watch do |w|
# Godに登録するプロセスの名前
w.name = "twikeshigeter"
w.interval = 10.second
# Godでプロセスを起動する際のコマンド
# "ruby /hello.rb"のように記述する
w.start = "foreman start -d #{FILE_PATH}"
# プロセスを起動する条件の設定
... | true |
cd5abca4a4964e300b916e0b74813394b26023d6 | Ruby | AnkitaTandel/Ruby-Problem-Solving | /String/anagram.rb | UTF-8 | 362 | 3.75 | 4 | [] | no_license | class String
def is_anagram?(str1, str2)
arr1, arr2 = [], []
str1.split('').each do |char|
arr1 << char.ord
end
str2.split('').each do |char|
arr2 << char.ord
end
if arr1.inject(:+) == arr2.inject(:+)
puts 'Anagram'
else
puts 'Not Anagram'
end
end
end
a = Str... | true |
3690fb02ac718540cde9400f0a38c976a4d04278 | Ruby | l4t1n0/hacker101 | /photo_galery/sqlbrute.rb | UTF-8 | 790 | 2.734375 | 3 | [] | no_license | require 'net/http'
require 'cgi'
require 'benchmark'
require 'pry'
url = "35.227.24.107"
character = "abcdefghijklmnopqrstuvyxwzABCDEFGHIJKLMNOPQRSTUVYXWZ0123456789-."
result = ""
placement = 1
while 1
for char in character.split('')
payload = CGI.escape("1 UNION SELECT IF(SUBSTRING(database(),#{placement.... | true |
d406da10a14b73c306ca8cd0bb68c3185d62ae46 | Ruby | Ryhu/mod1project | /app/models/item.rb | UTF-8 | 748 | 2.953125 | 3 | [] | no_license | class Item < ActiveRecord::Base
has_many :inventories
has_many :players, through: :inventories
# attr_accessor :name, :type, :boosts
# def initialize(name, type, boosts)
# @name = name
# @type = type
# #types - equipment - head, body, lower, weapon
# @boosts = boosts_translator(boosts)
# end
... | true |
8e42151d31d13a40f3071d2e81abb60099272a8a | Ruby | dmitryS1666/thinknetica_rep | /less_5/route.rb | UTF-8 | 1,126 | 3.203125 | 3 | [] | no_license | =begin
Класс Route (Маршрут):
-Начальная и конечная станции указываютсся при создании маршрута, а промежуточные могут добавляться между ними.
-Имеет начальную и конечную станцию, а также список промежуточных станций.
-Может добавлять промежуточную станцию в список
-Может удалять промежуточную станцию ... | true |
27625a2a5c99f2608c4fbb4ef602deb728832c1a | Ruby | OndrejKucera/university-assignments | /dpo/dpo1/lib/model.rb | UTF-8 | 2,080 | 3.109375 | 3 | [] | no_license | require_relative "player"
require_relative "world"
class Model
attr_reader :player, :world
def initialize
@player = Player.new
@world = World.new(self)
end
def start_game(name)
@player.name = name
@world.build_all()
@player.location = @world.hash_rooms["Predsin"]
true
end
def ... | true |
04953a65a4264a9f3107b9c71e2992747422c945 | Ruby | lynch16/ttt-with-ai-project-v-000 | /lib/players/human.rb | UTF-8 | 170 | 3.3125 | 3 | [] | no_license | module Players
class Human < Player
def move(array)
puts "Make a move."
value = gets.chomp
value
end
end
end | true |
af010977cc3ab77f1c4e944e0816d4f5631c4091 | Ruby | Edgar-Cortez/AppAcademyOpen | /01-Intro to Programming/06-Hashes/Assignment/11-HashToPairs.rb | UTF-8 | 1,041 | 4.6875 | 5 | [] | no_license | # Write a method hash_to_pairs that takes in a hash and returns a 2D array representing each key-value pair of the hash.
# ---------- Steps ----------
# - create empty array
# - loop through hash and shovel keys and values into another temp array
# - shovel temp array into intitial empty array
# - return array
#... | true |
35937d27522260d40eef0c3d6ad5c5ccc02f0668 | Ruby | empendium/GoalsApp | /app/models/flight.rb | UTF-8 | 377 | 2.53125 | 3 | [] | no_license | class Flight < ActiveRecord::Base
belongs_to :departure_airport,
:class_name => 'Airport',
:foreign_key => 'departure_airport_id'
belongs_to :arrival_airport,
:class_name => 'Airport',
:foreign_key => 'arrival_airport_id'
def duration
distance /... | true |
8832faa2741a264beda8adf884b5d33830c31179 | Ruby | devdiva/itr-ga-labs | /03_ITR_LABS/03_ITR_Labs_3_1_1_coa_arrays.rb | UTF-8 | 926 | 4.25 | 4 | [] | no_license | ################################################################################
#
# Introduction to Ruby on Rails
#
# Code Along Arrays
# Learning Objective: Introduce array syntax.
# Note: This is a cumulative example.
#
################################################################################
#... | true |
0e6ebfc27be8a2fea2f0c6d8b87b976d45e6ad48 | Ruby | aws-oe/killbill-cloud | /kpm/lib/kpm/sha1_checker.rb | UTF-8 | 1,642 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | require 'logger'
require 'yaml'
require 'pathname'
module KPM
class Sha1Checker
def self.from_file(sha1_file, logger=nil)
Sha1Checker.new(sha1_file, logger)
end
def initialize(sha1_file, logger=nil)
@sha1_file = sha1_file
init!
if logger.nil?
@logger = Logger.new(... | true |
e00058fb67ae317e60976f5bfe0084ff9ffd11b4 | Ruby | kimchikimchi/ruby | /rubyprograms/program15.rb | UTF-8 | 109 | 3.40625 | 3 | [] | no_license | # program16.rb
list = []
[1,2,3,4].each do |i|
list << i * 2
end
puts list.inspect # => [2, 4, 6, 8] | true |
61d1d5db804c8edc985cedbe3b3e134e8ae0f866 | Ruby | adelciotto/lisp-rb | /src/types/expression.rb | UTF-8 | 797 | 2.78125 | 3 | [] | no_license | class Expression
attr_accessor :type, :children, :symbol, :enhancements
TYPES = {
default: 'Exp',
predicate: 'Predicate',
var_def: 'Vardef',
var_set: 'Setf',
func_def: 'Funcdef',
lambda: 'Lambda',
var_let: 'Let',
func_let: 'Flet',
builtin: 'Builtin',
eval: 'Eval',
quote:... | true |
c77187d3c6573a39355818f3ebe472b5cc657214 | Ruby | GersonRevatta/algoritmo | /anagrama.rb | UTF-8 | 316 | 3.875 | 4 | [] | no_license | class Anagrama
def calculate str_one, str_two
if str_one.downcase == str_two.downcase
p 'No es un anagrama'
else
p (str_one.downcase.chars.sort.join == str_two.downcase.chars.sort.join) ? 'Es un anagrama' : 'no es un anagrama'
end
end
end
anagrama = Anagrama.new
anagrama.calculate('roma', 'roma')
| true |
919980af0fb6e3da27d7c5b9c7823808efbc72af | Ruby | ioquatix/geospatial | /lib/geospatial/map/index.rb | UTF-8 | 1,818 | 2.640625 | 3 | [
"MIT"
] | permissive | # Copyright, 2016, by Samuel G. D. Williams. <http://www.codeotaku.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use... | true |
dc22000f1b3cc055122fa98586581dfa4e34a4a2 | Ruby | railsfactory-meera/Contribute | /lib/number_cruncher.rb | UTF-8 | 373 | 3.390625 | 3 | [
"MIT"
] | permissive | require "number_cruncher/version"
module NumberCruncher
def self.crunch(pattern)
value = pattern.gsub(/[^-0-9]/, ',').split(',').reject(&:empty?)
result = 0
value.inject(0) do |a,b|
if b.to_i.positive? == true
result = a.to_i + b.to_i
else
raise "Please enter only positive v... | true |
4c54be9feb1104d52509f96edf47e83806ce23bc | Ruby | indy/ignite | /lib/ignite/string_additions.rb | UTF-8 | 312 | 3.421875 | 3 | [] | no_license |
class String
# converts SomeStringLikeThis to some_string_like_this
def camel_to_underscore
self.gsub(/[A-Z]|[0-9].*/) { |m| '_' + m.downcase }[1..-1]
end
# converts some_string_like_this to SomeStringLikeThis
def underscore_to_camel
self.split('_').map{ |w| w.capitalize }.join
end
end
| true |
98d9240d8248184dce58346cb7df1d6692c1df0f | Ruby | pradeepmakkuva/Ruby-Learning | /rna_transcription.rb | UTF-8 | 687 | 3.203125 | 3 | [] | no_license | class Complement
#Declaring the complementories in the hashmap
@inputHash=Hash["G" => "C", "C" => "G","T" => "A", "A" => "U"]
def self.of_dna (input)
puts "Input received::::#{input}"
#Looping the number of lettres in the input
#and adding its RNA by based on the
#complementories configured
@rna=""
fo... | true |
5f285132c57610df37ff3782bf5f1cf8abae7a11 | Ruby | tcharfi66/programming-univbasics-4-simple-looping-lab-wdc01-seng-ft-082420 | /lib/simple_loops.rb | UTF-8 | 508 | 3.9375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Write your methods here
def loop_message_five_times(message)
ctr = 0
while ctr < 5 do
puts message
ctr+= 1
end
end
def loop_message_n_times(message,n)
ctr = 0
while ctr < n do
puts message
ctr+= 1
end
end
def output_array(message)
ctr = 0
while ctr < message.length do
puts ... | true |
54b8dee00ea810cb340183049a1401b42265a3f0 | Ruby | conormcd/ruby-docs-samples | /storage/buckets.rb | UTF-8 | 9,033 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Copyright 2016 Google, Inc
#
# 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 law or agreed to in writing, ... | true |
51e8512c957f44f00e365415a5815703426d07b3 | Ruby | steverandy/concen | /test/unit/page_test.rb | UTF-8 | 6,394 | 2.734375 | 3 | [
"MIT"
] | permissive | require "test_helper"
class ConcenTest < ActiveSupport::TestCase
def setup
DatabaseCleaner.clean
end
test "can create page" do
page = Fabricate "concen/page"
refute_nil page.id
end
test "can create child page" do
page = Fabricate "concen/page"
child_page = page.children.create :titl... | true |
2ca6cab3cd305a69f0feef1c337ef3269a85d860 | Ruby | mattlazris/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 840 | 3.015625 | 3 | [] | no_license | require "json"
require "open-uri"
class GamesController < ApplicationController
def new
@game = params[:games]
@letters = (0...10).map { ("a".."z").to_a.sample.upcase }
end
def score
@letters = params[:letters].split(" ")
url = "https://wagon-dictionary.herokuapp.com/#{params[:attempt]}"
word... | true |
ee53bc6ef587478287af5f25b57f9287c807972c | Ruby | samkahchiin/Advent-of-code | /2015/day_9/solution.rb | UTF-8 | 1,161 | 3.796875 | 4 | [] | no_license | require 'byebug'
## Using brute-force and permutations
class File
INSTRUCTION_REGEXP = /(\w+) to (\w+) = (\d+)/
attr_reader :instructions
def initialize(file_name)
@instructions = []
@contents = File.read(file_name).split("\n")
end
def generate_instructions
@contents.each do |line|
info =... | true |
afdf9ff3bd9536ed10d219a5e61f6c7296ad6089 | Ruby | stbarrientos/arachnid | /spider.rb | UTF-8 | 2,322 | 3.875 | 4 | [] | no_license | require 'rest-client'
# require_relative 'database'
class Spider
def initialize(url)
@url = url
end
def get_html
RestClient.get @url
end
# General Approach: compare every word in html to every word in tags
# We can skip over all html elements, (anything between <>), which will make parsing much ... | true |
8ba071ed6e525c764cc767db0a0baa95d86878d6 | Ruby | LambertoD/odin_curricullum | /ruby101/english_number.rb | UTF-8 | 2,480 | 3.9375 | 4 | [] | no_license |
require 'minitest/autorun'
class TestEntries < Minitest::Unit::TestCase
def setup
@english_numberer = EnglishNumber.new
# @number = 0
# while (true)
# puts "Please enter a number between 1 and 999"
# @number = gets.chomp.to_i
# unless @number < 1 && @number > 999
# b... | true |
12cfc47869aebb2f64b93f4466733528c1b37324 | Ruby | afang24/COEN164L | /lab1/duplicate.rb | UTF-8 | 75 | 3.140625 | 3 | [] | no_license | def str_dup(n, text)
n.times {print text + " "}
end
str_dup(5, "click")
| true |
9ec1420a1a3575f1616d69890d81f647817e111d | Ruby | lfrancoeur/Ruby | /The_emopy?_and_nil>_Methods_on_an_Array.rb | UTF-8 | 432 | 4.125 | 4 | [] | no_license | puts [1, 2, 3].empty?
puts [].empty? #finds out if an array is empty
puts [].length == 0 #is the same as the above (finds out if an array is empty)
puts [false, false, false].nil? #finds out if the the array is nil
#an example to check for a nil with an array
letters = ("a".."j").to_a #to_a converts it to an array
ch... | true |
8b5a313402189b4cb530ecd7b2d4e459f8295267 | Ruby | JaniceYR/002_aA | /w1d3/recursion.rb | UTF-8 | 4,207 | 3.84375 | 4 | [] | no_license | def range_recursive(start_pos, end_pos)
return [] if end_pos - 1 <= start_pos
[start_pos + 1] + range_recursive(start_pos + 1, end_pos)
end
def range_iterative(start_pos, end_pos)
(start_pos + 1...end_pos).to_a
end
# p range_recursive(2, 10)
def sum_recursive(arr)
return 0 if arr.empty?
arr.pop + sum_recu... | true |
dda97e80059ba0618e25802d407728a7930f4a39 | Ruby | oneamitj/CF-intern | /hello_world.rb | UTF-8 | 305 | 3.96875 | 4 | [] | no_license | # arr = ["this", "can", "be", 1, nil, true, :sym]
# print arr[6]
# arr.map do |val|
# puts val == :sym
# end
# print arr[-1]
# dict = {"one" => 1, :two => 2, 5 => "five"}
# dict.each do |key, val|
# puts "#{key} => #{val}"
# end
def calc(a,b,c)
(a+b)*c
end
puts calc(1,2,3)
puts calc("a","b",3) | true |
58d7d546b04fc3afc7948590166bd9df9661aa69 | Ruby | HUFGhani/learning-ruby | /Introduction to Ruby/Strings and String Methods 15:16.rb | UTF-8 | 68 | 2.8125 | 3 | [] | no_license | #!/usr/bin/ruby -w
name = "hamza".downcase
name.reverse
name.upcase
| true |
098f627e27b7f70a06e4a460df3f76dcc7302e51 | Ruby | CarePlus/yard-rest-plugin | /lib/yard-rest/rest_filters.rb | UTF-8 | 324 | 2.59375 | 3 | [] | no_license | module RestFilters
def index_objects(list)
list = reject_without_resource(list)
list
end
def reject_without_resource(list)
list.delete_if { |object|
if [:class].include?(object.type)
object.meths.detect{|x| x.has_tag? :resource}.nil?
else
true
end
}
end
end... | true |
64c4bd2d0bb639f0c9ac824b36fe41df79c9569b | Ruby | Kremenchuk/PPKremenchuk | /app/models/gallery.rb | UTF-8 | 874 | 2.53125 | 3 | [] | no_license | class Gallery < ActiveRecord::Base
default_scope { order(horizontal: :desc) }
def next
Gallery.where("created_at < ?", self.created_at).where("image_folder = ?", self.image_folder).order(:time).first
end
def previous
Gallery.where("created_at > ?", self.created_at).where("image_folder = ?", self.image... | true |
c7c6d133e506f6470ca341ca821eb2fd5563b09b | Ruby | jodell/babushka | /lib/babushka/version_str.rb | UTF-8 | 2,194 | 3.203125 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Babushka
class VersionStr
include Comparable
attr_reader :pieces, :operator
GemVersionOperators = %w[= == != > < >= <= ~>].freeze
def <=> other
other = other.to_version if other.is_a? String
max_length = [pieces.length, other.pieces.length].max
(0...max_length).each do |inde... | true |
f53ec728af3c8f9aa7b925ed93254a30998d6263 | Ruby | grabarzstg/Ruby | /Inne/newton_taylor.rb | UTF-8 | 168 | 3.265625 | 3 | [] | no_license | class Xn
def initialize (num, x, y, z)
@num = num
@x = x
@y = y
@z = z
end
end
puts "podaj ilosc wezlow"
ile = gets.to_i
for i in 1..(ile)
puts "ohai"
end
| true |
494baa53c5ff5d1764695fceea46c8aa88be514d | Ruby | baccigalupi/vets-api | /app/models/form_profile.rb | UTF-8 | 3,769 | 2.5625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # frozen_string_literal: true
# TODO(AJD): Virtus POROs for now, will become ActiveRecord when the profile is persisted
class FormFullName
include Virtus.model
attribute :first, String
attribute :middle, String
attribute :last, String
attribute :suffix, String
end
class FormAddress
include Virtus.model
... | true |
78bbd4bd71d440667db7b2cce6f2583908b1b377 | Ruby | bryanaka/interview-questions | /ruby/fibonacci/fibonacci_cli.rb | UTF-8 | 403 | 3.03125 | 3 | [] | no_license | #!/usr/bin/ruby
require File.expand_path '../fibonacci', __FILE__
require 'optparse'
default_opts = { :file => ARGV[0] }
options = {}
OptionParser.new do |opts|
opts.on("-f", "--file [FILE_NAME]", String, "file name to read in") do |f|
options[:file] = f
end
end.parse!
options = default_opts.merge options
File... | true |
85215597961723f1e37100ffa4d564ad1797bfdb | Ruby | maxximus87/Game | /board_test.rb | UTF-8 | 2,387 | 3.328125 | 3 | [] | no_license | require "minitest/autorun"
require_relative "board.rb"
class TestBoard < Minitest::Test
def test_new_board
board = Board.new()
assert_equal(["","","","","","","","",""], board.gameboard)
end
def test_for_update_board
board = Board.new()
board.update("0", "x")
assert_... | true |
107372861ffede9e28c35766574f9d3d25fe98ea | Ruby | fsfiii/hivemeta | /lib/hivemeta/record.rb | UTF-8 | 1,072 | 2.984375 | 3 | [] | no_license | module HiveMeta
class FieldCountError < StandardError ; end
class Record
def initialize(line, table, opts = {})
@fields = line.chomp.split(table.delimiter, -1)
if @fields.size != table.columns.size
raise FieldCountError if not opts[:ignore_field_count]
end
@table = table
e... | true |
b1706232da25bc00e8db2a4431ff0460f3791740 | Ruby | uskey512/AtCoder | /ABC/169/d.rb | UTF-8 | 195 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'prime'
factors = gets.to_i.prime_division
result = 0
factors.each do |i|
a = 1
while a <= i[1]
i[1] -= a
a += 1
result += 1
end
end
puts result
| true |
5da3844c958cdd41d18e3224e658ac116e5d6973 | Ruby | entelo/ruby_omnomnum | /test/memory_test_numerizer.rb | UTF-8 | 101 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | require 'numerizer'
p Numerizer.numerize('two hundred')
100.times{Numerizer.numerize('two hundred')}
| true |
8975d07616c4171124a7cd5cb0275ecb5e43dc75 | Ruby | nightangelblade/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 3,797 | 4.3125 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:create an empty hash
# add a create list method(food_str)
# .split it
# set default to 1 test 0 too
#loop through list
# print the list to the console [can you use one of your other methods ... | true |
32dd4dbe9e74fcd97b86a909400cff8661e1365b | Ruby | croelanjr/Ruby-UPC2014-Unidad05 | /minas.rb | UTF-8 | 2,421 | 3.828125 | 4 | [] | no_license | #encoding:UTF-8
=begin
La Marina de Guerra del Perú desea un simulador de búsqueda de minas.
Para ello tiene un campo de 4 x 4 posiciones marcadas como
[0,0][0,1][0,2][0,3]
[1,0][1,1][1,2][1,3]
[2,0][2,1][2,2][2,3]
[3,0][3,1][3,2][3,3]
En dicho campo se colocará una mina cuya posición se pedirá por
consola us... | true |
da3f7aaeeb7027f131457bdaa13627f285434f94 | Ruby | kgardnr/blackjack | /blackjack.rb | UTF-8 | 1,996 | 3.953125 | 4 | [] | no_license | # 5. Ask Player if they want to hit or stay
# 6. If stay, Dealer's turn
# 7. If hit, give Player another card
# 8. Check if Player's cards are above 21; if so, Player busts
# 9. If Player's cards are below 21, ask if they want to hit or stay
# 10. Do this until they stay
# 11. If Dealer's cards < 14, hit
# 12. Otherwis... | true |
edb26bd52430442a7ab2e7daaeda283daab5c68b | Ruby | RobertRodes/RB101 | /small_problems/easy_7/ex_9.rb | UTF-8 | 206 | 3.65625 | 4 | [] | no_license | def multiply_all_pairs(arr1, arr2)
result = []
arr1.each do |value1|
arr2.each do |value2|
result << value1 * value2
end
end
result.sort
end
p multiply_all_pairs([2, 4], [4, 3, 1, 2]) | true |
391bd17bd8f79667e19645a7bdecd24e353a5200 | Ruby | Lawrenccee/LeetCode-Problems | /238_product_of_array_except_self.rb | UTF-8 | 329 | 3.015625 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[]}
def product_except_self(nums)
result = Array.new(nums.length, 1)
lower_prod = 1
upper_prod = 1
nums.each_with_index do |num, idx|
result[idx] *= lower_prod
result[-(idx+1)] *= upper_prod
lower_prod *= num
upper_prod *= nums[-(idx+1)]
end
r... | true |
c238bfb7ad58568ce4919fc97382e95c39c296f6 | Ruby | GreenRabite/advent-of-code-2019 | /ruby/day08/part-1/answer.rb | UTF-8 | 453 | 2.953125 | 3 | [] | no_license | file = File.read("./input.txt")
# image is 25px x 6
sif = file.split('').map(&:to_i)
results = []
sif.each_slice(150) do |row|
results << row
end
min=nil
noncorrupted_set = nil
results.each do |result|
if min.nil?
noncorrupted_set = result
min = result.count(0)
end
if result.count(0) < min
nonco... | true |
8846064151dacd361391877ede6aee3f0bda1325 | Ruby | cbeaujoin/mxl4r | /musicxml.rb | UTF-8 | 181,316 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'xsd/qname'
# {}dynamics
# p - Empty
# pp - Empty
# ppp - Empty
# pppp - Empty
# ppppp - Empty
# pppppp - Empty
# f - Empty
# ff - Empty
# fff - Empty
# ffff - Empty
# fffff - Empty
# ffffff - Empty
# mp - Empty
# mf - Empty
# sf - Empty
# sfp - Empty
# sfpp - Empty
# fp - E... | true |
3ad2c30b9ff78ee1046d917153a94fbb7fe36966 | Ruby | dhoangk07/ruby-base-exercise | /app/helpers/exercise4.rb | UTF-8 | 10,455 | 3 | 3 | [] | no_license | activities = Activity.where(user_id: b.select(:id))
<% @activities.each do |activity| %>
<%= activity.inpect%>
<% end%>
border-radius: 5px;
font-family: inherit;
font-size: 14px;
height: 42px;
width: auto;
<p style="width: 95px">
hash = { 0 => 'ze... | true |
38aedbf9929902b9fbce9e137200bcd82906ea9b | Ruby | google-code/aerosol | /Demo/demoList.rb | UTF-8 | 988 | 2.546875 | 3 | [] | no_license | # Copyright:: Copyright (c) 2008 Howling Moon Software
WIDTH = 800
HEIGHT = 600
AS.open_screen(WIDTH, HEIGHT, :vbl_sync => true)
AS.clear_color(1, 0, 0, 0)
AS.clear_screen
AS.clear_color(0, 0, 0, 0)
class DemoState < AS::GameState::TickLimitedState
def switch_state(state)
DemoState.new(state).run
end
def ... | true |
03b3b8599bd4603c36fbd604c5a8dbb29eada9da | Ruby | mlibrary/deepblue | /app/services/deepblue/find_and_fix_curation_concern_filter_date.rb | UTF-8 | 2,635 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
class Deepblue::FindAndFixCurationConcernFilterDate
attr_reader :begin_date, :end_date
def to_datetime( date, format: nil )
# TODO: see ReportHelper.to_datetime
return nil if date.blank?
date = date.strip
date = date.downcase
if format.nil?
case date
... | true |
6752a102ef000ca91dbf995e47f08bd2b126bf8e | Ruby | TSSaint/ruby-misc | /ruby_conditionals_tests.rb | UTF-8 | 2,713 | 4.59375 | 5 | [] | no_license | # write a method to check if a number is divisible by 5
def isdivby5(num)
if num % 5 == 0
answer = true
else
answer = false
return answer
end
end
# puts isdivby5(10)
# puts isdivby5(100)
# puts isdivby5(17)
# puts isdivby5(5.01)
# write a method that takes in a number and returns true ... | true |
8544d992fd5096f3b7cc982484bde7890d25487c | Ruby | Chuckatmaine/aup | /prog.rb | UTF-8 | 112 | 2.78125 | 3 | [] | no_license | names = ["chuck", "susan", "David", "Susan", "chuck"]
names.uniq.each do |name|
puts name
end
puts
puts names
| true |
23ae05c91458d3042bb400db0bf4b783473abbb2 | Ruby | rab/adventofcode2016 | /day12.rb | UTF-8 | 3,941 | 3.359375 | 3 | [
"MIT"
] | permissive | # --- Day 12: Leonardo's Monorail ---
#
# You finally reach the top floor of this building: a garden with a slanted glass ceiling. Looks
# like there are no more stars to be had.
#
# While sitting on a nearby bench amidst some tiger lilies, you manage to decrypt some of the
# files you extracted from the servers downst... | true |
81e07a23e08d9136b0b5cda5c3d914e916c79d95 | Ruby | amvasilyev/2020-autumn-ruby | /2020-10-22-lecture/bin/using_comparable_mixin.rb | UTF-8 | 526 | 3.765625 | 4 | [
"Apache-2.0"
] | permissive |
class SizeMatters
include Comparable
attr_reader :str
def initialize(str)
@str = str
end
def inspect
@str
end
def <=>(other)
str.size <=> other.str.size
end
end
s1 = SizeMatters.new("Z")
s2 = SizeMatters.new("YY")
s3 = SizeMatters.new("XXX")
s4 = SizeMatters.new("WWWW")
s5 = SizeMatters... | true |
d6472322e1eb1e898da1574306356ecc8bfe44a7 | Ruby | JoelQ/build_you_a_list_ruby | /spec/list_spec.rb | UTF-8 | 3,362 | 3.484375 | 3 | [] | no_license | require "list"
describe List do
describe "#inspect" do
it "shows empty brackets for an empty list" do
expect(List.empty.inspect).to eq "[]"
end
it "shows a value in brackets for a single item" do
list = List.empty.prepend 1
expect(list.inspect).to eq "[1]"
end
it "shows brack... | true |
99e497c4fecf5759f08bd8bb1d50710d46cd08c5 | Ruby | tnataly/anagram | /app/models/word.rb | UTF-8 | 1,069 | 3.5625 | 4 | [] | no_license | class Word < ActiveRecord::Base
before_save :add_letters
# Populates letters column based on the word's text attribute
def add_letters
characters = self.text.chars
alphabetized_characters = characters.sort
self.letters = alphabetized_characters.join
end
# It takes an array of letters & reverse it
def self.revers... | true |
cd013e2c506316eb662b507ca3374d6182aa25fb | Ruby | lbsambo547/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,248 | 3.9375 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
sum = 0
arr.each do |n|
sum = sum + n
end
return sum
end
def max_2_sum arr
return 0 if arr.size == 0
return arr[0] if arr.size == 1
arr.sort!
arr.reverse!
sum = 0
sum = arr[0] + arr[1]
return... | true |
604e3fb00322cae97994aa75c05a2eb20f6335a5 | Ruby | mumuki/mumuki-xgobstones-runner | /lib/stones_spec/string.rb | UTF-8 | 204 | 3.28125 | 3 | [
"MIT"
] | permissive | class String
def start_with_lowercase?
first_letter = self[0]
first_letter.downcase == first_letter
end
def include_any?(other_strs)
other_strs.any? { |other| include? other }
end
end | true |
22c5e408e0e845fafd2dbec3ebcd688ed7c93d6a | Ruby | DingChiLin/RubyExercise | /BasicLanguageProperty/logic.rb | UTF-8 | 238 | 2.9375 | 3 | [] | no_license | total = 200
if total > 150
puts "Large"
elsif total < 110
puts "small"
else
puts "NO"
end
puts "AAAAA" if total > 80
aaa = true
puts "aaa" if aaa
phone = "123-456-7890"
if phone =~ /(\d{3})-(\d{3})-(\d{4})/
ext = $3
end
puts ext
| true |
d1674c6a406270a6d33f2c19a0674842f21cd6ad | Ruby | se3000/whiteboard | /spec/models/post_spec.rb | UTF-8 | 2,743 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Post do
describe 'associations' do
it { should belong_to(:standup) }
it { should have_many(:items) }
it { should have_many(:public_items) }
end
describe "validations" do
it { should validate_presence_of(:standup) }
it { should validate_presence_of(:title) }
... | true |
99015ff49c2d7c7389e81c21b5ad824543c5fa7c | Ruby | grindars/yayjs | /lib/yayjs/phi_node.rb | UTF-8 | 421 | 2.59375 | 3 | [
"MIT"
] | permissive | module YAYJS
class PhiNode
attr_reader :map
def initialize(map, target)
@map = map
@target = target
@map.freeze
@target.freeze
freeze
end
def args
[]
end
def results
[ @target ]
end
def inspect
map = @map.to_a.map { |(key, value)| "... | true |
fe404b53be7031c1f8ade91d03c0c28de097e55a | Ruby | jmrada14/playingAround | /ciphers/rot13.rb | UTF-8 | 81 | 2.90625 | 3 | [] | no_license | def rot13 text
text.tr 'A-Za-z', 'N-ZA-Mn-za-m'
end
puts rot13("hello world")
| true |
4860a7ba33a21b5118bc5982384efd61fd9a2fbe | Ruby | tijmenb/govuk-cli | /lib/govuk/cli.rb | UTF-8 | 1,791 | 2.5625 | 3 | [
"MIT"
] | permissive | require "govuk/command"
require "govuk/docs"
require "govuk/http"
require "govuk/ssh"
require "govuk/string_extension"
module GOVUK
class CLI < Thor
desc "ssh <APPLICATION> <ENVIRONMENT>", "SSH into the server that <APPLICATION> lives on in <ENVIRONMENT> (integration by default)"
def ssh(app_name, environmen... | true |
a026403447e6d346e33194173c6da304c2b189ad | Ruby | OsamaOmar322/ReCode-Ruby-Projects | /exam_11.rb | UTF-8 | 856 | 4.9375 | 5 | [] | no_license | # You will write two methods:
# You will write a method is_prime? that takes in a number
# This method returns a boolean, indicating whether the number is prime.
# Note: A prime number is only divisible by 1 and itself.
# The method pick_primes that takes in an array of numbers
# The method should return a new array... | true |
e50885b7525a7ffc38f68d3f2c639198bb12cec8 | Ruby | eneagoe/project-euler | /ruby/solutions/problem69.rb | UTF-8 | 570 | 2.875 | 3 | [] | no_license | $LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib")
require "prime"
# Solves http://projecteuler.net/problem=69
class Problem
def self.solution_1
n = 1_000_000
primes = Prime.lazy
i, p, current_solution = 0, 1, 1
loop do
p *= primes.next
break if p >= n
i += 1
current_solu... | true |
a30bd2d6994dfae258f4fd4af595fadf86b13e58 | Ruby | mdsol/mauth-client-ruby | /lib/mauth/request_and_response.rb | UTF-8 | 7,617 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'openssl'
require 'addressable'
module MAuth
# module which composes a string to sign.
#
# includer must provide
# - SIGNATURE_COMPONENTS OR SIGNATURE_COMPONENTS_V2 constant - array of keys to get from
# - #attributes_for_signing
# - #merge_headers (takes a Hash of he... | true |
7c652756cdbca23be92ec6d3c9c7ba1407515577 | Ruby | jnewland/cassandra_object | /test/one_to_many_associations_test.rb | UTF-8 | 5,655 | 2.515625 | 3 | [
"ISC"
] | permissive | require 'test_helper'
class OneToManyAssociationsTest < CassandraObjectTestCase
context "A customer with no invoices added to its invoice association" do
setup do
@customer = Customer.create :first_name => "Michael",
:last_name => "Koziarski",
... | true |
c76bf1cbe9feaf0e8c7a7e3daf8b2e2c674a1226 | Ruby | kongkongry/AndroidDemoInOtherLanguages | /RubyMotionAndroidDemo/app/country_list_activity.rb | UTF-8 | 1,515 | 2.625 | 3 | [] | no_license | class RequestListener
attr_accessor :activity
def initialize(activity)
@activity = activity
end
def onResponse(json)
@activity.update_display(json)
end
end
class ClickListener
attr_accessor :activity
attr_accessor :items
def initialize(activity, items)
@activity = activity
@items = ... | true |
1055bd4708bf019d2ed87872c77b0035b6ebb8df | Ruby | ikozharov/ruby-angular-example | /app/controllers/main_controller.rb | UTF-8 | 498 | 2.515625 | 3 | [
"MIT"
] | permissive | class MainController < ApplicationController
def index
catrgories = Category.where(parent_id: nil)
@catrgories = catrgories.map { |category| get_children(category) }
@users = User.all
end
private
def get_children(category)
children = category.children
result = category.serializable_ha... | true |
02f958896fb864c1580aba02562645bf40e92e9c | Ruby | ELK75/connect_four | /spec/connect_four_spec.rb | UTF-8 | 2,592 | 3.359375 | 3 | [] | no_license | require 'rspec'
require_relative '../connect_four'
describe 'Board' do
before do
@board = Board.new
# used to create a blank board
@test_board = []
7.times{@test_board << Array.new([0] * 7)}
end
describe 'place_piece' do
context 'blank board' do
before do
@test_board[6][1] = 1
@board.place_pi... | true |
63cc924f332430cec5d15e53c8eb8ce164c30c59 | Ruby | LaunchPadLab/decanter | /lib/decanter/parser/phone_parser.rb | UTF-8 | 326 | 2.59375 | 3 | [
"MIT"
] | permissive | module Decanter
module Parser
class PhoneParser < ValueParser
REGEX = /\d/
allow Integer
parser do |val, options|
raise Decanter::ParseError.new 'Expects a single value' if val.is_a? Array
next if (val.nil? || val === '')
val.scan(REGEX).join.to_s
end
end
en... | true |
e0334609db9193e1fe06b8c21b84e32096340ba8 | Ruby | mejonyu/Rails-Practice-Code-Challenge-Travelatr | /app/models/destination.rb | UTF-8 | 464 | 2.734375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Destination < ApplicationRecord
has_many :posts
has_many :bloggers, through: :posts
def most_recent
self.posts.min_by(5) { |post| post.created_at }
end
def featured_post
self.posts.max_by { |post| post.likes }
end
def avg_age
sum = 0
blogger_arr = se... | true |
bbaae0a11e872a390658ce28a12456215678b1df | Ruby | panorama-ed/unique_attributes | /lib/unique_attributes.rb | UTF-8 | 4,437 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "unique_attributes/version"
require "active_support/concern"
# UniqueAttributes provides the unique_attribute method to assign a unique
# attribute to the given model, using the passed block.
# Example: unique_attribute :code { SecureRandom.random_number(1000) }
module UniqueA... | true |
b3097d1bc90b1a360b7f6792e5e693be6ac1cdee | Ruby | akilchomoko/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 1,384 | 3.234375 | 3 | [] | no_license | require 'open-uri'
class GamesController < ApplicationController
def new
@letters = generate_grid(10)
end
def score
@answer = params["answer"]
@grid = params["grid"].split(" ")
@result = run_game(@answer, @grid)
# raise
end
private
def generate_grid(grid_size)
# TODO: generate ra... | true |
b1116a40a9660e614d4286a2b7f6d0241cbec80c | Ruby | DanielMolina24/ics.bc.s18 | /week1/ch02/hours_in_year.rb | UTF-8 | 85 | 3.1875 | 3 | [] | no_license | puts"For a regular year it is:"
puts 365*24
puts"For a leap year it is:"
puts 366*24
| true |
42bc171c03eedf49f7a71baf88fef77c87fea683 | Ruby | TomoMayumi/contest | /atcoder/indeednow-finalb-openE.rb | UTF-8 | 331 | 2.765625 | 3 | [] | no_license | N=gets.to_i
BIT=[0]*(N+1)
def add x,v;(BIT[x]+=v;x+=x&-x)while BIT[x];end
def sum x;s=0;(s+=BIT[x];x&=x-1)while x>0;s;end
H=gets.split.map{|i|[i.to_i]}
H.sort_by{|i,|-i}.each.with_index(1){|i,j|i<<j}
if H.map{|i,j|i}.uniq.size != N
p(-1)
else
ans=0
H.each{|i,j|
ans+=sum(j)*i
add(j,1)
}
... | true |
1f2244cd33845bb1ceae708c59effcaaecf78c18 | Ruby | SarahBunker/rb101_programming_foundations | /small_problems/easy8/palindromic.rb | UTF-8 | 1,758 | 4.3125 | 4 | [] | no_license | =begin
in: string
out:array of substrings
rules:
substrings included in array are palidromes from original array
all palidromes are included
palidrome:
same sequence forward and backward
duplicate palidromes included multiple times
values arranged in array based on where the palidrome started
arrange... | true |
bba834b61a96f8aa7881e6d513af0431bc48b451 | Ruby | cecomp64/world-cup | /app/models/round.rb | UTF-8 | 2,616 | 3.34375 | 3 | [] | no_license | class Round < ActiveRecord::Base
has_many :groups
has_many :matchups
def group_winner(group)
if(self.name == "GROUP")
return group_winner_group(group)
end
end
def group_runnerup(group)
if(self.name == "GROUP")
return group_runnerup_group(group)
end
end
# First place in group... | true |
5d89389eac09a51fb0fef3d562182d10967a842e | Ruby | granparkrb/paint | /minmin/bin/paint | UTF-8 | 190 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "../lib/paint.rb"
unless ARGV[0] && File.exist?(ARGV[0])
puts "door file not given"
exit 1
end
x = Paint.new(open(ARGV[0]).read)
puts x.brash_size
| true |
021940eb58cebcdace5e4a47257f8da48b639b3e | Ruby | Umakhan/Task_2 | /task_2.rb | UTF-8 | 465 | 2.90625 | 3 | [] | no_license | require 'rubygems'
require 'mechanize'
class ExchangeUSD
attr_reader :dollar, :path
attr_writer :dollar
def initialize
@a = Mechanize.new
@path = 'div.switcher_view.cbr_view table.table.horizontal tbody tr td'
end
def parser
page = @a.get('http://www.raiffeisen.ru/ru/currency_rates/')
review_meta ... | true |
d970b78e3fba7b0cd572e791f2c165a0845d7224 | Ruby | MadiNaf/Tic_tac_toe | /board.rb | UTF-8 | 944 | 3.640625 | 4 | [] | no_license | require 'pry'
require 'boardcase.rb'
class Board
def initialize
a = Hash.new
for i in 1..3
for j in 1..3
a[ i.to_s + j.to_s] = BoardCase.new(i.to_s + j.to_s)
end
end
@grid = a
end
# A method that selects a case by its position and give back a Boardcase type object... | true |
569dfdf945042f2c1707f2f28d7bd17f660e62e9 | Ruby | reinh/nanoc | /lib/nanoc3/filters/colorize_syntax.rb | UTF-8 | 1,631 | 2.8125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Nanoc3::Filters
class ColorizeSyntax < Nanoc3::Filter
DEFAULT_COLORIZER = :coderay
def run(content, params={})
require 'nokogiri'
# Take colorizers from parameters
@colorizers = Hash.new(DEFAULT_COLORIZER)
(params[:colorizers] || {}).each_pair do |language,... | true |
04396944884b12822b8e88fcf6376771156d0e3c | Ruby | malexanders/ruby_fundamentals2 | /exercise5.rb | UTF-8 | 201 | 4 | 4 | [] | no_license | puts "Enter a Temperature in Fareheit (degF)"
temp = gets
def F_to_C (temp)
temp = temp.to_f
y = (temp - 32) * (5.0/9.0)
p "#{temp.round(2)}degF = #{y.round(2)}degC"
end
F_to_C(temp)
| true |
7f9022ab5a1b63557beeb71f95fa4773a92c919f | Ruby | siu/odat2 | /app/reports/report_pdf.rb | UTF-8 | 1,915 | 2.578125 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'prawn'
require 'prawn/format'
require 'prawn/layout'
class ReportPdf < Prawn::Document
def initialize(report)
super()
@report = report
view = @report.configurable_view
@font_size = view.font_size ? view.font_size*0.9 : 12
@border_style = view.table_grid? ? :grid : :u... | true |
cc07126e6722e2af1c3765826ac5a6f439242e6a | Ruby | devrieda/color_conversion | /spec/converters/hsv_converter_spec.rb | UTF-8 | 967 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe HsvConverter do
describe ".matches?" do
it "should match args with hsv hash" do
expect(HsvConverter.matches?(h: 225, s: 73, v: 57)).to be true
end
it "should match args with hsb hash" do
expect(HsvConverter.matches?(h: 225, s: 73, b: 57)).to be true
end... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.