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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2bc0d83545fd35ab7e43c85be4fa42008219c0cc | Ruby | mattfraz38/Udemy-Ruby-Projects | /oop_projects/students.rb | UTF-8 | 1,436 | 3.640625 | 4 | [] | no_license | class Student
attr_accessor :first_name, :last_name, :email, :username, :password
# attr_reader :username
def Initialize(firstName, lastName, userName, email, password)
@first_name = firstName
@last_name = lastName
@email = email
@username = userName
@password = password
end
# the below met... | true |
fca6006e151c94d06d5f0bba77ac1166a512007e | Ruby | TheodoreSchafer/ruby-object-initialize-lab-onl01-seng-pt-081720 | /lib/person.rb | UTF-8 | 78 | 2.75 | 3 | [] | no_license | class Person
def initialize(persons_name)
@name= persons_name
end
end
| true |
25cd863cdcdf0e46a75dbeb8d5f66d98a475e867 | Ruby | mohamedhafez/parallelizer | /lib/parallelizer.rb | UTF-8 | 4,200 | 2.859375 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
# used to call java code
require 'java'
# 'java_import' is used to import java classes
java_import 'java.util.concurrent.Callable'
java_import 'java.util.concurrent.FutureTask'
java_import 'java.util.concurrent.LinkedBlockingQueue'
java_import 'java.util.concurrent.ThreadPoolExecutor'
java_... | true |
a7e28d064f7d814f3584940f80a74cdc2ecdf85f | Ruby | didy400/scrap | /lib/01_crypto_scrapper.rb | UTF-8 | 616 | 2.78125 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
require 'rubygems'
page = Nokogiri::HTML(URI.open('https://coinmarketcap.com/all/views/all/'))
crypto_keys = []
crypto_values = []
page.css('tr.cmc-table-row > td:nth-child(5) > a').each do |node|
crypto_keys.push(node.content)
end
puts cryp... | true |
da937d2ee3e3b165a693b4307e15e60e0ded1d6a | Ruby | jmc27/PA2 | /User.rb | UTF-8 | 279 | 3.28125 | 3 | [] | no_license | class User
attr_accessor :users
def initialize
@users = Hash.new { |hash, key| hash[key] = []}
end
#loads a line and splits it and pushes it to the hash of of users
def load_line line
line = line.split ' '
@users[line[0].to_sym].push([line[1], line[2].to_i])
end
end | true |
a6698e8c1f4d84a43f1b5cfe52d059c61a57adc5 | Ruby | atandon0/ruby_intro | /app/controllers/programs_controller.rb | UTF-8 | 1,464 | 3.78125 | 4 | [] | no_license | class ProgramsController < ApplicationController
def home
# Your code goes below.
r_p_s = ["rock", "paper", "scissors"].sample
@program_choice = "The program chooses " + r_p_s
if r_p_s == "rock"
@your_output = "This is a tie. Let's refresh and play again"
elsif r_p_s == "scissors"
... | true |
e045ab1706f330ebcb6707c206707886dc9ad30a | Ruby | EdvinasGervelis/Events-sharing | /lib/event/event.rb | UTF-8 | 400 | 2.734375 | 3 | [] | no_license | class Event
attr_reader :accesability, :event_name, :event_information, :participants
initialize(event_name, location, date, price, accesability, organizator)
@event_ticket = EventTicket.new(evnt_name, location, date, price)
@event_information = EventInformation.new(organizator)
@accesability = accesab... | true |
6c0082d27daf9aeca7f7ec3d19c517ee3a2dff96 | Ruby | Tr1ckX/FAAST_Week-1 | /lib/oyster.rb | UTF-8 | 257 | 3.109375 | 3 | [] | no_license | class Card
DEFAULT_CREDIT = 0
attr_accessor :credit
def initialize(options = {})
self.credit = options.fetch(:credit, credit)
end
def credit
@credit ||= DEFAULT_CREDIT
end
def topup(value)
@credit = @credit + value
end
end
| true |
0f4f6561c2e284091ec42c06332b510e27760849 | Ruby | Strech/opal | /spec/cli/lexer_spec.rb | UTF-8 | 1,468 | 2.859375 | 3 | [
"MIT"
] | permissive | require File.expand_path('../spec_helper', __FILE__)
require 'opal/parser'
describe Opal::Lexer do
it "sets correct line information for each token" do
expect_lines("42").to eq([1])
expect_lines("\n3.142").to eq([2])
expect_lines("3.142\n42\n57").to eq([1, 2, 3])
end
it "increments the line count ov... | true |
5110cede2ec5d410f498b28a49e2e34f983b1afc | Ruby | mlevineisme/FindAndMove | /FindAndMove.rb | UTF-8 | 3,953 | 2.890625 | 3 | [] | no_license | #-- This program takes requirements specified in the .conf file, finds the
# associated .rb and .xml files, and copies them to a single file
# location, preserving the file paths after the specified end point
require 'FileUtils'
def print_err errorMsg
puts errorMsg
puts $! unless errorMsg.eql?($!)
puts $... | true |
81c990ed4c4d81e126f8adcf9e879222c312c9d3 | Ruby | nanma80/euler_project | /p076_100/p084/lib/monopoly.rb | UTF-8 | 2,680 | 3.21875 | 3 | [] | no_license | class Monopoly
attr_reader :board
def initialize
@board = [
:go, :a1, :cc1, :a2, :t1, :r1, :b1, :ch1, :b2, :b3,
:jail, :c1, :u1, :c2, :c3, :r2, :d1, :cc2, :d2, :d3,
:fp, :e1, :ch2, :e2, :e3, :r3, :f1, :f2, :u2, :f3,
:g2j, :g1, :g2, :cc3, :g3, :r4, :ch3, :h1, :t2, :h2
]
end
def... | true |
d8c1b24bcabe6fd417d7b8857dd9f0c966388129 | Ruby | mc962/monorm | /lib/monorm/associatable.rb | UTF-8 | 2,982 | 2.671875 | 3 | [
"MIT"
] | permissive | class MonoRM::AssocOptions
attr_accessor(
:foreign_key,
:class_name,
:primary_key
)
def model_class
self.class_name.constantize
end
def table_name
model_class.table_name
end
end
class MonoRM::BelongsToOptions < MonoRM::AssocOptions
def initialize(name, options = {})
@foreign_key... | true |
cd463d91750b35bf0fe934aa5a7dbf70c65b71d9 | Ruby | CristianoCM/Project-Euler | /problem56.rb | UTF-8 | 637 | 3.921875 | 4 | [] | no_license | =begin
A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size,
the sum of the digits in each number is only 1.
Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital su... | true |
467d393c6724fe80568ac603f9b3b814defcbdf3 | Ruby | teoucsb82/gloomhaven | /lib/gloomhaven/card.rb | UTF-8 | 804 | 3.3125 | 3 | [
"MIT"
] | permissive | module Gloomhaven
class Card
attr_reader :attack, :crit, :miss, :name, :shuffle
def initialize(name)
raise ArgumentError.new('Name must be a string') unless name.is_a?(String)
card_data = CARDS.detect { |card| card['name'].downcase == name.downcase }
validate!(card_data)
@name = ca... | true |
5b892d8c99f33aa41f848492ac02620714c4d5de | Ruby | efl7aArchive/sinatra-mvc-lab-cb-000 | /models/piglatinizer.rb | UTF-8 | 628 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def piglatinize(word)
if word.downcase.start_with?('a','e','i','o','u')
word + "way"
elsif word.downcase.start_with?('str', 'spl', 'spr')
word[3..-1] + word[0..2] + "ay"
elsif word.downcase.start_with?('bl', 'br', 'cl', 'cr', 'dr', 'fr', 'tr', 'th', 'fl', 'gl', 'gr','pl', '... | true |
71246899c6dd8312ea8234dbd2041127f55a88aa | Ruby | armchairdj/armchair-dj-rails | /app/models/concerns/listable.rb | UTF-8 | 1,837 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
concern :Listable do
class_methods do
def acts_as_listable(acts_as_list_scope)
acts_as_list(scope: acts_as_list_scope, top_of_list: 1)
scope :sorted, lambda {
joins(acts_as_list_scope).order(:"#{acts_as_list_scope}_id", :position)
}
end
def reorde... | true |
e017ccdd04cc4ce682bbfd52df4e6eb6cdea9579 | Ruby | uedy/study-ruby | /study1-2.rb | UTF-8 | 41 | 2.734375 | 3 | [] | no_license | def add(a, b)
a + b
end
puts add(1, 1)
| true |
3b2a932f5cc0aac8543ede742f4b15c5a5ecbdf7 | Ruby | alf-tool/alf-core | /lib/alf/support/coerce.rb | UTF-8 | 881 | 3.078125 | 3 | [
"MIT"
] | permissive | module Alf
module Support
# Defines all coercion rules, through Myrrha inheritance
Coercions = Myrrha::Coerce.dup.append do |g|
g.error_handler = lambda{|v,t,c|
raise TypeError, "Unable to coerce `#{v.inspect}` to `#{t}`", caller
}
g.coercion String, Time, lambda{|s,t| Time.pars... | true |
8cbce0fb61325220d1324c69b3c99557305359cf | Ruby | PhilippePerret/Collecte | /module/extracting/Extractor/Extractor/instance/filter_analyzer.rb | UTF-8 | 1,194 | 3.109375 | 3 | [] | no_license | # encoding: UTF-8
class Array
# Retourne True si le Array passe les conditions
# définies dans la procédure +procedure+
def passe_filtre? procedure
procedure.call(self)
end
end
class NilClass
def passe_filtre?(p) ; false end
end
class Collecte
class Extractor
# Analyse du filtre et transformation des ... | true |
05519c683d1be2516269972ebddca043cb9c97ec | Ruby | kevinjalbert/port_map | /lib/port_map/hosts.rb | UTF-8 | 702 | 2.609375 | 3 | [
"MIT"
] | permissive | module PortMap
module Hosts
PORT_MAP_TRACK_COMMENT = '#port_map'.freeze
HOSTS_FILENAME = '/etc/hosts'.freeze
def self.update
new_contents = contents
port_maps = JSON.parse(`list_port_maps`)
unless port_maps.empty?
new_contents += "\n127.0.0.1 #{port_maps.map { |port_map| port_m... | true |
2e75e6299abc5b431ec3cd77861f8824a1e22979 | Ruby | dimitras/GEOdatasets_analysis | /gene_locis.rb | UTF-8 | 1,168 | 3 | 3 | [] | no_license | # USAGE: ruby gene_locis.rb data/eqtl_browser/missed_genes_locis.txt data/eqtl_browser/missed_genes_locis_table.csv
# parse the efetch results from ncbi for the missing genes, and create a table with genename, geneid, start and stop genomic locations
# input file
missed_genes_locis_file = ARGV[0]
# output file
genes_... | true |
de8b52260c324edef172b2501e813d363f119621 | Ruby | denizkenan/wz2008 | /data/transform.rb | UTF-8 | 357 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'pry'
headlines = [:lfdnr, :wzcode, :bezeichnung, :isic]
couples = File.read('data/original.tsv').lines.map{|l|
t = l.split("\t")
t.pop
Hash[headlines.zip(t)]
}
current_category = nil
couples.each do |abschnitt|
if abschnitt[:wzcode][/^[A-Z]+$/]
current_category = abschnitt[:wzcode]
end
abschnit... | true |
5ef51cc586445d7d4a3ec27835eaf546a4595bc6 | Ruby | jjturner/sudoku-validator | /lib/puzzle.rb | UTF-8 | 671 | 3.21875 | 3 | [] | no_license | class Puzzle
attr_reader :puzzle_vals
def initialize(puzzle_file)
@puzzle_file = puzzle_file
self.consume
end
def consume
@puzzle_vals = @puzzle_file.scan(/\d/).map {|i| i.to_i }
end
def incomplete
@puzzle_vals.include? 0
end
def groupings
ret = []
ret << row_groups
ret <... | true |
6c35744c44aa5f78e230ed604a540042ff004eda | Ruby | cielavenir/procon | /codeforces/tyama_codeforces1097A.rb | UTF-8 | 89 | 2.671875 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
x,*a=$<.read.split
puts a.any?{|e|x[0]==e[0] || x[1]==e[1]} ? :YES : :NO
| true |
c9d8b8958656cec062592da41a651ced415e5fcc | Ruby | hslzr/curp_mx | /spec/curp_mx_spec.rb | UTF-8 | 2,058 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
RSpec.describe CurpMx do
it 'has a version number' do
expect(CurpMx::VERSION).not_to be nil
end
describe 'Validator class' do
it 'defines 33 RENAPO states' do
expect(CurpMx::Validator::STATES_RENAPO.length).to eq 33
end
it 'defines 78 problematic name initial... | true |
829101452f40093a5454480dc55674629718fc1e | Ruby | amycen/module-one-final-project-guidelines-nyc-web-051319 | /lib/helper.rb | UTF-8 | 5,103 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'uri'
def main_menu(user)
#menu_input = '0' for main menu
puts "\n\n"
puts " 🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆🍆 " .on_white.blink
puts " 🍆 🍆 ".on_white.blink
print " 🍆 ".on_white.blink
print " Welcome to Ripe Eggplant ".on_white.light_magenta
p... | true |
8bc8ea05d26a7d18ed7135b6d25b12e9f1857b15 | Ruby | Berta-G/Takeaway | /lib/Takeaway.rb | UTF-8 | 668 | 3.125 | 3 | [] | no_license |
require 'time'
class Takeaway
WAITING_TIME = 3600 # in seconds
def initialize(menu=nil, sender=nil)
@menu, @sender = menu, sender
end
attr_reader :menu, :sender
def list_menu
menu.to_s
end
def receive_order order
raise "Empty order" if order.total_lines == 0
send_text(order) if sender && order.ph... | true |
52f373ce527a6793fc0a0df622d2e03ee8798fc6 | Ruby | krismac/course_notes | /week_04/day_2/rock_paper_scissors/solution_vs_computer/models/rps_game_advanced.rb | UTF-8 | 1,145 | 3.53125 | 4 | [] | no_license | class RpsGame
attr_reader(:player_move, :computer_move, :all_moves)
def initialize(move_played)
@player_move = move_played.to_sym
@win_lookup = [
{scissors: :paper},
{paper: :rock},
{rock: :lizard},
{lizard: :spock},
{spock: :scissors},
{scissors: :lizard},
{lizar... | true |
3b23479029a3fbfa52ba103d595109afbd6fe71b | Ruby | Tim-K-DFW/vultures_ruby | /Classes/company_table.rb | UTF-8 | 255 | 2.9375 | 3 | [] | no_license | class CompanyTable
attr_accessor :main_table, :size
def initialize
@main_table = {}
@size = 0
end
def add(item)
main_table[(item.cid).to_sym] = item
@size += 1
end
def where(args)
main_table[args[:cid].to_sym]
end
end
| true |
0e23ceec2c8a8a64715d1548afc258f16d90eb6a | Ruby | getadeo/code-snippets | /ruby-snippets/file_negative_position.rb | UTF-8 | 91 | 2.53125 | 3 | [] | no_license | f = File.open "god.txt"
f.pos = -20
puts "Reading file with f.pos = #{f.post}"
puts f.gets
| true |
869b7d93dda4744b6bbc9e71ef29758151585752 | Ruby | rietta/csv_cleaner | /csv_cleaner.rb | UTF-8 | 2,800 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Super Simple CSV Cleaner
# Copyright 2012 Rietta Inc.
# Licensed under terms of BSD License.
require 'csv'
require 'optparse'
#
# Process the CSV input using default settings and trim every cell.
#
def clean_csv(input, output)
#raise "TODO: Implement CSV cleaner function!"
raise "Expect an ... | true |
307523ab8884d6785ae57242de90964da4e03e36 | Ruby | Sushanthbc/ds_algo | /linked_list/tc_linked_list.rb | UTF-8 | 784 | 3.078125 | 3 | [] | no_license | require "test/unit"
require_relative "linked_list"
class TestLinkedList < Test::Unit::TestCase
def test_add_item_to_linked_list
add_item_instance = LinkedList.new
add_item_instance.add_item(4)
assert_equal(4, add_item_instance.head.data)
end
def test_remove_item
remove_item_instance = LinkedList... | true |
7cc0c9c5cc6c9db97fede21e86a0602fca44f2c7 | Ruby | Thomascountz/peanuts | /spec/support/datetime_form_filler.rb | UTF-8 | 457 | 2.828125 | 3 | [
"MIT"
] | permissive | # fills in appropirate datetime select boxes with given datetime object
def select_date_and_time(date, options = {})
field = options[:from]
select date.strftime('%Y'), :from => "#{field}_1i" #year
select date.strftime('%B'), :from => "#{field}_2i" #month
select date.strftime('%d'), :from => "#{field}_3... | true |
a5877b1719e5fcd44b1f8d68a22b891eb44f4f6d | Ruby | awilsongithub/awilsongithub.github.io | /code reference toolbox/ruby & rails/chris_pine_ruby/my_ruby_examples.rb | UTF-8 | 3,040 | 3.96875 | 4 | [] | no_license | ###########################################################
# #
# chris pine ruby tutorial #
# https://pine.fm/LearnToProgram/chap_05.html #
# #
####################... | true |
6a7d87f923f7ce0421fd6b84e36df666556b83bc | Ruby | El-Treshka/Tasks_rb | /3/61.rb | UTF-8 | 75 | 2.9375 | 3 | [] | no_license | def t61(x)
puts x.floor
puts x
puts x.round(0)
end
t61(5.6) | true |
a215e3003ab5e2356e2e4639dada028eac5c9863 | Ruby | vrunda2712/ruby-fundamentals | /exercise2.rb | UTF-8 | 418 | 3.984375 | 4 | [] | no_license | #tip for $55 meal
puts "tip is $#{55.0*10/100} for meal."
puts "with $#{55.0*10/100} tip total bill should be $#{55.0*10/100+55.0}."
#integer and string with + operator
tip = 5
#puts "Tip: " + (tip.to_i)
puts "Tip: #{tip.to_i}"
#string interpolation
puts "45628 * 7839 = #{45628*7839}."
#value of expression
if (1... | true |
aeddbb9b3cb69fbafdeb5336bf2a4fd47aa49468 | Ruby | Velfolt/explorion | /lib/character/feet.rb | UTF-8 | 1,318 | 2.625 | 3 | [] | no_license | class Feet < Chingu::GameObject
def initialize(options = {})
super
@step1_sound = Sound['step1.mp3']
@step2_sound = Sound['step2.mp3']
@animation = Chingu::Animation.new(:file => "foot.png")
@frame_name = :idle
@animation.frame_names = { :idle => 0..0, :move => 1..2 }
@animation.on_fr... | true |
f83737f7e07b555f87afb7faa930456a3c47bcb4 | Ruby | kamarsh1/connect-four | /app/models/human_player.rb | UTF-8 | 155 | 2.984375 | 3 | [] | no_license | class HumanPlayer < Player
def pick_a_column(current_player)
puts "#{current_player.name} pick a column (1 through 7)"
gets.chomp.to_i
end
end
| true |
d4c2ca36c7a4d7c67fe296d06bbb0129be1a922f | Ruby | Mjtala/TestingTarea1 | /test/mine_unit_test.rb | UTF-8 | 2,245 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'test_helper'
require_relative '../lib/board_controller'
require_relative '../lib/board_model'
require_relative '../lib/board_view'
require 'test/unit'
# Testeo de minesweeper
class MineUnitTest < Test::Unit::TestCase
def test_reveal_boxes_move
new_board = Board.ne... | true |
007b84251c411158304cceaa147b19604e564cdf | Ruby | rarachocolate/dragon_quest | /character.rb | UTF-8 | 270 | 3.59375 | 4 | [] | no_license | class Character
attr_reader :name, :hp, :offense, :defense
def initialize(name: "勇者", hp: 100, offense: 50, defense: 40)
@name = name
@hp = hp
@offense = offense
@defense = defense
end
def attack(enemy_hp)
enemy_hp -= offense
end
end | true |
e9bf7f4e89f1a0d4f7a9a9a89778b921f1250b4e | Ruby | minirachel/nyc-greenthumb-gardens | /lib/scraper.rb | UTF-8 | 654 | 2.828125 | 3 | [
"MIT"
] | permissive | require_relative '../config/environment.rb'
require 'pry'
require 'httparty'
class Scraper
def self.gardens_api
site = 'https://data.cityofnewyork.us/resource/p78i-pat6.json'
page = HTTParty.get(site)
greenthumb_gardens = page.to_a
greenthumb_gardens
end
def self.create_sy... | true |
74abdf222c3c805bd0e5044e8d74b47da46840e9 | Ruby | blm768/bookie | /bookie/lib/bookie/formatter.rb | UTF-8 | 5,230 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'bookie/database'
require 'date'
require 'spreadsheet'
module Bookie
##
#Takes jobs from the database and creates summaries and tables in various output formats.
class Formatter
##
#Creates a new Formatter object
#
#<tt>type</tt> should be a symbol that maps to one of the files in <tt>bo... | true |
b086917c7aff628d55d3830dccb31e7b2369b296 | Ruby | Auralcat/100-days-of-code | /scripts/#songsToCSV.rb# | UTF-8 | 2,142 | 3.109375 | 3 | [] | no_license | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# This buffer is intended to help me learn to work with CSV files
require 'csv'
require 'find'
# You can use Find.find to get the list of directories to crawl:
def get_album_dir_list(music_library_dir)
dir_list = []
Find.find(music_library_dir).each do |filepath|
san... | true |
a09682f54fd6c0e56ad4105cd4b1786669d2f3fd | Ruby | JRJurman/ScrabbliSolver | /Board.rb | UTF-8 | 2,200 | 3.953125 | 4 | [] | no_license | require "colorize"
require "./Tile.rb"
# Board Class, defines a scrabble board on which several tiles exist
class Board
attr_accessor :board
# Creates a new board, reads in from an ASCII txt file
# and generates a 2 dimensional array
def initialize( boardFile )
@board = [[]]
f = File.open( boardFile )... | true |
9e8435942024324d3cff4ce829114c3fd7000edf | Ruby | kscotteng/weather_report | /test.rb | UTF-8 | 655 | 3.15625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './conditions.rb'
require './forecast.rb'
class Conditions
def initialize(zip)
@response = JSON.parse(File.read("conditions.json"))
end
end
class Forecast
def initialize(zip)
@response = JSON.parse(File.read("forecast.json"))
end
end
class ... | true |
71cdecf9ff50425a4c6b7fb6c306e80bd069f260 | Ruby | dealerignition/scraping_tools | /fabrica/parse_excel.rb | UTF-8 | 2,430 | 2.875 | 3 | [] | no_license | require 'rubygems'
require 'roo'
workbook = Excelx.new("DI_FABCarpet.xlsx")
workbook.default_sheet = workbook.sheets.first
carpets = {}
cur_carpet = nil
new_carpet = {:name => "", :details => "", :warranty => "", :brand_name => "", :fiber_name => "", :texture_name => "", :room_image_url => "", :colors => [], :styles... | true |
0b2d617432ec280568955d9a2dc69ec8fec7e9e0 | Ruby | DigitalKnight0/hangman | /lib/game.rb | UTF-8 | 1,078 | 3.359375 | 3 | [] | no_license | require './wordgen'
require './display'
require './logic'
require './saveload'
class Game
include Wordgen
include Display
include Logic
include SaveLoad
attr_accessor :turns, :grid, :key
def initialize
@turns = 8
@grid = []
@key = []
end
def play
if welcome == 1
self.key = gen_... | true |
af954ef90eeb2c7ef0ff214793c1a7d7b3e89c3d | Ruby | aspotashev/isearch-generate-dump | /lib-pyload.rb | UTF-8 | 2,994 | 3.484375 | 3 | [] | no_license |
require 'yaml'
require 'iconv'
String.class_eval do
def pyload
StringPyParser.new(self).parse
end
end
class StringPyParser
class StringPyParser::Nil ; end
def initialize(s)
@s = s
@i = 0
end
def pnil?(x) # parser nil
x.is_a?(StringPyParser::Nil)
end
def c(x = nil)
if x.nil?
@s[@i..@i]
elsif... | true |
e8fc7499f8bac73d77937ab1a912a74b03e6fdd7 | Ruby | rummelonp/gifvj | /app/models/blog.rb | UTF-8 | 1,751 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'open-uri'
class Blog
include Cacheable
class Error < StandardError
end
class InvalidName < Error
end
class ImageNotFound < Error
end
RECENT_NAMES_KEY = "#{NAMESPACE}:blog:recent_names"
MAX_IMAGE_SIZE = 45
def self.recent_names
cache.hgetall(RECENT_NAMES_KEY)
.to_a
.so... | true |
013e3bf8ca1158c777ba7f5b9103db4e065a2901 | Ruby | BenJohnCarson/oystercard | /lib/journey.rb | UTF-8 | 478 | 3.46875 | 3 | [] | no_license | class Journey
MINIMUM_CHARGE = 1
PENALTY = 6
attr_reader :trip
def initialize
@trip = {}
end
def start(station)
@trip[:entry_station] = station
end
def finish(station)
@trip[:exit_station] = station
end
def fare
journe... | true |
f31e90edcd81c250bd338696731132778cffb56f | Ruby | Schwad/hobix | /contrib/txp-to-hobix.rb | UTF-8 | 1,513 | 2.859375 | 3 | [
"MIT"
] | permissive | #
# txp_to_hobix.rb
#
# Converts a textpattern xml dump file generated with sqldump into a set of Hobix YAML entry files.
#
# Hobix::Entry code lifted from http://www.anvilwerks.com/src/wordpress_to_hobix.rb
#
# (c) 2005 erngui.com
#
require "rexml/document"
include REXML # so that we don't have to prefix everything ... | true |
bd92c8e41b3a219f1b5616cc3baad53f4804bd94 | Ruby | abates/ruby_expect | /lib/ruby_expect/procedure.rb | UTF-8 | 4,560 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | #####
# = LICENSE
#
# Copyright 2012 Andrew Bates 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... | true |
3f1782b508b070bc015beb390ff5354589cea2d8 | Ruby | UberMouse/stock-exchange | /src/app/stock_exchange.rb | UTF-8 | 1,444 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'db/config'
require 'app/services/stock_service'
require 'app/models/transaction'
class StockExchange
def initialize(args)
command = args.shift
command = 'list' if command.nil?
@service = StockService.new
send(command.to_sym, *args)
# the following case statement is equivalent to the s... | true |
6838a9fd7a8c6b26b2bc9f2527636e8c10fb8403 | Ruby | marcelgalang/ttt-7-valid-move-q-000 | /lib/valid_move.rb | UTF-8 | 376 | 3.578125 | 4 | [] | no_license | # code your #valid_move? method here
def valid_move?(board, position)
if position.to_i < 0 || position.to_i > 8
false
elsif position_taken?(board, position)
false
else
board = Array.new(9, " ")
true
end
end
def position_taken?(board, position)
if board[position.to_i-1] == "X" || board[posi... | true |
deb404c2e8ab0ea7922019a752f202099e0f8b97 | Ruby | nekokat/codewars | /7kyu_1/complete-the-pattern-number-1.rb | UTF-8 | 173 | 3.390625 | 3 | [
"Unlicense"
] | permissive | #Kata: Complete The Pattern #1
#URL: https://www.codewars.com/kata/5572f7c346eb58ae9c000047
def pattern(n)
(1..n).map.with_index{|x, y| x.to_s*y.next}.join("\n")
end | true |
3528a80a624d937f30c34823fdf3e51fbda63e60 | Ruby | ktp-forked-repos/csci400 | /08_ruby_nim/nimTest.rb | UTF-8 | 1,104 | 2.984375 | 3 | [] | no_license | require "test/unit"
require_relative "NimPlayerSmart"
class TestSmartPlayer < Test::Unit::TestCase
TEST_BOARD_1 = [3, 7, 9]
TEST_BOARD_2 = [0, 3, 5, 7]
TEST_BOARD_3 = [2, 3, 7]
def setup
@player = NimPlayerSmart.new
end
def testDigitalSum
assert_equal 13, @player.digital_sum(TEST_BOARD_1)
ass... | true |
07e74495d3e75ed16dfa286bd733dc20beab014e | Ruby | yooh-digital/omnicontacts | /lib/omnicontacts/importer/outlook.rb | UTF-8 | 4,213 | 2.65625 | 3 | [
"MIT"
] | permissive | require "omnicontacts/middleware/oauth2"
require "omnicontacts/parse_utils"
require "json"
# API Docs: https://msdn.microsoft.com/en-us/office/office365/api/api-catalog#Outlookcontacts
module OmniContacts
module Importer
class Outlook < Middleware::OAuth2
include ParseUtils
attr_reader :auth_host, :... | true |
766b8a31c9db376c0e1bdb723450b3491a6d41b9 | Ruby | h-takuto/RubyPractice | /base/scope.rb | UTF-8 | 546 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env ruby
class Japan
def initialize(primeminister)
@primeminister = primeminister
end
def people_saying
puts "消費税を上げないで、#{@primeminister}!"
end
end
class UK
primeminister = 'David Camelon'
def people_saying
puts "消費税を上げないで、#{primeminister}!"
end
end
class USA
@@primeminister = ... | true |
8f1c582b160ea5315aaf20c48e7d35b074d9f599 | Ruby | emcooper/apicurious | /app/models/user_profile.rb | UTF-8 | 644 | 2.53125 | 3 | [] | no_license | class UserProfile
attr_reader :num_followers,
:num_following,
:profile_picture,
:num_starred_repos,
:recent_activity,
:organizations
def initialize(user)
github_service = GithubService.new(user)
@num_followers = github_service.num_follow... | true |
87bf58283f4a95081623d13c4cd2ef4c1b70a799 | Ruby | bbnurse/array-methods-lab-online-web-prework | /lib/array_methods.rb | UTF-8 | 566 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_include("wow", "I", "am", "really", "learning", "arrays!")
using_include.include?("wow")
end
def using_sort("wow", "I", "am", "really", "learning", "arrays!")
using_include.sort
end
def using_reverse("wow", "I", "am", "really", "learning", "arrays!")
using_reverse.reverse
end
def using_first("wow", ... | true |
6beebaeb45ca0e1da8d07b3975c65f5eea26d10a | Ruby | slamplug/wso2esb | /lib/puppet/parser/functions/calc_mgmt_host.rb | UTF-8 | 538 | 2.5625 | 3 | [] | no_license | #
# calc_mgmt_host.rb
#
module Puppet::Parser::Functions
newfunction(:calc_mgmt_host, :type => :rvalue, :doc => <<-EOS
This calculates wso2 calc_mgmt_host. Takes 1 args
1. servername
EOS
) do |arguments|
raise(Puppet::ParseError, "calc_mgmt_host(): Wrong number of arguments " +
"given (#{ar... | true |
11d055c46214de64ea0e31f1557d808ba04daf58 | Ruby | jlx012/ruby_august_2017 | /leslie_hayes/rails/dojo_ninjas/test/commands.rb | UTF-8 | 3,989 | 3.53125 | 4 | [] | no_license | # # 1. Start a new project (the name of the project should be 'dojo_ninjas')
# rails new dojo_ninjas
# # 2. Create appropriate tables/models.
# rails g model Dojo name:string city:string state:string
# rails g model Ninja first_name:string last_name:string dojo:references
# rake db:migrate
# # 3. Using Ruby console:
... | true |
c69e4a5aac9e967671d25268fffd5d09e9f0997a | Ruby | DeuterGraves/snowman_game_lab | /specs/game_spec.rb | UTF-8 | 734 | 3.484375 | 3 | [] | no_license | # A Game will have properties for a Player object, a HiddenWord object, and an array of guessed_letters
require("minitest/autorun")
require("minitest/rg")
require("pry")
require_relative("../game.rb")
require_relative("../player.rb")
class GameTest < MiniTest::Test
def setup()
player_1 = Player.new("Puck", 6)... | true |
3af36d6bb39f863769b6cbc428857c8d9f01bf4c | Ruby | tomdalling/test-bench | /lib/test_bench/output/summary/run/print.rb | UTF-8 | 2,661 | 2.6875 | 3 | [
"MIT"
] | permissive | module TestBench
module Output
module Summary
module Run
module Print
extend self
def call(file_count: nil, test_count: nil, pass_count: nil, skip_count: nil, failure_count: nil, error_count: nil, elapsed_time: nil, writer: nil)
file_count ||= 0
test_coun... | true |
b22037cb5f948987ed4fa2867b14f70e104bdf19 | Ruby | DeliSauce/homeworks | /W2D2/tests.rb | UTF-8 | 1,114 | 3.96875 | 4 | [] | no_license | class Animal
attr_accessor :type
def initialize(type = "animal")
@type = type
end
end
class Human < Animal
attr_accessor :typing_sys
def initialize(type)
super
@type = "hutype"
end
end
peter = Human.new("human")
p peter.type
# p peter.typing_sys
class Municipality
attr_reader :state
... | true |
65e2e7fa5b81827d32167de51839a2d6863ff2a9 | Ruby | lpenzey/interview_exercises | /cracking_the_code_interview/chapter_1/1.3_urlify/lib/urlify.rb | UTF-8 | 525 | 3.703125 | 4 | [] | no_license | # frozen_string_literal: true
# URLify: Write a method to replace all spaces
# in a string with '%20'. You may assume that
# the string has sufficient space at the end
# to hold the additional characters, and that
# you are given the "true" length of the string.
# (Note: If implementing in Java, please use a
# charact... | true |
7430598f943791b8f33cc6c74cc5dfa3289cee2d | Ruby | jchabra/ruby | /quizzes/quiz10.rb | UTF-8 | 463 | 3.765625 | 4 | [] | no_license | #prompt user for a number?
puts "Input a number."
#that number will go into a variable called response
response = gets.to_i
#response.explode #this will cause an error, but there should be no error
begin
total = response**2
rescue
total.explode
retry
end
puts "the square of #{response} is #{total}."
#"the squar... | true |
ce96dac5cc9613d2bceed25f1bdf7c3b491a7520 | Ruby | TPei/faas_orchestrator | /spec/post_function_spec.rb | UTF-8 | 2,713 | 2.546875 | 3 | [
"MIT"
] | permissive | RSpec.describe PostFunction do
before do
@logger = Logger.new(STDOUT)
@logger.level = Logger::FATAL
end
describe '#execute' do
context 'with successful POST call' do
before do
@name = 'name'
@response = 'hello from function'
allow(Net::HTTP).to receive(:new).and_return(h... | true |
cbf6a6fd0e059722a11cde0b63016bd15664ca37 | Ruby | tescherm/project_euler | /ruby/problem_9.rb | UTF-8 | 299 | 2.859375 | 3 | [] | no_license | #!/bin/env ruby
#
# Problem 9
#
# Author:: mattt
#
require 'ruby/euler_lib'
timed_run {
triples = PythagoreanTriples.new
triple_product = 0
loop do
a,b,c = triples.next_triple
if a + b + c == 1000
triple_product = a * b * c
break
end
end
puts triple_product
} | true |
d3ee3b3da92d0b6fdb5136fa79bbf6640c701e1e | Ruby | tenderlove/quail | /lib/quail/handle.rb | UTF-8 | 864 | 2.625 | 3 | [
"MIT"
] | permissive | module Quail
class Handle
class << self
def start host, &block
new(host).start(host, &block)
end
end
attr_accessor :host, :handle
def initialize host
@host = host
@started = false
@handle = nil
end
def started?
@started
end
def start host ... | true |
a3c03c5198401523d23bd20b1a6444bf8b1a41d0 | Ruby | UpAndAtThem/100-109-Small-Problems | /medium_2_08.rb | UTF-8 | 912 | 4.34375 | 4 | [] | no_license | # A featured number (something unique to this exercise) is an odd number that is a multiple of 7,
# and whose digits occur exactly once each. So, for example, 49 is a featured number,
# but 98 is not (it is not odd), 97 is not (it is not a multiple of 7), and 133 is not (the digit 3 appears twice).
# Write a method t... | true |
99c67198571bbee2e6d803ed095ab425d6e07b1a | Ruby | ksmxxxxxx/ruby-practices | /09.wc_object/lib/reader.rb | UTF-8 | 689 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
module Wc
class Reader
InputData = Struct.new(:filename, :linecount, :wordcount, :stringcount)
attr_reader :data
def initialize(data)
@data = data
end
def make_data_structure
data.instance_of?(Array) ? make_file_structures : make_text_structure
end... | true |
969a1ddde284b9b07e993fa60ffb93ed71c7ac1c | Ruby | shoheifukui/furima-29679 | /spec/models/purchase_spec.rb | UTF-8 | 2,967 | 2.65625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Purchase, type: :model do
before do
@purchase = FactoryBot.build(:purchase)
end
describe '商品購入機能' do
context '商品購入がうまくいくとき' do
it 'クレジットカード番号、有効期限の年月、セキュリティコード、postal_code,prefecture_id,city,address,phone_numberが入力されていれば購入できる' do
expect(@purchase).to b... | true |
9ea2220f7ac5efb4e0f5a9966668a7d67e8fdc23 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz9_sols/solutions/Brian Schroeder/probabilities.rb | UTF-8 | 1,235 | 2.8125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
include Math
def t(n, r, p)
return 1 if n <= 1
slices = ([2.0, n.to_f * log(1 - r) / log(p)].max).ceil
slices + (1 - p) * slices * t(n / slices, r, p)
end
results = {}
r_samples = 256
p_samples = 1000
R_SAMPLE_POINTS = (1..r_samples).map{|r| (r.to_f / (r_samples + 1)) ** 3}
P_SAMPLE_POINTS = ... | true |
1f8fb154dc78b9f95e5042d92b3cfba85b81a1c9 | Ruby | sandzu/w3d2 | /aa_questions/questions_database.rb | UTF-8 | 1,759 | 2.75 | 3 | [] | no_license | require 'sqlite3'
require 'singleton'
class QuestionsDatabase < SQLite3::Database
include Singleton
def initialize
super('questions.db')
self.type_translation = true
self.results_as_hash = true
end
end
#
# class User
# attr_accessor :id, :fname, :lname
#
# def self.all
# data= QuestionsDa... | true |
4a8de121cbe263583339a31abf2032e33d68db65 | Ruby | old-school-devv/ebay_trader_support | /exe/ebay_seller_list | UTF-8 | 3,901 | 2.515625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'active_support/time'
require 'json'
require_relative './helper'
include ExecutableHelper
require_relative '../lib/ebay_trader_support/get_seller_list'
include EbayTraderSupport
class SellerList
PER_PAGE = 200
attr_reader :number_of_pages
def initialize
options.seller_id = n... | true |
9168bcb4ff4e4c04434dde2f2a01b17b0b93a091 | Ruby | WilfredTA/ruby_basics | /small_problems/easy4/multiples.rb | UTF-8 | 989 | 4.84375 | 5 | [] | no_license | #Write a method that searches for all multiples of 3 or 5 that lie between 1 and some other number, and then computes the sum of those multiples.
# For instance, if the supplied number is 20, the result should be 98 (3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20).
#You may assume that the number passed in is an integer grea... | true |
b3b98204ba8e08f64a517fdf16b29d45bf7f8f29 | Ruby | diegopiccinini/print_primes_table | /lib/print_primes_table/validators/help_validator.rb | UTF-8 | 600 | 2.8125 | 3 | [
"MIT"
] | permissive |
module PrintPrimesTable
module Validators
# @author Diego Hernán Piccinini Lagos
# to validate the --help option
class HelpValidator
class << self
# validate the arguments of --help option
# @param args [Array] the help option hasn't arguments
# @return [Symbol | String] :valid or an Error Mess... | true |
5c6d8774b76a92842164287ab7373e86870d9ca7 | Ruby | keryi/ruby-design-patterns | /decorator/check_summing_writer.rb | UTF-8 | 305 | 3.015625 | 3 | [] | no_license | class CheckSummingWriter < WriterDecorator
attr_reader :check_sum
def initialize(writer)
@writer = writer
@check_sum = 0
end
def write_line(line)
line.each_byte { |byte| @check_sum = (@check_sum + byte) % 256 }
@check_sum += '\n'.ord % 256
@writer.write_line(line)
end
end
| true |
f3dba06a00f3b5f13f4005f862274fc02df5f90a | Ruby | aramoe/homework-ruby | /draw/nezuko.rb | UTF-8 | 789 | 3.015625 | 3 | [] | no_license | #!/usr/bin/env ruby -I.
require "my_png"
MAG = 30
PINK = [ 0xFF, 0x66, 0x99 ]
BLACK = [ 0, 0, 0 ]
png = MyPNG.new(500, 500, color: PINK)
xz, yz = 0, -50
10.times do
x0, y0 = xz, yz
15.times do
x1, y1 = x0 + MAG, y0
x2, y2 = x1 + MAG, y0
x3, y3 = x2 + MAG, y0
x4, y4 = x0 + MAG * 1.5, y0 - MAG * 0... | true |
5c87c4b414287b05a8cf2aee6372667168fc022c | Ruby | waseem-ghafoor/budget_planner | /app/models/loan.rb | UTF-8 | 2,976 | 2.578125 | 3 | [] | no_license | class Loan
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
field :description, type: String
field :value, type: Float
field :emi, type: Float
field :start_date, type: Date
field :end_date, type: Date
embedded_in :user
validates :description, presence: true, length:... | true |
be04a35d10d1a1cbeaac73047aed8a21d4a410df | Ruby | naveenagarwal/school_builder | /app/models/group.rb | UTF-8 | 1,763 | 2.765625 | 3 | [] | no_license | class Group < ActiveRecord::Base
###############
# Associations
###############
has_many :students
has_many :test_results
###############
# Class Methods
###############
class << self
def performance_data_for_charting
tests = Test.all
groups = Group.all
average_marks, data = ... | true |
f61a4e3441e534cb9125c696596b6a1be2ac48f1 | Ruby | willnance/doctor-self-study | /app/controllers/assignments_controller.rb | UTF-8 | 4,014 | 2.578125 | 3 | [] | no_license |
#authors Will Nance and Sanket Prabhu
class AssignmentsController < ApplicationController
before_filter :store_location, :only => [:respond]
#before_filter :confirm_admin , :except => [:show, :edit]
before_filter :confirm_logged_in ,:only =>[:respond]
layout 'admin'
#list all assignments for a particu... | true |
1d9e1f8a5a90a1620a847a6c95fab50acda06346 | Ruby | cananz/cli-applications-simple-blackjack-dc-web-080519 | /lib/blackjack.rb | UTF-8 | 1,081 | 3.875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
return rand(1..11)
end
def display_card_total(total)
puts "Your cards add up to #{total}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
gets.chomp
end
def end_game(total)
puts "Sorry, you hit #{total}... | true |
d57ac8507cbab28b987c81491c8504600abb2878 | Ruby | Bossanov/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 375 | 2.671875 | 3 | [] | no_license | require 'faker'
require "faker"
CATEGORY = ["chinese", "italian", "japanese", "french", "belgian"]
10.times do
restaurant = Restaurant.create!(
name: Faker::Hipster.word,
address: Faker::Address.street_address + ", " + Faker::Address.zip_code + ", " + Faker::Address.city,
tel: Faker::PhoneNumber.cell_pho... | true |
7f77b4573a9f6e54de6967364a6c4eaae5cef32a | Ruby | rubocoptero/monopoly-domain-first | /system/src/system.rb | UTF-8 | 447 | 2.671875 | 3 | [] | no_license | require 'sinatra'
require 'json'
require_relative './create_game'
require_relative './take_turn'
post '/create_game' do
context = {'name': request_body['name']}
message = CreateGame.do(context)
json message
end
post '/take_turn' do
context = {'game_name': request_body['name']}
message = TakeTurn.do(contex... | true |
6046a08cf97fb77e3bd324df02ee2dd77c133d0e | Ruby | amit/kachara | /cp_convert.rb | UTF-8 | 2,686 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
# This module helps convert the cp1252 encoded characters which are part of
# some of the evil web pages which wrongly advertize utf8 encoding.
#
# Author: Amit Chakradeo (http://amit.chakradeo.net/)
# Copyright:: Copyright (c) 2009 Amit Chakradeo
# License:: WTFL (http://sam.zoy.org/wtfpl/COPYING)... | true |
66acb55a03b48cafb26f84309cf137016d8613f7 | Ruby | sciencehistory/scihist_digicoll | /app/models/compact_user_agent.rb | UTF-8 | 1,610 | 3 | 3 | [
"Apache-2.0"
] | permissive | # Tries to parse the user-agent to make a much more compact representation of what we'd
# eally want to know from it, to keep our logs shorter
#
# Currently implemented with device_detector gem.
class CompactUserAgent
attr_reader :user_agent
def initialize(user_agent)
@user_agent = user_agent
end
def com... | true |
4e657301c6624b02b652879441842725693fea75 | Ruby | svenfuchs/routing-filter | /lib/routing_filter/filters/uuid.rb | UTF-8 | 1,235 | 2.765625 | 3 | [
"MIT"
] | permissive | # The Uuid filter extracts an UUID segment from the beginning of the recognized
# path and exposes the page parameter as params[:page]. When a path is generated
# the filter adds the segments to the path accordingly if the page parameter is
# passed to the url helper.
#
# incoming url: /d00fbbd1-82b6-4c1a-a57d-098d52... | true |
1c20e1dcda5cf9d1ac957f69952b33044a056129 | Ruby | sametcilli/odin | /tictac/Player.rb | UTF-8 | 144 | 3.484375 | 3 | [] | no_license | class Player
def initialize()
baptise
end
def baptise
puts "give this Player a name: "
@name = (gets)
end
def name
@name
end
end | true |
a0e3c8d2ddf5b92616922cddec80de5b9f06cb12 | Ruby | henryDozie/HJH-Financial | /transactions.rb | UTF-8 | 551 | 2.859375 | 3 | [] | no_license | require_relative 'accounts'
class Transactions < Account
def initialize
# @history = []
end
def Create_account
super
puts "Your account has been created successfully"
end
def Withdraw
super
puts "Transaction complete"
end
def Deposit
puts "Transaction complete"
end
def Tr... | true |
303fccca99cd86b8e886378825b7f5819b97982c | Ruby | Pluvie/italian-ruby | /lib/italian/ruby/metodi/set.rb | UTF-8 | 489 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
class Set
##
# Congela in profondità l'insieme.
def congela_in_profondità
self.each do |element|
next unless element.respond_to? :congela_in_profondità
element.congela_in_profondità
end
self.freeze
self
end
##
# Converte l'insieme in una mappa.
... | true |
2c1da6ba1cd0ba9b041ab446eed75c932da24530 | Ruby | socialchorus/topical | /lib/topical/stopwords.rb | UTF-8 | 563 | 3.21875 | 3 | [
"MIT"
] | permissive | module Topical
class Stopwords
attr_accessor :words
def initialize
@words = []
end
def load(path)
new_collection = words + split_words_on(path)
self.words = new_collection.map {|word| trim(word) }.uniq.sort
end
def split_words_on(path)
path = stopwords_path(path) if... | true |
223c9d633d4aaf241ab6b1b1da790440f72d7505 | Ruby | GeorgieGirl24/Front-End | /app/facades/cars_facade.rb | UTF-8 | 258 | 2.65625 | 3 | [] | no_license | class CarsFacade
def self.new_car(car_params, current_user)
CarService.new_car(car_params, current_user)
end
def self.get_cars(current_user)
cars = CarService.get_cars(current_user)
cars.map do |car|
Car.new(car)
end
end
end
| true |
f8703e2cc7a9de3b66c809f04916471dde661de0 | Ruby | vladveterok/library | /library/library.rb | UTF-8 | 788 | 3 | 3 | [] | no_license | # frozen_string_literal: true
# Library class collects entities, saves library state into library.yaml and loads it
class Library
include Loader
include Statistics
attr_reader :orders
def initialize
@authors = []
@books = []
@readers = []
@orders = []
add_to_library(*load)
end
de... | true |
0ab2dad019d2c9d71ddd0b19b3218bde7202a40c | Ruby | jordynmindorff/learning-ruby | /4. Data Iteration/blocks.rb | UTF-8 | 2,305 | 4.46875 | 4 | [] | no_license | # * Block Basics
=begin
Block = a group of code connected to a method call (can't have a block without a method), to be executed at some time
Block != an object of any kind
Block can be defined with {} or do & end keywords (do end is convention for multi-line)
Blocks are only invoked one, do not persist, have seperate ... | true |
12d490fc33670061cd2f7acff5b02f9fc3f2e2d6 | Ruby | amedveczki/words | /sentences.rb | UTF-8 | 1,926 | 3.515625 | 4 | [] | no_license |
def find_words(sentence)
return sentence.scan(/\w+/).each { |x| x.downcase! }
end
def find_sentences(fname, max = 0)
current = 0
sentences = []
$sentence_regex = /.*?[^.?!][.?!]([^.?!]|[\n\r])/m
f = File.open fname
if f
# # print "Ok, #{fname} is now open.\n"
else
# # print "Could not open #{... | true |
304ad5163d367993cdcf796850c8c0e1632ff07d | Ruby | WakouTTD/learning-ruby | /Lesson13_2.rb | UTF-8 | 93 | 3.015625 | 3 | [] | no_license | class Student
def avg()
p (80 + 70) / 2
end
end
a001 = Student.new
a001.avg | true |
e2ef8b8458eb3e6127f7324a47820b523778f256 | Ruby | prestonseandavis101/anagram-detector-onl01-seng-pt-081720 | /lib/anagram.rb | UTF-8 | 749 | 4.4375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Anagram #----> defines class that we are working with
attr_accessor :word #----> we are working with words, to set your getter and setter method to #word, then we can work with any word
def initialize(word) #---> initializes word, this just needs to be habit
@word = word
end
def mat... | true |
34946bd3e2b26bacda80a777590cbbf493775f27 | Ruby | acg2176/ruby-music-library-cli-online-web-sp-000 | /lib/musicimporter.rb | UTF-8 | 1,142 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path
def initialize(path)
@path = path
end
def files
file_list = []
Dir["#{path}/*.mp3"].each do |file|
file = file.split("/") # "Song - artist - genre.mp3"
file_list.append(file[4])
end
file_list #returns the filenames
end
def import
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.