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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ada752c20b7915417b706b3e5b2657d426ac1381 | Ruby | griswold/shinny | /app/helpers/application_helper.rb | UTF-8 | 893 | 2.65625 | 3 | [] | no_license | module ApplicationHelper
def format_activity_time(start_time, end_time)
time_of_day_format = "%-I:%M%P"
start_format = [("%b %-d" unless start_time.to_date == Date.current), time_of_day_format].compact.join(" ")
[start_time.strftime(start_format), "-", end_time.strftime(time_of_day_format)].join(" ")
en... | true |
e126641f8782ddb9125a8e2cafea503b8993fd96 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex0008.rb | UTF-8 | 89 | 2.609375 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 11
number = Math.abs(number) // Java code
| true |
e9fcb26ea3b4f732b9ed938b639b4bc1e9cd6528 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex1306.rb | UTF-8 | 108 | 3.40625 | 3 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 600
"now is the time".sum
"now is the time".sum(8)
| true |
7b97208596d53cebacf4be9961e01ccf83159be3 | Ruby | theldoria/lg-lcd | /lib/lg-lcd/open.rb | UTF-8 | 566 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative 'lib'
module LgLcd
class Open
def initialize connection
@ctx = Lib::OpenByTypeContext.new
@ctx[:connection] = connection
@ctx[:device_type] = Lib::LGLCD_DEVICE_BW
@ctx[:device] = Lib::LGLCD_INVALID_DEVICE
raise "Open by type failes" unless Lib::LGL... | true |
14a240e0dc6c99b28215d087b76979d5378ed301 | Ruby | marioatpb/advent_of_code | /2016/13/run.rb | UTF-8 | 372 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'maze'
input = File.read('./input.txt')
ad = Advent::Maze.new(input)
s = ad.steps([31,39])
puts "Steps: #{s}"
ad.debug!
s = ad.steps([31,39], 50)
puts "Locations: #{s}"
# 473 is too high - Did we include 1,1?
# Off by one?a
#
# 460 is too high
# 448 is too high
#
# Probably nee... | true |
1df5dd1e7382b6371f527274a6bf75a181342a38 | Ruby | nmcguire61/homework_submission | /goingdown/person.rb | UTF-8 | 237 | 2.96875 | 3 | [] | no_license | class Person
attr_accessor :name, :weight, :age
#attr_reader
def initialize(options={})
self.name = options[:name]
self.age = options[:age]
self.weight = options[:weight].to_f
end
#attrs: names, destinations
end | true |
c2e0b87f708416b9ae12533f29257a9aa25c89b1 | Ruby | vinaymehta/Training-2 | /ruby/qestions/firstelement.rb | UTF-8 | 422 | 4.375 | 4 | [] | no_license | =begin
very easy
Return the First Element in an Array
Create a function that takes an array containing only numbers and return the first element.
Examples
get_first_value([1, 2, 3]) ➞ 1
get_first_value([80, 5, 100]) ➞ 80
get_first_value([-500, 0, 50]) ➞ -500
Notes
The first element in an array always has an index... | true |
87cf28e5320d889753a33bef6d989dff03267151 | Ruby | akchalasani1/myruby | /examples/learn/disp_array_hash_dup_count1.rb | UTF-8 | 2,092 | 4.0625 | 4 | [] | no_license | # http://gregpark.io/blog/ruby-group-by/
# you can generally use group_by anywhere you’d be using #each or some iteration.
# The collection of objects that needs grouping (e.g., an array)
# group_by returns a hash where the keys are defined by our grouping rule, and the values are the corresponding objects from our ori... | true |
85f0e6070d795953710b3d2a7c40c4eb2ef563b2 | Ruby | nminhthien/LogivanTest | /lib/product.rb | UTF-8 | 294 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'error'
module LogivanTest
class Product
attr_accessor :code, :name, :price
def initialize(params = {})
raise Error::PARAMS_MUST_BE_HASH unless params.is_a? Hash
@code = params[:code]
@name = params[:name]
@price = params[:price]
end
end
end | true |
ff63de6eba9ffe09b0bc1341b970f1483a7b96e0 | Ruby | spikesp/Ex_programming_foundation | /lesson_3/hard_4.rb | UTF-8 | 290 | 2.9375 | 3 | [] | no_license |
def generate_uuid
arr = ('a'..'z').to_a + ('0'..'9').to_a
uuid = ''
sections = [8, 4, 4, 4, 12]
sections.each_with_index do |section, index|
section.times { uuid += arr.sample}
if index < 4
uuid += '-'
else
break
end
end
uuid
end
p generate_uuid | true |
4bf963dc1d1f292bf483d32459009f05eef92730 | Ruby | harunawaizumi/lean_to_code_with_ruby | /239_Class_Variables_and_Instance_Variables.rb | UTF-8 | 521 | 3.390625 | 3 | [] | no_license | class Pay
@@shared_count = 0 # sigil: class variables
@@maker = "LINE"
# a process runs whenever a new instance is instantiated.
def initialize
@count = 0
@@shared_count += 1
end
def pay
@count += 1
end
def self.shared_count # class methods are prefixed with self keyword.
@@shared_coun... | true |
1221706206356768e6673d53c030b4e26b094bfb | Ruby | russenoire/ls100 | /ruby_basics/hashes/low_med_high.rb | UTF-8 | 110 | 2.875 | 3 | [] | no_license | numbers = {
high: 100,
medium: 50,
low: 10
}
low_numbers = numbers.select {|k,v| v < 25}
p low_numbers
| true |
6cf33d5e64890813366740931a18241d8817211b | Ruby | jaishanker/dbp | /copy/lib/.svn/text-base/sitemap.rb.svn-base | UTF-8 | 8,314 | 2.671875 | 3 | [] | no_license |
class Sitemap
require 'fastercsv'
require 'design.rb'
require 'rubygems'
require 'fileutils'
require 'builder'
require 'logger'
require 'csv'
require 'uri'
@log = Logger.new(File.open('log/sitemap.log','a'))
# This method creates the script that will generate the sitemap xmls for cleartrip
... | true |
92b3ad33774ff327d9137b181e724bcb26bf0112 | Ruby | marinaflores/book-App | /app/controllers/home_controller.rb | UTF-8 | 906 | 2.625 | 3 | [] | no_license | class HomeController < ApplicationController
before_action :authenticate_user!
def index
@weekdays = ["Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira"]
@timetables = ["8:00", "9:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00"]
if params[:new_da... | true |
74fee1cfdcaefdd808f7cc44791ec401366943c4 | Ruby | beliar91/house_hold_chores | /app/models/task.rb | UTF-8 | 720 | 2.78125 | 3 | [] | no_license | class Task < ActiveRecord::Base
#validations:
validates :name, presence: true, uniqueness: true
validates :completion_time, presence: true
#scopes:
scope :by_status, -> (status) {where(complete: status)}
scope :completed, -> {where complete: true}
scope :pending, -> {where complete: false}
#associati... | true |
118ebea8c9bf41d9a1312f4b86320097f4d4c6fd | Ruby | danielacodes/ruby-exercises | /arrays/a_ex3.rb | UTF-8 | 146 | 3.8125 | 4 | [] | no_license | # Write a Ruby program to pick number
# of random elements from an given array.
array = [12,24,56,41]
puts array.sample(2)
puts array.sample(3)
| true |
6aeb4c15a1c8deaec728693444b1209793c37b2c | Ruby | aaltowebapps/team-7 | /server/building.rb | UTF-8 | 1,805 | 2.90625 | 3 | [] | no_license | require_relative 'building_classes.rb'
#
# building.rb
#
# Contains logic for accessing building and floormap data.
#
# Returns all building data in JSON format (see wiki, TODO: URL).
def building_data(timestamp = nil)
# TODO: replace temporary static test data with live data read from DB
data_file = 'building_da... | true |
4033ce87a28bcbe20918a0e06c8620daf6aa27a6 | Ruby | NishantUpadhyay-BTC/demo_one_app | /myprograms/lib/ex32.rb | UTF-8 | 822 | 4.25 | 4 | [] | no_license | the_count = [1,2,3,4,5]
fruits = ['apple','oranges','pears','apricots']
change = [1,'pennies',2,'dimes',3,'quarters']
#this first kind of fo-loop goes through an array
the_count.each do |number|
puts "This is count #{number}"
end
#same as above, but using a block instead
for fruit in fruits
puts "A fruit of type : ... | true |
ff3e1eec28a6eb1f9454c2a8e9bf90163dd801ef | Ruby | pratamashooter/RubyBasic | /RubyFile/RubyFile/latihan_ruby_24.rb | UTF-8 | 118 | 3.21875 | 3 | [] | no_license | # Return Method
def halo
"Saya sedang belajar Ruby"
end
def diBalik
halo.reverse
end
puts halo
puts diBalik | true |
c2d6c08e768d1c859b449658accf7de433c031dd | Ruby | AustenGG/notes | /notes_app/lib/app.rb | UTF-8 | 313 | 2.953125 | 3 | [] | no_license | class Notes
def initialize
@notes = {}
end
def add_note(title, body)
@notes[title] = body
"Your note has been saved!"
end
def print_titles
return @notes.keys
end
def print_notebook
return @notes
end
def view_titles(title)
return @notes[title]
end
end | true |
b226148d187dc74fc44f7bc399b1f0c079a1d507 | Ruby | jdkaplan/advent-of-code | /2019/day11/part1.rb | UTF-8 | 2,378 | 3.75 | 4 | [] | no_license | # frozen_string_literal: true
require 'set'
require_relative 'intcode'
Point = Struct.new(:x, :y) do
def to_s
"(#{x}, #{y})"
end
end
class Hull
def initialize
@panels = Hash.new { |hash, key| hash[key] = :black }
@painted = Set.new
end
def color_at(point)
@panels[point]
end
def paint(... | true |
ff749649f1511e83808ba97a140447af06579567 | Ruby | AlexHandy1/MA_week2_battleships_new | /lib/Board.rb | UTF-8 | 2,486 | 3.59375 | 4 | [] | no_license | require_relative 'ship'
require_relative 'destroyer'
require_relative 'cruiser'
require_relative 'battleship'
require_relative 'submarine'
require_relative 'carrier'
class Board
attr_accessor :grid, :guesses, :fleet, :ship_positions, :game_over
def initialize(size = 10)
@grid = Array.new(size){Array.new(siz... | true |
d21a6605c2e2705568414ddf90140df34993e052 | Ruby | Alex1100/RailsCodingChallenge-master | /spec/cuboid_spec.rb | UTF-8 | 6,283 | 2.859375 | 3 | [
"MIT"
] | permissive | require_relative '../lib/cuboid'
#This test is incomplete and, in fact, won't even run without errors.
# Do whatever you need to do to make it work and please add your own test cases for as many
# methods as you feel need coverage
describe Cuboid do
describe "vertices" do
it "finds all vertices (aka edges)" d... | true |
d2470c361b7196ebe351da4601f7b6d16c03af45 | Ruby | germanescobar/articles | /test/models/article_test.rb | UTF-8 | 653 | 2.734375 | 3 | [] | no_license | require 'test_helper'
class ArticleTest < ActiveSupport::TestCase
test "article is not created without a title" do
article = Article.new
assert_not article.save, "article should not be created without a title"
end
test ".word_count returns the correct number of words" do
article = Article.new(title:... | true |
935b10d1c88956a8efff46638b985edf73639a0a | Ruby | ivanvc/pft | /spec/base_spec.rb | UTF-8 | 1,755 | 2.625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/../lib/pft.rb'
describe "Pft::Base" do
it "should raise an error with no arguments" do
lambda { Pft::Base.tweet.should_not }.should raise_error("Please provide a message")
end
it "should respond with the version" do
Pft::Base.version
end
it "should open... | true |
f31b456f2ff0b56596fa4cc42af9b9cd470ee013 | Ruby | marksingh910/launchschool | /prep_course/ruby_book_exercises/exercises/exercises_15.rb | UTF-8 | 449 | 3.546875 | 4 | [] | no_license | hash1 = {shoes: "nike",
"hat" => "adidas",
:hoodie => true}
hash2 = {"hat" => "adidas",
:shoes => "nike",
hoodie: true}
if hash1 == hash2
puts "These hashes are the same!"
else
puts "These hashes are not the same!"
end
# I thought it would say they are not the same. T... | true |
3ea702cc0841a9bad1da83ba3dc77ae0075f8e42 | Ruby | Ma9sha/chitter-challenge | /spec/chitter_spec.rb | UTF-8 | 551 | 2.921875 | 3 | [] | no_license | describe '.all' do
it 'returns names and message of chitters' do
posts = Peeps.all
expect(posts[0].name).to eq "manisha"
end
end
describe '.add name' do
it 'stores the name of blogger' do
posts = Peeps.all
allow(posts).to receive(:add_name).and_return(4)
expect(posts.add_name).to eq(4)
end
... | true |
73840d48184b51695d060af365a731237f79a4bf | Ruby | ducktyper/ora-cli | /lib/ora/cli/tasks/switch_branch.rb | UTF-8 | 1,021 | 2.53125 | 3 | [] | no_license | require 'ora/cli/task'
require 'ora/cli/precondition_error'
module Ora::Cli
class SwitchBranch < Task
attr_reader :target_branch
def commands
'
:only_feature_branch_can_be_dirty!
:switch_to
git stash save -u "OraCli"
git checkout #{target_branch}
:apply_stash
'
... | true |
036372e74db16f6b4aea77eed84ec4dbaa3187ed | Ruby | fatcatdog/W1D5 | /tic_tac_toe/skeleton/lib/tic_tac_toe_node.rb | UTF-8 | 747 | 3.171875 | 3 | [] | no_license | require_relative 'tic_tac_toe'
class TicTacToeNode
attr_accessor :board, :next_mover_mark, :prev_move_pos
def initialize(board, next_mover_mark, prev_move_pos = nil)
@board = board
@next_mover_mark = next_mover_mark
@prev_move_pos = prev_move_pos unless prev_move_pos == nil
end
def losing_node?... | true |
2ed4ddcfd54931a796bf66c8097379b297b75715 | Ruby | knaveofdiamonds/conspirator | /spec/data_encoding_spec.rb | UTF-8 | 1,219 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Google Charts' extended data encoding" do
it "should translate an integer to two characters" do
ExtendedEncoding.new.translate(0).should == "AA"
ExtendedEncoding.new.translate(25).should == "AZ"
ExtendedEncoding.new.translate(26)... | true |
7ce3a99aa1215684bd388a4f943f8d0252ddf3f6 | Ruby | zapidan/ruby-playground | /3-reducing-costs-with-duck-typing/preparer_duck_type.rb | UTF-8 | 950 | 3.375 | 3 | [] | no_license | # Trip preparation is easier with a preparer duck type
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(preparers)
preparers.each { |preparer| preparer.prepare_trip(self) }
end
end
# Preparer is a duck that responds to prepare_trip
# Flexible extension, a new preparer can be added in the f... | true |
b48f83638c37fea1f85ef8209342fdbfd0b2e51d | Ruby | pathways2050/excel_to_code | /spec/compile/ruby/check_for_unknown_functions_spec.rb | UTF-8 | 478 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative '../../spec_helper'
describe CheckForUnknownFunctions do
it "should print a list of formulae that are in the input but have not been implemented by the compiler" do
input = <<END
A1\t[:function, "AVERAGE", [:number, "1"]]
A2\t[:function, "NOT IMPLEMENTED FORMULA", [:number, "1"]]
END
expected = <<EN... | true |
67d32da8980d71a575cb28bb8e3cfc31d8565417 | Ruby | sumajirou/ProjectEuler | /p060 copy.rb | UTF-8 | 494 | 3.375 | 3 | [] | no_license | require 'prime'
# 問題の確認
[3,7,109,673].permutation(2).map{|n,m| (n.to_s+m.to_s).to_i}.all?(&:prime?)
def check(primes)
primes.permutation(2) do |n,m|
unless (n * 10 ** Math.log10(m).ceil + m).prime?
return false
end
end
return true
end
26.upto(1000) do |sum|
end
... | true |
37bd42f3497ca4c5b0897f3515d59b7b089c8525 | Ruby | RubyCamp/rc2011s_g1 | /dice_game/map.rb | UTF-8 | 189 | 2.90625 | 3 | [] | no_license | # Mapクラスの定義
class Map
def initialize
@x, @y = 0, 0
@map_img = Image.load("Map_image/map.png")
end
def draw
Window.draw(@x, @y, @map_img)
end
end
| true |
c1f53c928e9342d349bdd2f2490273ee1ec291cb | Ruby | M4r14nn4/Ruby-Bottom-up | /numbers/roman_helper.rb | UTF-8 | 2,173 | 4.1875 | 4 | [] | no_license | # created for visualising which logical steps can easily lead to the 'short' solution of representing integers as 'old-school'
# roman nums. Written to show the logic only...
def roman_helper(arabic_num)
if arabic_num < 5
puts 'I' * arabic_num
#integers between 5 and 9
elsif arabic_num >= 5 && arabic_nu... | true |
acb0030a0e3eaf6dce37cf5c2d5bf54292c00956 | Ruby | griffithlab/civic-server | /app/models/scoped_event_feed.rb | UTF-8 | 933 | 2.578125 | 3 | [
"MIT"
] | permissive | class ScopedEventFeed
attr_reader :root, :event_subjects, :page, :per
def initialize(root_type, root_id, page = 0, per = 20)
@root = root_type.classify.constantize.find(root_id)
@event_subjects = EventHierarchy.new(root).children
@page = page
@per = per
end
def events
if @events
@even... | true |
ebfed03ccf4712ffcc9c71664f3ad345a5c6f01a | Ruby | DanielMulitauopele/black_thursday | /test/merchant_repository_test.rb | UTF-8 | 2,862 | 3.0625 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/merchant_repository.rb'
class MerchantRepositoryTest < Minitest::Test
def setup
merchant_1 = Merchant.new(
name: "Bills Tools",
id: "123",
created_at: "2010-12-10",
updated_at: "2011-12-04"
)
merchant_2 = Merchant.new(
... | true |
712766f6bc907168fa6d9d7188d814a3718f3641 | Ruby | steph544/mod-1-whiteboard-challenge-multiples-of-three-and-five-hou01-seng-ft-042020 | /lib/multiples.rb | UTF-8 | 214 | 3.375 | 3 | [] | no_license | # Enter your procedural solution here!
require 'pry'
def collect_multiples (limit)
(1...limit).to_a.select{|num| num% 3 ==0 || num % 5 ==0}
end
def sum_multiples(limit)
collect_multiples(limit).sum
end | true |
e38a7ff743c863fdca9257b245631a54e1b83655 | Ruby | jamesgraham320/the-bachelor-todo-web-100817 | /lib/bachelor.rb | UTF-8 | 1,491 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def get_first_name_of_season_winner(data, season)
# code here
data.each do |season_number, contestants|
if season == season_number
contestants.each do |info|
#binding.pry
if info["status"] == "Winner"
# binding.pry
return info["name"].split(" ").first
... | true |
ddf145cfef5532942d4c41a3fa27ade8e60203a6 | Ruby | victornava/exercises | /2016.beautiful-code.rb | UTF-8 | 4,424 | 3.96875 | 4 | [] | no_license | # https://programmingpraxis.com/2009/09/11/beautiful-code/
#
# Beautiful Code
#
# In their book The Practice of Programming, Brian Kernighan and Rob Pike present
# this code for matching simple regular expressions consisting of literal
# characters, a dot matching any character, a star consisting of zero or more
# repe... | true |
2c05af8b4deffe50e487022e7f57c10c6db04e8f | Ruby | dereke/proxy-server | /lib/proxy/port_prober.rb | UTF-8 | 265 | 2.90625 | 3 | [] | no_license | # lovingly reused from selenium-webdriver
class PortProber
def self.above(port)
port += 1 until free? port
port
end
def self.free?(port)
TCPServer.new('localhost', port).close
true
rescue SocketError, Errno::EADDRINUSE
false
end
end
| true |
e83d88aaaf7ed27c33cfda83fe8540d5cffeb274 | Ruby | ChrisCPO/Metis-Prework | /xis.rb | UTF-8 | 162 | 3.765625 | 4 | [] | no_license | puts "give me a number"
x= gets.chomp.to_i
if x > 2
puts "x is greater then 2"
elsif x < 2 and x != 0
puts "x is 1"
else
puts "i cant guess the number"
end
| true |
2cc5fe24519c49d17ecfa8a66c83093d6fd2fe6b | Ruby | alsabater/Hackerrank_30_Days_of_Code | /Grades_calculator.rb | UTF-8 | 814 | 3.859375 | 4 | [] | no_license | class Student
def initialize(firstName,lastName,phone)
@firstName=firstName
@lastName=lastName
@phone=phone
end
def display()
print("First Name: ",@firstName,"Last Name: ",@lastName+"Phone: ",@phone)
end
end
class Grade <Student
def initialize (firstName,lastName,phone,... | true |
59eb25435091ebf9d2e748a5c461731719e92537 | Ruby | allolex/nacre | /lib/nacre/concerns/inflectible.rb | UTF-8 | 765 | 3.140625 | 3 | [
"MIT"
] | permissive | module Nacre::Inflectible
CAMEL_CASE_RE = /(?<=[a-z])[A-Z]/
SNAKE_CASE_RE = /_(\w)/
def snake_case(value)
value.to_s.split(/(?=[A-Z])/).join("_").downcase
end
def camelize(value)
value = value.to_s
return value unless snake_case?(value)
value.gsub(/_(\w)/) { $1.upcase }
end
def format_... | true |
a3cc1d8079be5eafbccd072809a30ee915875a45 | Ruby | mocoso/roman-cart | /lib/roman_cart_site.rb | UTF-8 | 2,291 | 2.625 | 3 | [] | no_license | require 'tmpdir'
require 'mechanize'
require 'roman_cart_export'
class RomanCartSite
def initialize
self.agent = Mechanize.new
end
def login(options)
login_page = agent.get('https://admin.romancart.com')
login_form = login_page.form_with(:name => 'frmlogin')
login_form.set_fields(options)
re... | true |
6b1e837513a203c505d7ac9273610f457bd96e00 | Ruby | chris241/THP1_J10 | /lib/eventcreator.rb | UTF-8 | 709 | 3.25 | 3 | [] | no_license | class EventCreator
attr_accessor :title , :start_date, :duration, :attendees
def initialititleze(title, start_date, duration, attendees)
@title = title
@start_date = start_date
@duration = duration
@attendees = attendees
end
def recupere
puts "Salut, tu veux créer un événement? Cool!"
puts "Comm... | true |
750f5f5386bdc8396b93406a3611f8257f049c14 | Ruby | ajLapid718/HackerRank-30-Days-of-Code | /Day-27-Testing.rb | UTF-8 | 988 | 3.546875 | 4 | [] | no_license | Task
# Link: https://www.hackerrank.com/challenges/30-testing/problem
Create and print a test case for the problem above that meet the following criteria:
- A minimum of five test cases
- A number n between 3 and 200, which represents the amount of students in the class
- A number k between 1 and n, which represents ... | true |
b91e3ced125ff29fe287584233a8eaacac6f8e70 | Ruby | complikatyed/Whatcha_Reading | /app/models/author.rb | UTF-8 | 1,421 | 2.84375 | 3 | [
"MIT"
] | permissive | # class Author < ActiveRecord::Base
# attr_reader :id, :errors
# attr_accessor :name
# def initialize(name = nil)
# self.name = name
# end
# def ==(other)
# other.is_a?(Author) && other.id == self.id
# end
# def self.all
# Database.execute("select * from authors order by name ASC").map do ... | true |
9284e917c459f93b8e6e5126c5238e1261c81c7c | Ruby | oscarjes/bootcamp-ruby | /week1/assignment/list.rb | UTF-8 | 1,420 | 3.671875 | 4 | [] | no_license | require 'colorize'
require_relative "item"
class List
attr_accessor :items
def initialize(name, items = [])
@name = name
@items = items
end
def add(item)
@items << item
end
def display
puts ("-" * 100).colorize(:light_blue)
puts "Here is your #{@name}:".colorize(:light_blue)
puts... | true |
85e201cb272d08250466d59252ad1d157ccf289e | Ruby | stormbrew/channel9 | /ruby/lib/channel9/instruction/message_new.rb | UTF-8 | 1,327 | 3.1875 | 3 | [
"MIT"
] | permissive | module Channel9
module Instruction
# message_new name, sys_count, count
# ---
# Pushes a message onto the stack, with count
# positional arguments consumed and stored in the argument
# pack, along with the message name.
#
# Takes count inputs as well as a message name:
# SP ->arg1 -> ... | true |
f5ea0c360cf33a5c3ea92b1451f4a8a7ae2526fb | Ruby | yu-nakagawa/design-pattern | /abstract_factory.rb | UTF-8 | 1,500 | 4.0625 | 4 | [] | no_license | class Duck
def initialize(name)
@name = name
end
def eat
puts "アヒル #{@name} は食事中です"
end
end
class Frog
def initialize(name)
@name = name
end
def eat
puts "カエル #{@name} は食事中です"
end
end
class WaterLily
def initialize(name)
@name = name
end
def grow
puts "スイレン#{@name}は成長中... | true |
9c3ef1dbee5e1941aa31d7f958c538a6fa1625f3 | Ruby | roman-franko/fog_backup | /lib/fog_backup/base.rb | UTF-8 | 1,719 | 2.53125 | 3 | [] | no_license | module FogBackup
class Base
include Helpers::Archiver
include Helpers::Aws
include Helpers::Ftp
def initialize
@timestamp = Time.now
set_local_storage
@archive_path = File.join(@tmp_dir, "#{formatted_time @timestamp}.tar.gz")
end
def run
target_dir = FogBackup.config... | true |
0dd57378fa803e900e39bd9d6abd431fb55003f5 | Ruby | pcarri4/programming-univbasics-nds-green-grocer-part-1-chi01-seng-ft-120720 | /lib/grocer.rb | UTF-8 | 487 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def find_item_by_name_in_collection(name, collection)
# Implement me first!
#
# Consult README for inputs and outputs
cart = nil
collection.each do |item|
if item[:item] == name
cart = item
end
end
cart
end
def consolidate_cart(cart)
receipt = Array.new
cart.each do |item|
count = 0
if !it... | true |
6939a6f79a3695390b9f2ea0e7d35f2d2e8d27a1 | Ruby | mikeisfake/prime-ruby-online-web-pt-081219 | /prime.rb | UTF-8 | 89 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def prime?(num)
return false if num <= 1
(2..num - 1).none?{ |i| num % i == 0}
end
| true |
4ca298f22b41ed462811edecddd0b67636915cd2 | Ruby | voxpupuli/beaker | /spec/beaker/command_spec.rb | UTF-8 | 5,337 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
module Beaker
describe Command do
subject(:cmd) { described_class.new(command, args, options) }
let(:command) { @command || '/bin/ls' }
let(:args) { @args || [] }
let(:options) { @options || {} }
let(:host) do
h = {}
allow(h).to receive(:environment_st... | true |
cb24d3fdef33e8ca3eb5ef97cc261a1128f4ae48 | Ruby | kolishchak/codewars | /Design Patterns/elevator.rb | UTF-8 | 952 | 3.578125 | 4 | [] | no_license | module ValuesValidator
def valid?
self.value.is_a?(valid_type) && self.valid_values.include?(value)
end
end
class Level
include ValuesValidator
attr_reader :value
def initialize(value)
@value = value
end
def valid_values
(0..3)
end
def valid_type
Integer
end
end
class Button
... | true |
4380c5038ebd65ecb52b2e062937a1e081ee4b51 | Ruby | vinbarnes/asciidoctor | /test/headers_test.rb | UTF-8 | 4,261 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'test_helper'
context "Headers" do
test "document title with multiline syntax" do
title = "My Title"
chars = "=" * title.length
assert_xpath "//h1[not(@id)][text() = 'My Title']", render_string(title + "\n" + chars)
assert_xpath "//h1[not(@id)][text() = 'My Title']", render_string(title + "\n... | true |
c3f1716382b16daf891b9510a1525ec33c37bc16 | Ruby | justinweiss/error_stalker | /lib/error_stalker/store/in_memory.rb | UTF-8 | 3,337 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'error_stalker/store/base'
require 'will_paginate/array'
require 'set'
# The simplest exception store. This just stores each reported
# exception in a list held in memory. This, of course, means that the
# exception list will disappear when the server goes down, the server
# might take up tons of memory, and s... | true |
4225925e483765f7d2ad3b5e8d46ca8fd259c2f5 | Ruby | panickat/CodeaCampRuby | /sem1/dia4/6_hash_iteracion.rb | UTF-8 | 438 | 3.53125 | 4 | [] | no_license | def family_members(h)
respuesta = []
h.each do |k,v|
respuesta.concat(v) if (k == :sisters || k == :brothers)
end
respuesta
end
family = { uncles: ["jorge", "samuel", "steve"],
sisters: ["angelica", "mago", "julia"],
brothers: ["polo","rob","david"],
aunts: ["maria","m... | true |
f4936b04b0936fe82dcfbae2e5f0912ace36f06c | Ruby | kinisoftware/7L7W | /Ruby/day2/array_four_items_at_time_with_each_slice.rb | UTF-8 | 39 | 3.078125 | 3 | [] | no_license | (1..16).each_slice(4) {|items| p items} | true |
1fec76d20cee952e0d0feeff6f2437b26327c1f7 | Ruby | micahbf/rails_lite | /lib/rails_lite/controller_base.rb | UTF-8 | 1,076 | 2.546875 | 3 | [] | no_license | require 'erb'
require_relative 'params'
require_relative 'session'
class ControllerBase
attr_reader :params
def initialize(req, res, router_params)
@request = req
@response = res
@params = Params.new(req, router_params)
end
def session
@session ||= Session.new(@request)
end
def already_r... | true |
2a8c91ded92686a4051a17d12d264d2d75adf278 | Ruby | llwebsol/omg_validator | /test/alpha_numeric_validator_test.rb | UTF-8 | 776 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class AlphaNumericValidatorTest < ActiveSupport::TestCase
def setup
@thing = Thing.new
@things = Things.new
end
def teardown
@thing = nil
end
test 'Thing should be valid if alpha_numeric attribute has alphanumeric characters.' do
@things.alpha_numeric['valid'].each do ... | true |
e1f4b21f0ef496b31461250b064205d3368bc7e7 | Ruby | blackric/steam-condenser | /ruby/lib/steam/community/app_news.rb | UTF-8 | 2,541 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | # This code is free software; you can redistribute it and/or modify it under
# the terms of the new BSD License.
#
# Copyright (c) 2010-2011, Sebastian Staudt
require 'json'
require 'steam/community/web_api'
# The AppNews class is a representation of Steam news and can be used to load
# current news about specific g... | true |
1e070d687d9ad3ad2263a7b04c72c05e04586dfa | Ruby | rshea303/sales_engine | /lib/transaction.rb | UTF-8 | 887 | 2.546875 | 3 | [] | no_license | require_relative 'support'
class Transaction
include Support
attr_reader :id,
:invoice_id,
:credit_card_number,
:credit_card_expiration_date,
:result,
:created_at,
:updated_at,
:repository
def init... | true |
f92bbfa85394ccb73dc17a34140f8909c5bf2c07 | Ruby | chrisjgilbert/fizzbuzz-ruby | /spec/fizzbuzz_spec.rb | UTF-8 | 509 | 3.375 | 3 | [] | no_license | require 'fizzbuzz'
describe FizzBuzz do
describe '#play' do
it 'returns Fizz if number is divisible by 3' do
expect(subject.play(3)).to eq 'Fizz'
end
it 'returns Buzz if number is divisible by 5' do
expect(subject.play(5)).to eq 'Buzz'
end
it 'returns FizzBuzz if number is divisibl... | true |
3b3451a837bed611bc78ecd81c6258df36d32bb6 | Ruby | pitosalas/coursegen | /lib/coursegen/course/schedule/schedule_def.rb | UTF-8 | 535 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Define schedule scheme for a lecture series
class ScheduleDef
attr_reader :first_day, :weekdays, :number, :skips, :start_time, :end_time, :start_times, :end_times
def initialize(first_day: nil, weekdays: nil, number: nil,
skips: [], start_time: nil, end_time: nil, start_times: [], end_times: [])... | true |
aeefdcc706eeeaf44699e7e318ece5dfa56f3959 | Ruby | puppetpies/Snippets | /keyword_highlight.rb | UTF-8 | 376 | 3.203125 | 3 | [] | no_license | a = "Linux, Android, some text Java Mobile hello this is just a test, DevOps, far to much fun!"
def text_highlighter(text)
keys = ["Linux", "Java", "Android", "DevOps", "obi", "uc", "un!", "us"]
cpicker = [2,3,4,1,3]
keys.each {|n|
text.gsub!("#{n}", "\e[4;3#{cpicker[rand(cpicker.size)]}m#{n}\e[0m\ ".strip)
... | true |
a3759ec6464ca1f2e600cae5206d0b8e2903a6cf | Ruby | ga-wolf/WDI12_Homework | /AlexLee/week_05/games-on-rails/games/app/controllers/rps_controller.rb | UTF-8 | 2,804 | 2.703125 | 3 | [] | no_license | class RpsController < ApplicationController
def rock_paper_scissors_play
rock_paper_scissors_play = {
:rock => {:rock => "draw", :paper => "paper", :scissors => "rock", :lizard => "rock", :spock => "spock"},
:paper => {:rock => "paper", :paper => "draw", :scissors => "scissors", :lizard... | true |
6c5021d7da9a64cad9f8136e458e0a6860a6118a | Ruby | vsizov/cssquirt | /lib/cssquirt/file_list.rb | UTF-8 | 1,389 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'rake'
module CSSquirt
class ImageFileList < Rake::FileList
# Public: return a CSS document of all images
#
# prefix - an optional String to automatically prefix all class names with, useful
# for namespacing, etc. Default: nil.
# header - a optional Boolean value representing wh... | true |
9294a63a386be152b0039292a708121652b3ef8a | Ruby | dell-asm/razor-server | /db/migrate/015_realize_node_name.rb | UTF-8 | 2,022 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # -*- encoding: utf-8 -*-
require_relative './util'
# Node names were previously fabricated in application code as required; this
# resulted in a highly non-uniform API, and complicates validation code based
# on object references.
#
# This performs the same realization of the value into the database for
# existing no... | true |
6b3fb0f2c5d9120db5d573118c9f4f8bc193fd97 | Ruby | graywh/ccsc-se-contest | /2010/2/17-2.rb | UTF-8 | 438 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby
data = {}
def rating(win,loss,sum)
(sum + 400.0 * (win - loss)) / (win + loss)
end
STDIN.readline.to_i.times do |line|
team, record, scores = line.split(' ', 3)
wins, loss = record.split('-').map(&:to_i)
sum = scores.split.map(&:to_i).inject(&:+)
data[team] = rating(wins,loss,sum)
end
... | true |
9a34cb9fef93c0dd2468397f475fed1c171619a3 | Ruby | jjoub/rails-longest-word-game | /app/controllers/games_controller.rb | UTF-8 | 790 | 3 | 3 | [] | no_license | require 'json'
require 'open-uri'
class GamesController < ApplicationController
def new
@letters = []
10.times do
@letters << ("A".."Z").to_a.sample
end
end
def score
@answer_player = params[:answer]
@letters_sample = params[:letters_sample]
if @answer_player.upcase.split("").all?... | true |
8ba29b7237130eed8268ebcfac9dec52409210f6 | Ruby | rmiri/ruby-enumerables-cartoon-collections-lab-london-web-120919 | /cartoon_collections.rb | UTF-8 | 677 | 3.484375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)# code an argument here
# Your code here
myhash = Hash.new
array.each_with_index { |item,index|
myhash[index + 1] = item
}
puts myhash
end
def summon_captain_planet(names)# code an argument here
# Your code here
names.map {|name| p "#{name.capitalize}!"}
end
def long_plan... | true |
c9b42a5a60e9cc7b4456a6b1308db7f925f410d3 | Ruby | AlinaGoaga/GildedRose | /spec/features/gilded_rose_spec.rb | UTF-8 | 944 | 2.734375 | 3 | [] | no_license | require 'gilded_rose'
describe GildedRose do
describe '#update_quality' do
it 'updates the quality of different items' do
normal = Normal.new('Normal', 5, 5)
sulfur = Sulfuras.new('Sulfuras, Hand of Ragnaros', 10, 5)
brie = Brie.new('Aged Brie', 9, 8)
ticket = Ticket.new('Backstage passes... | true |
1eb0954e93538c6940436c14e7474a74c1286b3e | Ruby | johnnyt/maglev-presentation | /models/player.rb | UTF-8 | 763 | 2.828125 | 3 | [] | no_license | class Transition
attr_accessor :player, :cell, :time
def self.store
@store ||= IdentitySet.new
end
def initialize(player, cell, time=Time.now)
@player, @cell, @time = player, cell, time
self.class.store.add self
end
end
class Player
attr_accessor :name, :transitions, :current_cell
def self... | true |
7aceb043833b088d05f67bc3dc8b37974efbc3ec | Ruby | ivaverka/Learn-Ruby-the-Hard-Way | /questions.rb | UTF-8 | 1,076 | 3.546875 | 4 | [] | no_license | module Questions # I need to think how to make it ask a question check the answer (done) and then GO TO THE RIGHT ROOM BASED ON THE ANSWER.
# SHould I put the logic in the Scene Class and use super in other classes or Should I put the Logic inside this module?
# Because now it will only iterate over keys and values a... | true |
d973ded977d5edbd24a177ddd86be41adcdb9e1d | Ruby | gengogo5/atcoder | /ABC/abc222/ABC222_A.rb | UTF-8 | 35 | 2.59375 | 3 | [] | no_license | N = gets.to_i
printf("%04d\n", N)
| true |
320574f16e0074f2a36e13c91f5ce2fc93898017 | Ruby | Gowdhamselvam/Basics-of-Ruby | /foreach.rb | UTF-8 | 45 | 2.671875 | 3 | [] | no_license | IO.foreach("input.txt") {|block| puts block}
| true |
3b9f276d86b746036e75f7fb39aa995eb3d14d4c | Ruby | NatasaPetrovic/railsCourse | /ruby_projects/hash.rb | UTF-8 | 454 | 3.453125 | 3 | [] | no_license | # Hash
my_details = {'name' => 'nata', 'favcolor' => 'red'}
puts my_details['favcolor']
myhash = {a: 1, b: 2, c: 3}
puts myhash[:c]
myhash[:d] = 7
puts myhash[:d]
puts myhash
myhash[:name] = "Nata"
puts myhash[:name]
myhash.delete(:d)
numbers = {a: 1, b: 2, c: 3, d: 4 }
numbers.each {|k, v| puts v}
numbers.each {|k... | true |
5f27b86cd37f01cbfb51741857ee1b20635dfed9 | Ruby | emmiehayes/scrabble_api | /app/models/word.rb | UTF-8 | 925 | 2.734375 | 3 | [] | no_license | class Word
def initialize(word)
@word = word
end
def validate
return "'#{@word}' is not a valid word." if response.status == 404
return "'#{word_id}' is a valid word and its root form is '#{root_word}'." if dictionary_data.first[:id] == @word
end
private
def root_word
dictionary_data... | true |
b747270c71849a2b71ea6df309e3e373b8b26161 | Ruby | orderedlist/mongomapper | /lib/mongo_mapper/observing.rb | UTF-8 | 1,100 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'observer'
require 'singleton'
require 'set'
module MongoMapper
module Observing #:nodoc:
def self.included(model)
model.class_eval do
extend Observable
end
end
end
class Observer
include Singleton
class << self
def observe(*models)
models.flatten... | true |
de5ccc30574870b1abebc32d8f5946149f5c1718 | Ruby | saidmaadan/mks | /Ruby/project-euler/problem31.rb | UTF-8 | 648 | 3.90625 | 4 | [] | no_license |
# In England the currency is made up of pound, £, and pence, p, and there are
# eight coins in general circulation:
# 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
# It is possible to make £2 in the following way:
# 1£1 + 150p + 220p + 15p + 12p + 31p
# How many different ways can £2 be made using any number of ... | true |
0c0d774585de510db9edb57e9944b9466799bb74 | Ruby | Fitog4/rvnb | /app/models/booking_request.rb | UTF-8 | 570 | 2.53125 | 3 | [] | no_license | class BookingRequest < ApplicationRecord
belongs_to :rv
belongs_to :user
validates :status, inclusion: { in: ['pending', 'approved', 'paid'] }
validates :location, :date_from, :date_till, presence: true
validate :valid_dates?
private
def valid_dates?
# date_till >= date_from >= Date.today
unles... | true |
5d088c7a5d9fe198b1008896b65e1a44b88661a6 | Ruby | mikey-roberts/mini_projects | /sub_string/sub_string.rb | UTF-8 | 466 | 3 | 3 | [] | no_license | dictionary = ["plastic","previous","below","low","aggressive","cautious", "truculent","full","accessible","material","amused","selfish","apathetic","perpetual"]
# takes a string input and returns a hash. K - string V - number of entires
def sub_string(string, dictionary)
string = string.downcase.split(" ")
... | true |
f0619bff0b07201493404efe9d70ab92a28aeaa0 | Ruby | sekoudosso82/Ruby_essential | /testing/spec/palindrome_checker_spec.rb | UTF-8 | 1,079 | 2.84375 | 3 | [] | no_license | require_relative '../lib/palindrome_cheker'
RSpec.describe PalindromeChecker do
describe '#check' do
let(:checker) {PalindromeChecker.new}
it 'returns true when given a palaindrome' do
word = "racecar"
result = checker.check(word)
expect(result).to be true
... | true |
e40b6e62ff78555b1b005bcda9dd5ce795b891ae | Ruby | alexdaesikkim/hcef | /app/models/guardian.rb | UTF-8 | 742 | 2.640625 | 3 | [] | no_license | class Guardian < ActiveRecord::Base
#add date of birth to uniquely identify
#relationships
has_many :children
has_many :guardian_locations
has_many :locations, through: :guardian_locations
#validations
validates_presence_of :first_name, :last_name, :phone, :email
validates_date :date_of_birth, :before => lamb... | true |
28a339624ea7a8c113d047abcf20b403313a060c | Ruby | ktmishra1-appdev/loops-chapter | /spec/scripts/loops_spec.rb | UTF-8 | 4,594 | 3.109375 | 3 | [] | no_license | describe "loops_fizz_buzz.rb" do
it "should output the correct response", points: 1 do
# Un-require loops_fizz_buzz.rb
loops_fizz_buzz = $".select{|r| r.include? 'loops_fizz_buzz.rb'}
$".delete(loops_fizz_buzz.first)
response = File.read("spec/support/fizz_buzz.txt")
expect { require_relative("... | true |
d83748d802f2febcadb2b5ad0d74d7f730cd2371 | Ruby | cyberarm/visual_plotter | /lib/machine/compiler/processor.rb | UTF-8 | 965 | 2.78125 | 3 | [] | no_license | class Machine
class Compiler
Node = Struct.new(:x, :y)
class Processor
def initialize(compiler:, canvas:, mode: :default)
@compiler = compiler
@canvas = canvas
case mode
when :classic, :default
default
when :graph_search
graph_search
... | true |
f9de4a618f7277de466618e213ca22800371a93a | Ruby | sokampdx/head_first_design_patterns | /ruby/PizzaStore/pizza_store_simple.rb | UTF-8 | 2,024 | 3.890625 | 4 | [] | no_license | class SimplePizzaFactory
def create(type)
case type
when 'cheese'
CheesePizza.new
when 'pepperoni'
PepperoniPizza.new
when 'clam'
ClamPizza.new
when 'veggie'
VeggiePizza.new
end
end
end
class PizzaStore
def initialize(factory)
@factory = factory
end
def or... | true |
03df5447d6e0c0558f54e5070a7d8553deebd59f | Ruby | Green-stripes/reverse-each-word-001-prework-web | /reverse_each_word.rb | UTF-8 | 121 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(phrase)
hold = []
phrase.split(" ").each do |x|
hold << x.reverse
end
hold.join(" ")
end | true |
2e85f6e0c33f915299092af7bf2c0eed7760c71e | Ruby | pmarshall17/ruby_calculator | /calculator.rb | UTF-8 | 1,081 | 4.125 | 4 | [] | no_license | def add
print "Enter number 1: "
@a1 = gets.chomp.to_i
print "Enter number 2 : "
@a2 = gets.chomp.to_i
puts "Calculating... #{@a1 + @a2}"
end
def subtract
print "Enter number 1: "
@s1 = gets.chomp.to_i
print "Enter number 2: "
@s2 = gets.chomp.to_i
puts "Calculating... #{@s1 - @s2}"
end
def multiply
... | true |
b6805960831fb25694b33757ab19c9c513593f79 | Ruby | pawelduda/codeeval-ruby-solutions | /easy/3.rb | UTF-8 | 246 | 3.515625 | 4 | [] | no_license | # https://www.codeeval.com/browse/3/
require 'prime'
def is_palindrome?(str)
str == str.reverse
end
def largest_prime
(1..1000).reverse_each do |x|
if x.prime?
return x if is_palindrome?(x.to_s)
end
end
end
p largest_prime | true |
03cfdfa3b94be2e19f83045c7d5d3990a845c02d | Ruby | JustSilverman/xDBC-todo_list_with_ar | /app/controllers/todo_controller.rb | UTF-8 | 1,103 | 2.609375 | 3 | [] | no_license | require_relative '../models/list_item'
require_relative '../views/todo_view'
class TodoController
attr_reader :id, :action, :task, :user_interface
def initialize(args)
@id = args[:id].to_i
@action = args[:action]
@task = args[:task]
@user_interface = TodoView.new
... | true |
279801053729847a8e0d15d3c18a9a07e86edf2d | Ruby | chuckremes/rzmq_brokers | /lib/rzmq_brokers/broker/worker.rb | UTF-8 | 3,735 | 2.609375 | 3 | [] | no_license |
module RzmqBrokers
module Broker
# Used by the Broker to track the state of a connected Worker and maintain heartbeats
# between itself and the actual Worker.
#
class Worker
attr_reader :service_name, :identity, :envelope
def initialize(reactor, handler, service_name, identity, heartbeat... | true |
21eae3507b98a1c76fbf0753f323eab7e58fb220 | Ruby | opfo/resources | /scripts/db_parser.rb | UTF-8 | 6,699 | 3.140625 | 3 | [] | no_license | # Used to parse tags from a stackoverflow database
require 'colorize'
require 'debugger'
unless File.exists? "./so.sqlite"
puts "=============================================================================".red
puts "ERROR ==> script cannot execute without the original db in the same directory"
puts ""
puts ... | true |
ba8064fa43647f4d89bb6b729775c45e097176ad | Ruby | ksashikumar/bootcamp-ruby | /Polynomials/polynomials.rb | UTF-8 | 762 | 3.390625 | 3 | [] | no_license | class Polynomials
def initialize(array)
@array = array
@length = @array.length()-1
@result = ""
end
def compute
raise ArgumentError, "Need atleast 2 coefficients" if @length < 1
@array.each do |coeff|
if coeff != '0'
if coeff > '0'
if @length != @arra... | true |
20100b52bfaf4d8cff612e787dbab2a95bf93de6 | Ruby | marcelosnts/estudos_ruby | /Modulos/app2.rb | UTF-8 | 105 | 2.59375 | 3 | [] | no_license | require_relative "mixin"
var = Mixin.new
puts var.a1
puts var.a2
puts var.b1
puts var.b2
puts var.ex1 | true |
e7c32483f18d155a3d203d3fd84a43077cab9ee5 | Ruby | 34code/Hello-Ruby | /RubyPickaxe/Chapter 2 - Ruby.new/hashes.rb | UTF-8 | 600 | 3.75 | 4 | [
"MIT",
"BSD-3-Clause",
"BSD-4-Clause",
"BSD-2-Clause"
] | permissive | h = { 'dog' => 'canine', 'cat' => 'feline', 'donkey' => 'asinine' }
p h.length
p h['dog']
h['cow'] = 'bovine'
h[12] = 'dodecine'
h['cat'] = 99
p h
def words_from_string(string)
string.downcase.scan(/[\w']+/)
end
p words_from_string("But I didn't inhale, he said (emphatically)...")
def count_frequency(word_list)
... | true |
59dc41c2ceb01e6786e3a5f285c794becb3a646f | Ruby | LynnAmsbury/hayk-assessment-build-classes-and-objects | /Building.rb | UTF-8 | 893 | 3.375 | 3 | [] | no_license | # frozen_string_literal: true
class Building
attr_accessor :name, :number_of_tenants
attr_reader :address
@@all = []
def initialize(name, address, number_of_floors = 0, number_of_tenants = 0)
@name = name
@address = address
@number_of_floors = number_of_floors
@number_of_tenants = number_of_t... | true |
08b6103abff18adb7be9a9b4b91434cb81779c29 | Ruby | rminasi/hangman-rails-ruby | /app/models/guess_bot.rb | UTF-8 | 1,926 | 3.40625 | 3 | [
"MIT"
] | permissive | class GuessBot
class << self
def calculate_guesses(word)
# Loop through single letters in order of frequency until we get a match
# TODO: Loop through bigrams trying letters in order of frequency
letters_guessed = word.chars.map { |letter| [letter.downcase, false] }.to_h
letters_guessed.de... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.