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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f8f4eb5fe455f31ed2cb6f1f780bcb491e6344e9 | Ruby | aurelienbottazini/Code-Kata | /Ruby-Quiz/03.GEDCOM_Parser/gedcom_parser.rb | UTF-8 | 954 | 2.796875 | 3 | [] | no_license | require 'rexml/document'
class GEDCOMParser
def initialize filepath
@gedcom_lines = File.readlines(filepath)
end
def to_xml
xml_root = REXML::Element.new('gedcom')
stack = Array.new
stack.push xml_root
last_depth = 0
@gedcom_lines.each do |line|
splitted_line = line.chomp.split(/... | true |
8e30bd14c0aa6aa07c4d4d825ce5fc31374a337d | Ruby | Anutka777/reps-counter | /lib/rep_counter.rb | UTF-8 | 707 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
# Counter of reps for pyramid workout
class RepCounter
def simple_pyramid(height)
sequence = 1.step(by: 1).take(height)
sequence.inject { |total, set| total + set }
end
def dimond_pyramid(height)
sequense_increased_part = 1.step(by: 1).take(height / 2)
sequense_decr... | true |
6f49a708e82fed5e82317761d3949597e0ac9860 | Ruby | NickDongoske/programming-univbasics-4-square-array-denver-web-010620 | /lib/square_array.rb | UTF-8 | 176 | 2.953125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(numbers)
counter = 0
while counter < numbers.length
numbers[counter] = numbers[counter] ** 2
counter += 1
end
return numbers
end
| true |
f63705ad0020719d0d1cbd8e839f4fb89ae54d62 | Ruby | Solveug/Tutorial-Simdyanov | /chapter11/task9.rb | UTF-8 | 482 | 2.625 | 3 | [] | no_license | solar_system = {
'Венера' => 4.81068,
'Земля' => 5.97600,
'Луна' => 0.07350,
'Марс' => 0.63345,
'Меркурий' => 0.32868,
'Нептун' => 101.59200,
'Плутон' => 0.01195,
'Сатурн' => 561.80376,
'Солнце' => 1989000.00000,
'Уран' => 86.05440,
'Юпитер' => 1876.64328
}
s1 = solar_system.sort_by(&:last)
puts... | true |
ff6c85fc616e900fca29bc2af455b15206ad1546 | Ruby | necrio/deli-counter-online-web-sp-000 | /deli_counter.rb | UTF-8 | 633 | 3.953125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
def line(katz_deli)
if katz_deli.length >= 1
deli_line = []
counter = 1
katz_deli.each do |name|
deli_line.push "#{counter}. #{name}"
counter += 1
end
puts "The line is currently: #{deli_line.join(" ")}"
else
puts "The line is currently empty."
end
end
... | true |
93590ec557fdbe43db86cb38a0fbcd83cdbac000 | Ruby | anku19/BasicRuby | /step.rb | UTF-8 | 198 | 3 | 3 | [] | no_license | puts "stepto is combo of upto and downto"
1.step 8 do |num|
print "#{num}, "
end
=begin
Output:
C:\Users\USER\Desktop>ruby step.rb
stepto is combo of upto and downto
1, 2, 3, 4, 5, 6, 7, 8,
=end
| true |
6cef0c131647a06e236007b1edb32beaf7c1c976 | Ruby | tiborh/ruby | /map_vs_each.rb | UTF-8 | 468 | 3.84375 | 4 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
# source:
# https://learn.onemonth.com/ruby-tutorial-map-vs-each-a692b63e1850
曜日 = %w|月 火 水 木 金 土 日|
def days0(曜日)
文章 = Array.new
曜日.each do |日|
文章 << "\t今日は、#{日}曜日です。"
end
return 文章
end
puts "first with each:",days0(曜日),"\n"
def days1(曜日)
曜日.map { |日| "\t今日は、#{日}曜日... | true |
e3774997231c3472ed9c82d191d2c9783b93d506 | Ruby | RubyCamp/rc2012w_g1 | /scenes/stages/characters/character.rb | UTF-8 | 918 | 3.140625 | 3 | [] | no_license | class Character
attr_accessor :collision, :x, :y, :collision_active, :z
def center_x; @x - @image.width / 2 end
def center_y; @y - @image.height / 2 end
def initialize(director, x = 400, y = 550, z = 0, image_file = nil)
@director = director
@x = x; @y = y; @z = z
@image = char_image(image_file)
... | true |
ecc3843fb9a22aba3146ddf2a596fc6d6e06355f | Ruby | AlvaroAlonsoFlor/wk02_weekend_homework | /specs/karaoke_specs.rb | UTF-8 | 2,276 | 3.28125 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require("pry")
require_relative("../karaoke.rb")
require_relative("../room.rb")
require_relative("../guest.rb")
require_relative("../song.rb")
require_relative("../drink.rb")
require_relative("../bar.rb")
class TestKaraoke < MiniTest::Test
def setup
@song1 = So... | true |
362905d8a75b919f069d39931e2dd9f9f9fc39dd | Ruby | mind1949/ruby-exercises-for-programmers | /chapter-1/tip_calculator.rb | UTF-8 | 907 | 3.90625 | 4 | [] | no_license | def is_number?(number)
!!Integer(number)
rescue ArgumentError
false
end
def validate(condition, message)
if !condition
STDERR.puts message
return false
end
true
end
def amount_bigger_than_zero(number)
number
end
bill_amount = 0
tip_rate = 0
loop do
puts "What is the bill amount?"
bill_amoun... | true |
a9633acb296c26e8164f0f8ac58b4621c054d909 | Ruby | xykodevops/tools | /lib/lib/prompt.rb | UTF-8 | 909 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'singleton'
class ToolsPrompt
include Singleton
def initialize(options = {}); end
def self.yes?(*args)
prompt = TTY::Prompt.new
prompt.yes?(*args)
end
def self.no?(*args)
prompt = TTY::Prompt.new
prompt.no?(*args)
end
def self.ask(*args)
prompt = TTY::Prompt.new
result ... | true |
905f4e6bdcd5de7c9cc4962d143aaba053d24c5a | Ruby | SurajG/codeeval | /moderate/decimal-to-binary/decimal-to-binary.rb | UTF-8 | 404 | 3.875 | 4 | [] | no_license | # Given a decimal (base 10) number, print out its binary representation.
#
# File containing positive whole decimal numbers, one per line. e.g.
#
# 2
# 10
# 67
#
# Print the decimal representation, one per line. e.g.
#
# 10
# 1010
# 1000011
File.open(ARGV[0]).each_line do |line|
n = line.to_i
digits = []
begin
... | true |
79d43fcc5e839022f5df1dd897020471fb80b4fd | Ruby | katheroine/languagium | /ruby/arrays/hashes/examples_of_hash_elements.rb | UTF-8 | 516 | 3.5625 | 4 | [] | no_license | #!/usr/bin/ruby2.7
person = {
'name' => 'Edmund',
'surname' => 'Dantes',
'profession' => 'merchant sailor',
'age' => 19,
}
puts("person['name']: #{person['name']}")
puts("person['surname']: #{person['surname']}")
puts("person['profession']: #{person['profession']}")
puts("person['age']: #{person['age']}\n\n")... | true |
e0e8915901c62b2a989ed67433c70892199e3bd2 | Ruby | parabuzzle/humanize_boolean | /test/test_human_boolean.rb | UTF-8 | 419 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class TestHumanBoolean < Test::Unit::TestCase
def test_human_boolean
# Test correct humanization
assert_equal(true.humanize, 'Yes')
assert_equal(false.humanize, 'No')
assert_equal(nil.humanize, 'Nothing')
# Test incorrect humanization
assert_not_equal(true.humanize, 'N... | true |
d9565d43500a25b289eef43b446150c91004a731 | Ruby | Wil-McC/enigma | /test/enigma_test.rb | UTF-8 | 2,689 | 3.09375 | 3 | [] | no_license | require_relative 'test_helper'
class EnigmaTest < Minitest::Test
def setup
@enigma = Enigma.new
end
def test_it_exists_with_attributes
assert_instance_of Enigma, @enigma
end
def test_it_encrypts
expected = {
encryption: 'keder ohulw',
key: '02715',
date: '040895'
}
as... | true |
e569e373bd6c66a782ac76d03aeb28848b504b21 | Ruby | CorySpitzer/odd_positions | /odd_positions.rb | UTF-8 | 148 | 3.4375 | 3 | [] | no_license | def odd_positions(list)
odds = []
list.each_with_index do |value, index|
unless index % 2 == 0
odds << value
end
end
odds
end
| true |
9fafef64befd91dfe7eba932b1eacf75b8946032 | Ruby | itggot-Elias-Nordh/webbserver-slutprojekt | /app.rb | UTF-8 | 5,225 | 2.546875 | 3 | [] | no_license | require_relative 'modules.rb'
class App < Sinatra::Base
include Account
include Social
include Add
include Messages
include Group
enable:sessions
get('/error') do
error = session[:error]
back = session[:back]
a = [error, back]
erb(:error, locals:{a: a})
end
get('/') do
session[:user] = fal... | true |
d6acdf91676c098643ec1c544b69abde831c96b5 | Ruby | NicholasBuczacki/launch-school | /exercises/small_problems/easy9/name_swapping.rb | UTF-8 | 509 | 4.5625 | 5 | [] | no_license | #Write a method that takes a first name, a space, and a last name passed as a single String argument, and returns a string that contains the last name, a comma, a space, and the first name.
#input is first and last name separated by space in a string
#output is a string with last name comma first name
#algo is to spli... | true |
d223514d9ada60827560d7e2bfb898561615fcbd | Ruby | prakharR534/Hackrrank-sol. | /Ruby/Ruby Hash - Initialization.ruby | UTF-8 | 195 | 2.859375 | 3 | [] | no_license | # Initialize 3 variables here as explained in the problem statement
empty_hash = Hash.new
default_hash = Hash.new(1)
hackerrank = Hash.new
hackerrank["simmy"] = 100
hackerrank["vivmbbs"] = 200
| true |
caba79c19119a3711a8c24550c25a9188954d0c9 | Ruby | DragonRuby/dragonruby-game-toolkit-contrib | /samples/02_input_basics/03_mouse_point_to_rect/app/main.rb | UTF-8 | 2,827 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | =begin
APIs that haven't been encountered in a previous sample apps:
- args.outputus.borders: An array. Values in this array will be rendered as
unfilled rectangles on the screen.
- ARRAY#inside_rect?: An array with at least two values is considered a point. An array
with at least four values is considered a rect... | true |
c3b73ec8de61543c16380fd01d4215d454a43f0e | Ruby | pn11/latlong | /scripts/gpx2dat.rb | UTF-8 | 1,309 | 2.84375 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
require "rexml/document"
require "time2unix.rb"
def gpx2dat(in_file_name)
puts "gpx2dat #{in_file_name}"
out_file_name = in_file_name.gsub("gpx", "dat")
fout = File.open(out_file_name, "w")
fout.puts "#time elevation" ## distance and speed are bit complex so... | true |
f213676f3e9aa30ac4c5476bdd431136fbd2ddaa | Ruby | tracer11/weekend_work_three | /oop/tv_and_remote.rb | UTF-8 | 1,636 | 4.375 | 4 | [] | no_license | # In this exercise, you will be creating two classes AND the driver code to test them.
# You will create a Tv class and a Remote class.
# The Tv class will have the attributes: power, volume, and channel.
# The Remote class will have just one attribute: tv. This will represent which tv it
# actually controls.
# The... | true |
4871228a389764aee14bf25841ea0ffab24b8e40 | Ruby | Kanst/watcher | /watcher-dashing/dashing/lib/agregation.rb | UTF-8 | 129 | 2.53125 | 3 | [] | no_license | def rp(agr)
if agr == 1
return ' (rpm)'
elsif agr == 60
return ''
else
return ''
end
end
| true |
ddd91c26d4a741359ab4b260d3aef2390d178f01 | Ruby | dmaster18/reverse-each-word-online-web-sp-000 | /reverse_each_word.rb | UTF-8 | 616 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word2(sentence)
array_of_sentence = sentence.split(',')
backwards_sentence = []
array_of_sentence.each do |word|
backwards_word = word.reverse
backwards_sentence.unshift(backwards_word)
end
puts backwards_sentence.join.reverse
end
def reverse_each_word(sentence)
array_of_sentence =... | true |
fd9dd89aaa816e62769417aa3bc9056345d1e164 | Ruby | dengsauve/College-Work | /2017 Spring/CIS283/character_playoff/sauve_character_fight/lib/Weapon.rb | UTF-8 | 641 | 3.6875 | 4 | [] | no_license | ############################################################
#
# Name: Dennis Sauve
# Date: 05/02/17
# Assignment: Character Playoff
# Class: CIS283
# Description: Weapon Class - Inherits from Item Class
# [X]Attributes:
# [X]damage_hits
# [.... | true |
c82d5dd250bceccfc907b9d9440bca5a392a2c18 | Ruby | binarypaladin/toil | /lib/toil/dynamic_value.rb | UTF-8 | 395 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # frozen-string-literal: true
module Toil
class DynamicValue
def initialize(value = nil, &blk)
@static = false
@proc =
if block_given?
blk
elsif value.is_a?(Proc)
value
else
@static = true
proc { value }
end
end
def call... | true |
c4887cf199429b91c8466006c55ef7d90e87be02 | Ruby | Kbhkn-zz/Codes | /Ruby/Gectikaldi.rb | UTF-8 | 802 | 3 | 3 | [] | no_license | # encoding: utf-8
# Kodlayan kbhknn
puts "Dönem Sonu Not Hesaplamayıcıya Hoş Geldiniz"
puts ""
while true
print "Arasınav Notunuzu Giriniz: "
a = gets.chomp
if a.to_i >= 0 && a.to_i <= 100
print "Dönem Sonu Notunuzu Giriniz:"
b = gets.chomp
if b.to_i >= 0 && b.to_i <= 100
break
else a.to_i < 0 && a.to_i > 100
prin... | true |
ab4dc73fe461dc089f83cea277525458a1b31c09 | Ruby | nicoolas25/boxes-kata | /heuristic.rb | UTF-8 | 740 | 3.203125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | require_relative "./pile"
class Heuristic
def initialize(available_boxes, pile: nil)
@available_boxes = available_boxes
@pile = pile || Pile.new
end
def highest_pile
return @pile unless best_box
new_pile = @pile << best_box
remaining_boxes = @available_boxes - [best_box]
Heuristic.new(re... | true |
445c3dc1681bf8855a2e1b9890332f423d757d1b | Ruby | Cobu/localeyes | /lib/tasks/load_colleges.thor | UTF-8 | 640 | 2.53125 | 3 | [] | no_license | class Colleges < Thor
desc 'load [full path to zip_code file]', "Load geonames city, state, zip, lat. longs into mysql"
def load(colleges_file=nil)
require './config/environment'
raise "Can't find that colleges file '#{colleges_file}'" unless File.exist? colleges_file
College.connection.execute "TRUNC... | true |
42d7a8a9fb5ac41f8c1bfc1a51394168266017b6 | Ruby | wouterbin/Mastermind | /spec/game_spec.rb | UTF-8 | 1,059 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Mastermind
class Code
end
class Guess
def initialize(*colors)
end
end
class CodeMaker
def check(guess)
Result.new
end
end
class CodeBreaker
def guess(*colors)
Guess.new(colors)
end
end
class Result
end
class Status
end
c... | true |
48cfa8f8b298194693c0941bd06f1354449978fb | Ruby | phil-smith-1/ruby_bitmap_editor | /lib/bitmap_editor.rb | UTF-8 | 3,201 | 3.53125 | 4 | [] | no_license | require 'pry'
class BitmapEditor # :nodoc:
VALID_COMMANDS = 'ICLVHS'.freeze
COMMAND_METHODS = {
I: :create_canvas,
C: :clear_canvas,
L: :colour_pixel,
V: :vertical_segment,
H: :horizontal_segment,
S: :output_canvas
}.freeze
def run(file)
return puts 'please provide correct file' if ... | true |
6aa42b843d736dcae5c58b0d04fd5cb83836ef19 | Ruby | CodingDojoDallas/ruby_aug_2018 | /prajesh_gohel/Ruby/first_vagrant_box/ruby_tdd/project/project_spec.rb | UTF-8 | 2,339 | 3.375 | 3 | [] | no_license |
require_relative 'project' #include our Project class in our spec file
=begin
RSpec.describe Project do
before(:each) do
@project1 = Project.new('Project 1', 'description 1') # create a new project and make sure we can set the name attribute
end
it 'has a getter and setter for name attribute' do
@projec... | true |
26449308202aa501d614e3d3165d62a7fdf15c16 | Ruby | dslivken/ruby-music-library-cli-cb-000 | /lib/genre.rb | UTF-8 | 501 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Genre
extend Basics::ClassMethods
extend Concerns::Findable
include Basics::InstanceMethods
attr_accessor :name, :songs
@@all = []
def initialize (name)
super
@songs = []
end
def self.all
@@all
end
def add_song(song)
until self.songs.include?(song)
self.songs << song... | true |
50f6afdcc7bcc0238b7f87d757a83371c770aaff | Ruby | myun2ext/power_boots | /lib/power_boots/css/selector.rb | UTF-8 | 454 | 2.734375 | 3 | [] | no_license | module PowerBoots
module Css
class Selector
attr_reader :selectors, :attributes
def initialize(*selectors, **attributes)
@selectors = selectors
@attributes = attributes
end
def to_s
selectors.join(",") + "{" + attributes_to_s + "}"
end
private
d... | true |
0be2d58ae3ff9b5ad44d03e6a69757cfd9d00968 | Ruby | jeffwklein/project_euler | /factors.rb | UTF-8 | 1,938 | 3.796875 | 4 | [
"MIT"
] | permissive | # A set of utility functions that provide
# information about a given positive integer
# parameter, particularly relating to factors
# and divisibility.
module Factors
# Returns true if a given positive integer is
# prime, i.e. the only positive integers that
# evenly divide it are 1 and itself.
# Returns fals... | true |
046389e43cfcb97c65cc753e006f2548c50f2711 | Ruby | bradx3/quinc | /lib/quinc/processors/filter_in_by_extension.rb | UTF-8 | 426 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Quinc
module Processors
class FilterInByExtension
attr_reader :extensions
def initialize(*extensions)
@extensions = extensions.map(&:downcase).map { |e| ".#{ e }" }
end
def process(files)
files.select { |f| extensions.include?(File.extname(f).downcase) }
end... | true |
d5f8d0f9bcfae157eb05c87683dd4cdf629fcc8d | Ruby | LRDesign/project-euler | /lib/tools.rb | UTF-8 | 585 | 3.265625 | 3 | [] | no_license | module Tools
# test if a string is a number
def is_a_number?(s)
s.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
end
def elapse
start = Time.now
[yield, Time.now-start]
end
def solve_puzzle(solution)
(ans, elapsed) = elapse { solution.answer }
"#{solution.class} ... | true |
b20ea81edbb97162ea6ff9f1e061dfae4eb52a43 | Ruby | IIIIIIIIll/RubyQuizess | /Quiz17/question5.rb | UTF-8 | 77 | 2.65625 | 3 | [] | no_license | x = 42
y = 'cat'
b = binding
def hi(b)
b.local_variable_get(:y)
end
p hi(b) | true |
fd241937e838bb240e64443125a018d8dc72511d | Ruby | hoangvubrvt/cellar | /src/totem/api/totem-cli/lib/totem/cli/helpers/run_helpers.rb | UTF-8 | 4,124 | 2.546875 | 3 | [
"MIT"
] | permissive | module Totem; module Cli; module Helpers; module RunHelpers
# Thor run time options
def force?; run_options[:force]; end # overwrite files that alreay exist
def pretend?; run_options[:pretend]; end # run but do not make any changes
def quiet?; run_options[:quiet]; end # suppress status output
def... | true |
5f468256ef771bb2234846116783edf7bd0e6328 | Ruby | brady-robinson/ls-rb101 | /2_small_problems/medium_1_9.rb | UTF-8 | 331 | 3.859375 | 4 | [] | no_license | def fibonacci_last(nth)
fib_array = [1,1]
new_element = 0
loop do
break if fib_array.size >= nth
new_element = fib_array[-1] + fib_array[-2]
fib_array << new_element
end
fib_array.last % 10
end
p fibonacci_last(15) # -> 0 (the 15th Fibonacci number is 610)
p fibonacci_last(20)
p fibonacc... | true |
223700f6779bd80d2b65a7429979cddddbfca7f2 | Ruby | taku-xhift/labo | /ruby/visibility.rb | UTF-8 | 479 | 3.734375 | 4 | [
"MIT"
] | permissive |
class MyDate
def initialize(year, month, day)
@year = year
@month = month
@day = day
end
def <=>(target)
ret = @year - target.year
ret = @month - target.month if ret == 0
ret = @day - target.day if ret == 0
ret
end
protected
def year
@year
end
... | true |
7484f91565b66b2e49172ae0e6798701e7d09fac | Ruby | JeffreyCheng92/Algorithms | /ConvertArrayInPlace/convert_array.rb | UTF-8 | 893 | 4.15625 | 4 | [] | no_license | # Given an array [a1, a2, ..., aN, b1, b2, ..., bN, c1, c2, ..., cN]
# Convert it to [a1, b1, c1, a2, b2, c2, ..., aN, bN, cN]
# Returns the index of where the element should actually be placed.
# i = current_index
# n = number of elements each series (a1..aN).length
def get_new_idx(i, n)
# I use the number 4 here b... | true |
e58b810bfc0395b434b42c2a13173437146f6e87 | Ruby | tyleresmith/emoticon-translator-001-prework-web | /lib/translator.rb | UTF-8 | 970 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require 'yaml'
require 'pry'
def load_library(file_path)
# code goes here
emoticon = YAML.load_file(file_path)
#binding.pry
h = {'get_meaning' => {}, 'get_emoticon' => {}}
emoticon.each do |meaning, emoticon_array|
h["get_meaning"][emoticon_array[1]] = meaning
h["get_emoticon"... | true |
e431c5701999b87d90d2494da68c150443d394e8 | Ruby | nitanshu/ruby-cracker | /Ruby Advance/module/module_hierachy.rb | UTF-8 | 184 | 2.84375 | 3 | [] | no_license | module M
def a
p 'a module up'
end
def a
p 'a module down'
end
end
class A
extend M
def b
p 'a up'
end
def b
p 'a down'
end
end
a = A.new
a.b
A.a
| true |
31a9f9e4182d1dbabf401c6daba4c984b1bd8fa5 | Ruby | wordset/wordset-legacy | /app/models/concerns/anagram_helpers.rb | UTF-8 | 2,380 | 3.09375 | 3 | [
"MIT"
] | permissive | module AnagramHelpers
extend ActiveSupport::Concern
included do |base|
base.field :alpha, type: String, as: "a"
base.before_create :calculate_alpha!
base.index({alpha: 1})
end
class_methods do
def randogram()
meaning = Meaning.limit(1).offset(rand(Meaning.count)).first
anagram = an... | true |
286a800e375f06b9119f0000d5069e1ddc88237e | Ruby | monfil/f1r2s3 | /fibo.rb | UTF-8 | 888 | 3.796875 | 4 | [] | no_license |
require 'benchmark'
def fibonacci_iterative(n)
prev_e = 0
next_e = 1
if n == 0
f = 0
elsif n == 1 || n == 2
f = 1
else
for i in 2..n
f = prev_e + next_e
prev_e = next_e
next_e = f
end
end
f
end
def fibonacci_recursive(n)
if n == 1 || n == 2
1
elsif n == 0
0
... | true |
590ac0c79ae2112b5e2e74d99d70cd59fd94f1a3 | Ruby | jacegu/nervion | /lib/nervion/stream_parser.rb | UTF-8 | 1,283 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'yajl'
require 'http/parser'
module Nervion
class StreamParser
attr_reader :json_parser, :http_parser
def initialize(parsers = {})
@http_parser = parsers[:http_parser] || Http::Parser.new
@json_parser = parsers[:json_parser] || Yajl::Parser.new(symbolize_keys: true)
@http_parser.on... | true |
c012149f615acecb0bcd62606684fb731d30a685 | Ruby | unalterable/learn_to_program | /ch12-new-classes-of-objects/birthday_helper.rb | UTF-8 | 411 | 3.15625 | 3 | [] | no_license | File.open('dates.txt', 'w'){|f| f.write("Christopher Alexander, Oct 4, 1936
Christopher Lambert, Mar 29, 1957
Christopher Lee, May 27, 1922
Christopher Lloyd, Oct 22, 1938
Christopher Pine, Aug 3, 1976
Christopher Plummer, Dec 13, 1927
Christopher Walken, Mar 31, 1943
The King of Spain, Jan 5, 1938")}
dates = {}
File.r... | true |
f5c2108bdd9064d887dc5b0eb9202ff0c1b8542b | Ruby | bradgessler/anchors | /lib/anchors.rb | UTF-8 | 1,612 | 2.828125 | 3 | [] | no_license | require "anchors/version"
require "rack-plastic"
module Anchors
class Middleware < Rack::Plastic
CSS_SELECTOR = "body"
SEPERATOR = "_"
LINK = true
def change_nokogiri_doc(doc)
# Throw this CSS class into the HTML page where you
# want to have linkable anchor headers.
doc.css(css).e... | true |
6ca21aa71ddda220c28ffff82ec8aa45b0e4a117 | Ruby | MichelCance/revisionexospeer | /lib/exo_14b.rb | UTF-8 | 119 | 3.3125 | 3 | [] | no_license | puts "Merci de me donner un nombre"
number = gets.chomp.to_i
number.times do
puts number
number = number -1
end
| true |
d1bb5ce64336e441945810fc8079f904a998498d | Ruby | miaoshan/my-first-hash-london-web-career-031119 | /my_first_hash.rb | UTF-8 | 1,277 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # use the literal constructor to set the variable, my_hash, equal to a hash with key/value pairs of your choice.
def my_hash
my_has={"name" => "miao", "age"=>"29", "height"=>170 }
end
# set a variable called `the_manifest`, equal to a hash
# fill that hash with key/value pairs that describe the following information... | true |
33b2b3d28bdcd2b632424a4a0adf3a83347123d1 | Ruby | jaredkgrove/sinatra-nested-forms-lab-superheros-online-web-sp-000 | /app/models/team.rb | UTF-8 | 172 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Team
attr_accessor :name, :motto, :members
def initialize(params)
self.name = params[:name]
self.motto = params[:motto]
self.members = []
end
end
| true |
295ea4e4a521dfbb3cb4b802adf1c057f3ded974 | Ruby | dalspok/exercises | /small_problems_i3/easy_1/1.rb | UTF-8 | 314 | 3.78125 | 4 | [] | no_license | # def repeat (string, repetition)
# repetition.times {|_| puts string}
# end
# def repeat(string, repetition)
# for _ in (1..repetition)
# puts string
# end
# end
def repeat(string, repetition)
counter = 0
until counter == repetition
puts string
counter += 1
end
end
repeat('Hello', 3) | true |
e33743638f8e958d99bbabc316cafdcc1c63d7d7 | Ruby | learn-co-students/nyc-web-100719 | /10-hashes-and-the-internet/run.rb | UTF-8 | 658 | 3.328125 | 3 | [] | no_license | require_relative './lib/book_app'
# url = "https://www.googleapis.com/books/v1/volumes?q=ruby+programming"
=begin
DELIVERABLES
Create a CLI that asks a user for a search term and then returns a list of books from the Google books API.
Steps:
1. √Welcome the user
2. √Promt the user - "What books do you want to sear... | true |
c0cf8eff792d0c55722fd1f47e357f8f7f999682 | Ruby | aniketpant/todo | /lib/todo/cli.rb | UTF-8 | 3,394 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'main'
require 'highline/import'
require 'ftools'
def read_list(environment)
file = environment.nil? ? Todo::Store.read('.todo/list.yml') : Todo::Store.read(environment)
if file
yield(file)
else
say "Todo list file is invalid or do not exist."
end
end
def write_list(list, en... | true |
b6142f0a8e970d081bbc8d2048beb0f9e0171c80 | Ruby | RomanJohnson/bringing-it-all-together-web-062617 | /lib/dog.rb | UTF-8 | 1,700 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
attr_accessor :id, :name, :breed
def initialize(id: nil, name:, breed:)
@name = name
@breed = breed
@id = id
end
def self.create_table
sql = <<-SQL
CREATE TABLE IF NOT EXISTS dogs (
id INTEGER PRIMARY KEY,
name TEXT,
breed TEXT
)
SQL
DB[:conn].exe... | true |
c25ed8038f981c7cf4652eceda26c3c65254a878 | Ruby | isene/txt2pdf | /txt2pdf | UTF-8 | 2,345 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
# Converts plain text (file or from STDIN) to pdf via pdflatex
# ...either from a text file (first argument) or from STDIN
# By Geir Isene (https://isene.org/). No rights reserved.
def help # defines the helptext to be printed when option "-h" is used
puts <<HELPTEXT
NAME
txt2pdf
SYNOPSIS
txt... | true |
a487fc2dba847e6b210b45d5eebd53417d438ab9 | Ruby | zozo2936/EastCB | /spec/models/cart_spec.rb | UTF-8 | 2,312 | 3.0625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Cart, type: :model do
# let(:cart) {Cart.new}
context "進階功能" do
it "可以將購物車內容轉換成 Hash 並存到 Session 裡" do
cart = Cart.new
book1 = create(:book)
book2 = create(:book)
3.times { cart.add_item(book1.id) }
2.times { cart.add_item(book2.id) }
... | true |
4561e8c5d25e0c72a69567c975429f9ed1bb64ce | Ruby | YourSouLi5Mine/trainee | /ricardo/dynamic_typing/examples/dynamic_typing.rb | UTF-8 | 72 | 2.765625 | 3 | [] | no_license | age = 22
puts age
age = 23
puts age
age = 'Ricardo' # No error
puts age
| true |
4231f6b1e62b076b8dcf9cf47dc87db23512693a | Ruby | wwboynton/tp_link | /lib/tp_link/smart_home.rb | UTF-8 | 2,622 | 2.9375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module TPLink
# Main class for TPLink. This is likely the only class you will initialize.
# @example
# sh = TPLink::SmartHome.new
#
# # Get array of TPLink Devices (currently only dimmable lights work).
# sh.devices
#
# # Find a device by name:
# light = sh.f... | true |
b30fafccc90050874eae9cb6e629a42401254620 | Ruby | khwon/loco | /termapp/processors/loco_menu.rb | UTF-8 | 4,198 | 3.0625 | 3 | [] | no_license | module TermApp
# Main processor of the Application. User can navigate menus and select a
# menu. Processed after WelcomeMenu.
class LocoMenu < Processor
# Item of LocoMenu. Contains a regex for shortcut, title and a menu symbol
# of the class inheriting Processor.
class Item
# Returns the Regexp... | true |
535978ab5ca967816dd60d49f0badfd1858c108f | Ruby | fbohz/nyc-web-102918 | /25-lexical-scope-closures/scope.rb | UTF-8 | 193 | 3.171875 | 3 | [] | no_license | name = 'a string'
def say_name(name_arg)
puts name_arg
end
say_name(name)
say_name('another string')
$global_blah = 'jimmy'
def say_name_global
puts $global_blah
end
say_name_global
| true |
f0faa3f93cc67112e489e29f3c1f125acacdcc3a | Ruby | jkwok97/ROR-app | /Ruby Lang/conditionals/unless_condition.rb | UTF-8 | 228 | 2.859375 | 3 | [] | no_license | players = ["Correa", "Carter", "Altuve"]
unless players.empty?
players.each { |player| puts player}
end
players.each { |player| puts player } unless players.empty?
players.each { |player| puts player } if !players.empty?
| true |
7e73fdcc626fb99ff03aaf9a7d4d6ade1b653379 | Ruby | glebm/i18n-tasks | /lib/i18n/tasks/scanners/scanner_multiplexer.rb | UTF-8 | 1,253 | 2.828125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'i18n/tasks/scanners/scanner'
module I18n::Tasks::Scanners
# Run multiple {Scanner Scanners} and merge their results.
# @note The scanners are run concurrently. A thread is spawned per each scanner.
# @since 0.9.0
class ScannerMultiplexer < Scanner
# @param scanners [... | true |
7446ac287139a4c5e227397495d2754ecba8f44f | Ruby | takagotch/pay | /webpay/admin/05/app/services/price_calculator.rb | UTF-8 | 774 | 2.953125 | 3 | [] | no_license | #---
# Excerpted from "Take My Money",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.prag... | true |
21a259208bfd5134ecbf5a2f0db921ecccfea862 | Ruby | rjurado01/grapi | /lib/mail.rb | UTF-8 | 996 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'net/smtp'
require 'erb'
module Grapi
class Mail
attr_accessor :server, :to, :from, :subject, :template, :port
@@last_email = nil
def self.last_email
@@last_email
end
def initialize
@port = ENV['SMTP_PORT']
@server = ENV['SMTP_SERVER']
@from = ENV['SMTP_FROM']
... | true |
a7fbba19566a517b6a555c295575124b1d4ef0e9 | Ruby | Hungnv950/day-by-day | /Rspec/Rspec.rb | UTF-8 | 3,421 | 2.859375 | 3 | [] | no_license | https://github.com/eliotsykes/rspec-rails-examples
include_examples "name" # include the examples in the current context
it_behaves_like "name" # include the examples in a nested context
it_should_behave_like "name" # include the examples in a nested context
matching metadata # include the exampl... | true |
1282e10e9e9885eccbfcd244eb0f3ede7d32d6b2 | Ruby | KVRajil/Ruby_examples | /patt.rb | UTF-8 | 866 | 2.875 | 3 | [] | no_license | puts "Enter a string"
inputString=gets().chomp
outPutString=""
ar1 = inputString.scan(/:conditions=>\{(.*?)\}/).join("")
ar2 = inputString.scan(/:joins=>\{(.*?)\}/).join("")
ar3 = inputString.scan(/:select=>\{(.*?)\}/).join("")
ar4 = inputString.scan(/:group=>\{(.*?)\}/).join("")
ar5 = inputString.scan(/:order=>\{(.*?... | true |
17a8c5b9bcf939c68f5e0122625ea707521a8bb6 | Ruby | mje113/sideband | /lib/sideband/manager.rb | UTF-8 | 780 | 2.859375 | 3 | [
"MIT"
] | permissive | module Sideband
class Manager
def initialize
@pid = ::Process.pid
thread!
queue!
end
def queue
handle_fork
handle_dead_thread
@queue
end
def thread
@thread
end
def join
@queue.kill
@thread.join
end
def kill
@thread.ki... | true |
ee760eb1e5de819a22b9f1577bf0522b9ba4cb2e | Ruby | richardcrng/wh-lesson-collaborating-classes | /spec/project_spec.rb | UTF-8 | 5,221 | 3.515625 | 4 | [] | no_license | describe 'Creating labs and courses' do
describe 'GIVEN a title and description' do
title = 'My new lesson'
description = 'It is going to teach some things'
describe 'WHEN lab = Lab.new(title, description)' do
lab = Lab.new(title, description)
it 'THEN lab#title is equal to the passed in tit... | true |
db688bdf558b57624a6296bb56e1a3d801391a98 | Ruby | codystair/ruby_small_problems | /Easy_5/10.rb | UTF-8 | 1,022 | 4.09375 | 4 | [] | no_license | =begin
input: string
output: prints box with input within it
rules:
- inputting an empty string will result in this:
- input will always fit in terminal window
examples:
print_in_box('To boldly go where no one has gone before.')
+--------------------------------------------+
| ... | true |
6d3a207ebea6fe8793cdeb3778add2a5d1218ea9 | Ruby | Tomohiro-Kawakami-techcamp/RubySilver | /Question/question15.rb | UTF-8 | 93 | 3.484375 | 3 | [] | no_license | a = [1,2,3,4]
a[0..-2].each do |i| print i, " " end
a[0,3].each do |i| print i, " " end | true |
9a8c2eff2dee9158fe7b69f7b1b381e10a0afae3 | Ruby | salo18/rb100_exercises | /9_Conditionals/e3.rb | UTF-8 | 436 | 4.15625 | 4 | [] | no_license | # In the code below, sun is randomly assigned as 'visible' or 'hidden'.
sun = ['visible', 'hidden'].sample
# Write an if statement that prints "The sun is so bright!" if sun equals visible.
# Also, write an unless statement that prints "The clouds are blocking the sun!" unless
# sun equals visible.
puts sun
puts... | true |
256733f4bdd860eeb0b62b329ec5d688489cbaef | Ruby | craycode123/57-Algorithm-Drill-Factorial-and-Introduction-to-Recursion- | /factorial.rb | UTF-8 | 618 | 4.15625 | 4 | [] | no_license | # Implement an iterative version of the factorial function
def factorial_iterative(n)
if n < 0
"Invalid input"
elsif n == 0
1
else
total = n
while n > 1
total *= n-1
n -= 1
end
total
end
end
p factorial_iterative(0)
p factorial_iterative(-1)
p factorial_iterative(8)
# Impleme... | true |
6dddfcaca34496dccf46774a2baf7d14a12ae1b0 | Ruby | evdokimov-r/thinknetica | /less4/station.rb | UTF-8 | 354 | 3.5 | 4 | [] | no_license | class Station
attr_reader :name, :stations
def initialize(name)
@name = name
@stations = []
end
def get_train(number_of_train)
@stations.push(number_of_train)
end
def send_train(number_of_train)
@stations.delete(number_of_train)
end
def train_of_type(type)
@stations.select { |tra... | true |
f135ac24c278e4cd465a3c7ddabbfa747213dde6 | Ruby | ArturMroz/exercism | /ruby/hamming/hamming.rb | UTF-8 | 258 | 3.703125 | 4 | [] | no_license | class Hamming
def self.compute(strand_a, strand_b)
if strand_a.length != strand_b.length
raise ArgumentError, 'Strands have different lengths'
end
strand_a
.chars
.zip(strand_b.chars)
.count { |x, y| x != y }
end
end
| true |
5f729fc2bb7eee5f834b3d03146395b07ebe3bf9 | Ruby | vijayontheweb/Ruby | /Modules/MethodLookupExample.rb | UTF-8 | 804 | 3.796875 | 4 | [] | no_license | # This example illustrates the Method Lookup Mechanism
#The basic rules governing method lookup and the ordering of the method search
#path may be summarized as follows. To resolve a message into a method, an object
#looks for the method in
# 1) Its class
# 2) Modules mixed into its class, in reverse order of inclusio... | true |
19bca726f5067516ff5c0e2ab52d070dbe7cb22c | Ruby | kivohin/Ironhack-Bootcamp | /Week 2/day_3/secure_passwords/lib/secure_passwords.rb | UTF-8 | 359 | 3.25 | 3 | [] | no_license | # Secure Password Program
class PasswordChecker
def check_password(email, password)
@email = email
@password = password
length_7 &&
let_num_sym
end
def length_7
if @password.length > 7
true
else
false
end
end
def let_num_sym
!(@password =~ /([a-z][0-9])/i).nil? && !(@password =~ /([_+-.,... | true |
aff092265ffdf4e0104b81be449e3fb5828204f4 | Ruby | dojosp/participant-s-projects | /84-PokerHands-Ruby/lib/poker_matcher.rb | UTF-8 | 141 | 3.015625 | 3 | [] | no_license | class PokerMatcher
def self.recognize(hand)
if(hand[0][0] == hand[1][0])
:one_pair
else
:highest_card
end
end
end | true |
c473afa2708e0ef140595f04292b8cc89405818b | Ruby | zbbeaird89/TicTacToe | /lib/tic_tac_toe/game.rb | UTF-8 | 1,963 | 3.625 | 4 | [
"MIT"
] | permissive | module TicTacToe
class Game
attr_reader :players, :board, :current_player, :other_player
def initialize(players, board = Board.new)
@players = players
@board = board
@current_player, @other_player = players.shuffle
end
def switch_players
@current_player, @other_player = @other_player, @current... | true |
83adfbec87cbeab02d5a1989c137987e871b3b29 | Ruby | rubymonstas-zurich/bug-exercise | /bug.rb | UTF-8 | 421 | 3.515625 | 4 | [] | no_license | class Bug
attr_reader :name, :total_lives
attr_accessor :remaining_lives
def initialize(name)
@name = name
@total_lives = 10
@remaining_lives = @total_lives
end
def life_expectancy
self.total_lives
end
def alive?
self.remaining_lives > 10
end
def dead?
self.remaining_lives ... | true |
c43f7246fffdb059bc114605995e5909c633831e | Ruby | hkeefer18/RB101-and-Small-Problems | /lesson_5/16.rb | UTF-8 | 564 | 3.046875 | 3 | [] | no_license | def create_uuid
hexa_arr = ('a'..'f').to_a + ('0'..'9').to_a
string = ''
8.times { string << hexa_arr.sample }
3.times {
string << '-'
4.times { string << hexa_arr.sample }
}
string << '-'
12.times { string << hexa_arr.sample }
string
end
create_uuid
def create_uuid
hexa_arr = ('a'..'f').t... | true |
1490ebbd42b2caf6f7cd1dc0abf1c3c49c736578 | Ruby | rakeshrawat011992/TescoParser | /test/tescoParser_test.rb | UTF-8 | 2,084 | 2.6875 | 3 | [
"MIT"
] | permissive | require "test_helper"
class TescoParserTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::TescoParser::VERSION
end
def test_is_previous_line_total
parserobj = TescoParser::TescoParsercls
assert_equal(true, parserobj.isReducedPrice("REDUCED PRICE") && parserobj.isReducedPrice("... | true |
2ab25be92b55e26534a85c2e435df1402a1cec57 | Ruby | takeyuweb/RubyNewFeatures | /2.2/String/unicode_normalize_test.rb | UTF-8 | 1,018 | 2.6875 | 3 | [] | no_license | # coding: utf-8
require 'test/unit'
class TestUnicodeNormalize < Test::Unit::TestCase
def test_unicode_normalize
assert_equal(
"\u{30AC}", # 濁点付き片仮名カ
'ガ'.unicode_normalize(:nfc))
assert_equal(
"\u{30AB}\u{3099}", # 片仮名カ + COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
'ガ'.uni... | true |
583b9061738d59047e6005da596797e04b0cf58a | Ruby | jigneshkapuriya/ruby_learning | /Class-II/Class_variable_and_class_methods_Bicycle.rb | UTF-8 | 364 | 3.3125 | 3 | [] | no_license | class Bicycle
@@maker = "Biketech"
@@count = 0
def self.description
"Hi, there I'm the blueprint for Bicycle"
end
def self.count
@@count
end
def maker
@@maker
end
def initialize
@@count += 1
end
end
p Bicycle.description
p Bicycle.count
a = Bicycle.new
b = Bicycle.new
c = Bicyc... | true |
f78a01e07d282386b8fbf4b9d693bd1cf7cfdc81 | Ruby | todesking/teamlab-contest-20100807 | /yahoo_keyphrase.rb | UTF-8 | 693 | 2.796875 | 3 | [] | no_license | require 'rubygems'
require 'uri'
require 'net/http'
require 'nokogiri'
class YahooKeyphraseAPI
def initialize(appid)
@appid=appid
end
def extract(text)
resp=request(API_URI,{:appid=>@appid,:sentence=>text})
doc=Nokogiri(resp)
result=[]
(doc/'Result').each{|r|
result.push({
:keyp... | true |
d27ab49abc4bb635d668fa006866d3002b23f7e2 | Ruby | omar-4/omar-projet | /lib/02_calculator.rb | UTF-8 | 72 | 2.8125 | 3 | [] | no_license | def add(a, b)
return a + b
end
def subtract(a, b)
return a - b
end
| true |
a4a5c093b1192bc68716c0c8e4266a5c13e6ceb5 | Ruby | mikekauffman/intro_to_tdd | /spec/fizz_buzz_spec.rb | UTF-8 | 558 | 3.5 | 4 | [] | no_license | #int into fizz buzz class
#run -> [1,integer]
#multiple of 3 = fizz
#multiple of 5 = buzz
#multiple of 3 and 5 = fizzbuzz
require 'rspec/core'
require '/Users/MikeMac/gschoolwork/intro_to_tdd/lib/fizz_buzz.rb'
describe FizzBuzz do
it "replaces multiples of 3 with Fizz and multiples of 5 with Buzz, and multiples o... | true |
6be2f7981204051b1cbab072815c61a6fd52bbac | Ruby | bycdiaz/well_grounded_rubyist | /ch3_organizing_objects_with_classes/3_1_2_overriding_methods.rb | UTF-8 | 169 | 3.15625 | 3 | [] | no_license | class C
def m
puts "First definition of method m"
end
# This one overrides the first.
def m
puts "Second definition of method m"
end
end
puts C.new.m | true |
92fe07a19f25cb028a6a237d96c873432e3b223c | Ruby | Forzafonz/Two-O-Player | /player.rb | UTF-8 | 158 | 3.421875 | 3 | [] | no_license | class Player
attr_accessor :name, :lives
def initialize(name)
self.name = name
self.lives = 3
end
def lost?
self.lives -= 1
end
end | true |
c8bdc2b1a5b7a33dd8d89d381836f8e133112cf4 | Ruby | devslife7/ruby-oo-practice-relationships-domains-wdc01-seng-ft-060120 | /app/models/lyft/passangers.rb | UTF-8 | 983 | 3.484375 | 3 | [] | no_license | class Passanger
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def rides
# returns all rides a passenger has been on
Ride.all.select do |ride|
ride.passanger == self
end
... | true |
ae7db390d254a5bac237dc184ae71129fc428889 | Ruby | cheerfox/Introduction_to_Programing_with_Ruby_Exercise | /Final_Exercises/ex14.rb | UTF-8 | 650 | 2.90625 | 3 | [] | no_license | #single contact
contact_data = ["joe@email.com", "123 Main st.", "555-123-4567"]
contacts = {"Joe Smith" => {}}
symbols = [:email, :address, :phone]
contact_data.each do |data|
add_symbol = symbols.shift
contacts["Joe Smith"][add_symbol] = data
end
p contacts
#multiple contacts
contact_data = [["joe@email.com", ... | true |
ca02c7af3fc148c23ead7dee069f77865ab45777 | Ruby | Who828/TicTacToe | /lib/game_init.rb | UTF-8 | 246 | 2.84375 | 3 | [] | no_license | class Game_Init
def initialize
@game = Game.new(3)
@player_x = Player.new(@game,"X")
@player_y = Player.new(@game,"Y")
end
def player_x
@player_x
end
def player_y
@player_y
end
def game
@game
end
end
| true |
0c57d895fa6614e4f6bc32d2a6c703713374ff2f | Ruby | nerab/cardgame | /lib/cardgame/player/auto_player.rb | UTF-8 | 1,349 | 3.234375 | 3 | [] | no_license | require 'player'
module CardGame
module Player
class AutoPlayer < Base
#
# Select one or more of our cards (according to our playing strategy)
#
# Note the the player has no further knowledge about the state of the game except the topmost card of the pile that is passed.
# If a play... | true |
f6f96d0cef5e31916f2dc6ad84e87642ffe0dbb7 | Ruby | rudyNK/ruby-object-attributes-lab-noukod-000 | /lib/dog.rb | UTF-8 | 187 | 3.265625 | 3 | [] | no_license | class Dog
def name=(dog_name)
@name = dog_name
end
def name
@name
end
def breed=(dog_breed)
@breed = dog_breed
end
def breed
@breed
end
end
Fido = Dog.new
Fido.name = "Fido"
| true |
bcc8f534d0899c4a6b45d062ba4d52b97b417640 | Ruby | groundberry/oystercard | /spec/station_spec.rb | UTF-8 | 271 | 2.59375 | 3 | [] | no_license | require 'station'
describe Station do
subject(:station) { described_class.new('Waterloo', 1) }
it 'gives the name of the station' do
expect(station.name).to eq 'Waterloo'
end
it 'gives the zone of the station' do
expect(station.zone).to eq 1
end
end
| true |
76ad605de1c89d7c7ba4695e797744a30500c1f8 | Ruby | sensu-plugins/sensu-plugins-supervisor | /bin/check-supervisor-socket.rb | UTF-8 | 3,091 | 2.5625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# check-supervisor-socket
#
#
# DESCRIPTION:
# Check that all supervisor processes are running using its UNIX domain socket. See unix_http_server section in
# http://supervisord.org/configuration.html.
#
# OUTPUT:
# Plain text, 'All processes running' or eg. 'redis-server not running: FATAL'... | true |
1fbffe82293ba4e7ed9f0b1009af6ed207eab75f | Ruby | tsurugeek/sg_eratos | /eratos.rb | UTF-8 | 820 | 3.28125 | 3 | [] | no_license | # エラトステネスの篩 の実装
# https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
#--------------------
# 引数チェック
#--------------------
unless ARGV.size == 1
puts "引数を1つ指定してください。"
exit
end
max = ARGV[0].to_i
unless ARGV[0].to_i >= 2
puts "引数は2以上の整数を指定してくあさい。"
e... | true |
0d253d827228d525ec1efa233c54e543cd8b3609 | Ruby | inspec/inspec-aws | /libraries/aws_elasticache_replication_group.rb | UTF-8 | 2,643 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require "aws_backend"
class AwsElastiCacheReplicationGroup < AwsResourceBase
name "aws_elasticache_replication_group"
desc "Verifies settings for an AWS Elasticache Replication Group"
example "
describe aws_elasticache_replication_group('my-replication_group-001') do
it { should be_encrypted_at_transi... | true |
633c086b6c45561d9675a9e08a0c9f01a9b9acb2 | Ruby | vizcay/webwarrior | /app/models/task.rb | UTF-8 | 579 | 2.625 | 3 | [] | no_license | require 'time'
class Task
attr_accessor :id, :uuid, :description, :project, :status, :priority, :entry, :due, :urgency, :tags
def import_from_json(task)
@id = task['id']
@uuid = task['uuid']
@description = task['description']
@status = task['status'].to_sym
@priority = ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.