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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c49eb5b06da7115f9fe8ae5d88af17463b325376 | Ruby | route4me/route4me-ruby-sdk | /lib/route4me/util.rb | UTF-8 | 645 | 2.59375 | 3 | [] | no_license | module Route4me
module Util
def self.extract(params, keys)
s = params.select{|k,v| keys.include? k.to_sym }
Hash[s.map{|k, v| [k.to_sym, v] }]
end
def self.url_encode(key)
URI.escape(key.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
def self.symbolize_names(object)
... | true |
5281e58e3aefefa58d4b58d93ffa7036ed6198e4 | Ruby | AtomicMegaNerd/RubyRational | /main.rb | UTF-8 | 230 | 3.03125 | 3 | [] | no_license | require_relative "rational"
include Rcd
r1 = RcdRational.new(4, 8)
puts r1
r2 = RcdRational.new(3, 21)
puts r2
r3 = r1.reciprocal
puts r3
r4 = r1 + r2
puts r4
r5 = r1 - r2
puts r5
r6 = r2 / r1
puts r6
r7 = r2 * r1
puts r7
| true |
69cb41326cc9be452d41483841e78b3813c68565 | Ruby | manoj-k-r/odin_webdev | /ruby_programs/stock_picker.rb | UTF-8 | 778 | 3.4375 | 3 | [] | no_license | #given an array of days gives an array of buy day and sell day with the highest profit
def stock_picker(arr)
profits_hash=arr.reduce({}) do |op_hash, price| # get all combos with positive profits
profit=arr[arr.index(price)...arr.length].max-price
op_hash[profit]=[price,arr[arr.index(price)...arr.le... | true |
0314daf79775156c892f03eae72bdc0e4e39a8cc | Ruby | rzilleruelo/historyse.service | /app/models/event.rb | UTF-8 | 628 | 2.59375 | 3 | [] | no_license | class Event < Base
SOURCES = ['click', 'scroll', 'focus', 'blur']
validates_presence_of :user_uuid
validates_presence_of :tab_id
validates :source, :inclusion => {:in => SOURCES}
def user_uuid
UUIDTools::UUID.parse_raw(self[:user_uuid]).hexdigest if self[:user_uuid].present?
end
def tab_id
s... | true |
f58bac05e6880df7f52c5a9bcf8e88e31717675a | Ruby | jimcoyle/JimsRubyCode | /flow.rb | UTF-8 | 226 | 3.828125 | 4 | [] | no_license | puts 1>2
puts 1<2
puts 'cat' < 'dog' # ie does cat come before dog in dictionary? Beware CAPS
puts 'Hello, what\'s your name?'
name = gets.chomp
puts 'Hello, ' + name + '.'
if name == 'Chris'
puts 'What a lovely name!'
end | true |
69e8f4c3e5ed7be10f97073874ffcea558efe525 | Ruby | tomejesus/boris-bikes | /lib/docking-station.rb | UTF-8 | 539 | 3.15625 | 3 | [] | no_license | require_relative 'bike'
class DockingStation
DEFAULT_CAPACITY = 20
attr_reader :dock, :capacity
def initialize(capacity = DEFAULT_CAPACITY)
@dock = []
@capacity = capacity
end
# updated under the assumption that docks start empty
def release_bike
fail 'No bikes available' if empty?
@bike =... | true |
c3a4cc1f67aa8e0baf2fbd33ddef2156b7c9cfa7 | Ruby | decal/zap-attack | /lib/zap_attack/api/replacer/view/rules.rb | UTF-8 | 1,295 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | # coding: utf-8
module ZapAttack::Replacer
#
# URL to access alerts via ZAP API with baseurl parameter to narrow results
#
RULES_JSON = 'http://zap:8080/JSON/replacer/view/rules'
class Rules < Array
attr_reader :json, :text, :alerts
#
# Instantiate Ruby Rules Array Object by parsing JSON from Z... | true |
69e1888d37bc93e512861de3a0649d8b3dfb88dd | Ruby | eduardopz2w/rubyclass | /suma.rb | UTF-8 | 92 | 3.234375 | 3 | [] | no_license | a = 1
b = '2'
begin
c = a + b
rescue
puts 'No se puede sumar'
else
puts c
end | true |
4e9fe4274b9b70c375b2745b97edffdbaee945a3 | Ruby | guiatsu/Tp2-P1-Parte-2 | /src/DivEval.rb | UTF-8 | 424 | 2.8125 | 3 | [] | no_license | require './src/Eval'
require './src/Div'
module Div_Eval
include Core_Div
class Div < C_Div #real implementacao da divisao com os metodos print e evaluate
include Eval::Expression
def initialize(left, right)
@left = left
@right = right
def eval
... | true |
f832ab165f73ccdb7b1dc4536c70e5af52876238 | Ruby | LittleBigProgramming/HuntersKeepers | /app/models/improvement.rb | UTF-8 | 1,626 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# == Schema Information
#
# Table name: improvements
#
# id :bigint not null, primary key
# description :string
# type :string
# rating :integer
# stat_limit :integer
# playbook_id :bigint
# created_at :datetime not null
# updated_at :date... | true |
df3ff7ba7f0bcaa1a14c0e132d11b7a6e812391e | Ruby | pdxwolfy/Challenges | /Live01/x2.rb | UTF-8 | 397 | 3.609375 | 4 | [] | no_license | # frozen_string_literal: true
#
# Copyright (c) 2016 Pete Hanson
def lowest_number(number_list)
number_list.map(&:to_s).sort.join('').to_i
end
puts lowest_number([23, 550, 1, 80]) # -> 12355080
puts lowest_number([1, 1, 1, 1]) # -> 1111
puts lowest_number([10000, 123, 1890, 11]) # -> 10000111231890
puts lowest_numb... | true |
13d59ee6b20a23129642416554f4514fd389331b | Ruby | uwexpd/expo | /app/models/activities/accountability_report.rb | UTF-8 | 40,667 | 2.84375 | 3 | [] | no_license | =begin rdoc
An Activity models a person's participation in some sort of trackable activity. The primary purpose of the Activity models is to compile and generate accountability statistics for the provost and the legislature. We currently focus on two metrics for undergraduates: public service and research.
== How acti... | true |
d74d1129990107149276349e3f79ef43017d8803 | Ruby | francis/rover | /test/vector_test.rb | UTF-8 | 11,241 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative "test_helper"
class VectorTest < Minitest::Test
def test_works
vector = Rover::Vector.new([1, 2, 3])
assert_equal [1, 2, 3], vector.to_a
assert_equal 3, vector.size
assert_equal 3, vector.count
assert_equal 3, vector.length
assert_equal [1, 2], vector.first(2).to_a
assert... | true |
2780367a03de47ac43b2267a71d01087a1c798c0 | Ruby | grmx/bookdepository | /spec/models/order_spec.rb | UTF-8 | 1,996 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Order, type: :model do
let(:book) { create(:book) }
let(:order) { build(:order) }
before { order.add_book(book) }
describe 'validation' do
it { should validate_presence_of(:total_price) }
it { should validate_presence_of(:state) }
it { should validate_presenc... | true |
a7ea3a2cf01cd7fe2e7aeb9f61c60c02912fe890 | Ruby | amaxwellblair/module_1 | /night_writer/test/night_reader_test.rb | UTF-8 | 878 | 3.125 | 3 | [] | no_license | require 'minitest'
require 'alphabet'
require 'night_reader'
class NightReaderTest < Minitest::Test
include Alphabet
def test_class
reader = NightReader.new("")
assert_equal NightReader, reader.class
end
def test_machine
str = ""
assert_equal NightReader.new("\n\n\n").compute, str
assert... | true |
27a5f8404562cc1eeff717c6a81d7508699881e3 | Ruby | Vilkelis/black_jack | /views/game_base_view.rb | UTF-8 | 1,400 | 3.265625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../config/app_settings.rb'
# Base class for application views
class GameBaseView
def welcome_to_game
title
puts 'Добро пожаловать в игру!'
sleep_short
end
def end_game
title
puts 'До новых встреч!'
sleep_long
clear_console
end
def... | true |
44039872be879298bb257748bbb22030a0511260 | Ruby | marcmoy/maze | /spec/maze_spec.rb | UTF-8 | 1,071 | 3.078125 | 3 | [] | no_license | require 'board'
require 'rspec'
describe Board do
let(:textfile) { "maze1.txt" }
let(:board) { Board.new(textfile) }
let(:node4) { {:id=>4,:text=>"*",:pos=>[0,4],:type=>:wall} }
let(:node18) { {:id=>18,:text=>" ",:pos=>[1,2],:type=>:empty} }
let(:node53) { {:id=>53,:text=>"*",:pos=>[3,5],:type=>:wall... | true |
2bbe20503aaa144d401bce8927fa42119011bc0a | Ruby | parhaml/ProjectEuler | /Euler4b.rb | UTF-8 | 372 | 3.5 | 4 | [] | no_license | def palindrome(max_num)
answer = 0
(100..max_num).to_a.reverse.each do |a|
if a % 11 == 0
b = 999
db = 1
else
b = 990
db = 11
end
while b >= a
if a * b <= answer
break
elsif (a * b).to_s === (a * b).to_s.reverse
answer = a * b
end
b = b ... | true |
466402f7dfd5f0c73b94441ddffe0c28c2479336 | Ruby | jordannad/ArcHydroTutorial | /_plugins/image_tag.rb | UTF-8 | 3,064 | 2.8125 | 3 | [] | no_license | # Title: Jekyll Image Tag
# Authors: Brennan Saeta : @saeta
#
# Description: Easier images
#
# Syntax: {% image [preset] [scale] path/to/img.jpg ["caption" location] [attr="value"] %}
# Example: {% image simple 50% poster.jpg "<i>Figure 1</i> The strange case of Dr. Jekyll" bottom class="foo" %}
# {% image ga... | true |
f6abf26286d96e34fd545e131a99ce99663d58e6 | Ruby | mdixon47/Codewars-Ruby | /7-kyu/Complete The Pattern #1.rb | UTF-8 | 428 | 3.984375 | 4 | [] | no_license | #Description:
#Task:
#You have to write a function pattern which returns the following Pattern(See Pattern & Examples) upto n number of rows.
#Note:Returning the pattern is not the same as Printing the pattern.
#Rules/Note:
#If n < 1 then it should return "" i.e. empty string.
#There are no whitespaces in the patter... | true |
25190da78faca9e0a039c7e1d9a4d55f188c9a04 | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/polymorphic-copy.rb | UTF-8 | 166 | 3.59375 | 4 | [] | no_license | class T
def name
"T"
end
end
class S
def name
"S"
end
end
obj1 = T.new
obj2 = S.new
puts obj1.dup.name # prints "T"
puts obj2.dup.name # prints "S"
| true |
561ca615596b8e79fb54ebea973c2852f540460e | Ruby | entaq/floq | /Floq/installer/fastlane_lib/bundle/lib/ruby/gems/2.2.0/gems/tty-screen-0.5.0/lib/tty/screen/size.rb | UTF-8 | 3,472 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # coding: utf-8
module TTY
class Screen
class Size
# Initialize terminal size detection
#
# @api public
def initialize(env, options = {})
@env = env
@output = options.fetch(:output) { $stderr }
@verbose = options.fetch(:verbose) { false }
end
# Ge... | true |
a2dcca5f3e54683c20a4b1159c22833784ef3a7a | Ruby | alinawww/Ironhack | /Class/week2/day4/blog/lib/models/blog.rb | UTF-8 | 190 | 2.734375 | 3 | [] | no_license | require 'colorize'
require 'pry'
require_relative './post.rb'
class Blog
attr_reader :posts
def initialize
@posts = []
end
def add_post(post)
@posts.push(post)
end
end
| true |
ca9823420a696866ab0f345b8f6e66661307c82e | Ruby | b4thestorm/101-programming-foundations | /small_problems/leap_year2.rb | UTF-8 | 515 | 3.984375 | 4 | [] | no_license | #goal: The British Empire adopted the Gregorian Calendar in 1752, which was a leap year. Prior to 1752,
#the Julian Calendar was used. Under the Julian Calendar, leap years occur in any year that is evenly divisible
#by 4.
#logical layer
#get year
#modulo year by 4
#if no remiander (equally visible)
... | true |
50e68539e24feba72a79a089c02cfce0c4263a1c | Ruby | nlllllly/Hachiss_ | /app/models/shipping.rb | UTF-8 | 1,197 | 2.546875 | 3 | [] | no_license | class Shipping < ApplicationRecord
belongs_to :customer
# バリデーション
validates :last_name_kana, presence: true, length: { minimum:1, maximum:10 }
validates :first_name_kana, presence: true, length: { minimum:1, maximum:10 }
validates :last_name, presence: true, length: { minimum:1, maximum:10 }
v... | true |
9d06b349587f9092200dfa7c544f9f7f02087933 | Ruby | Brayan9105/Exercises | /CRUD/user.rb | UTF-8 | 5,787 | 3.09375 | 3 | [] | no_license | require "minitest/autorun"
class User
attr_accessor :users
def initialize
@@users = []
@@id = 0
end
def is_unique?(email: nil)
@@users.each do |user|
return false if user[:email] == email
end
true
end
def has_value?(*fields)
fields.each do |field|
return false unle... | true |
309efe50c8f60472522010b29812559fb2836240 | Ruby | mpath-development/rack-jetty | /lib/rack_jetty/java_input.rb | UTF-8 | 1,246 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module RackJetty
class JavaInput
def initialize(input)
@input = input
end
# reads count bytes into into_buffer, returns nil at EOF, otherwise
# returns into_buffer.
def read_bytes(count, into_buffer)
data = "\0" * count
data = data.to_java_bytes
count = @input.read(dat... | true |
52d1f0c0d0dfb367287dd9721637ebb9ac93d60a | Ruby | jparkSF/algorithms | /jiwoo_park_quicksort/lib/quick_sort.rb | UTF-8 | 1,610 | 3.609375 | 4 | [] | no_license | class QuickSort
# Quick sort has average case time complexity O(nlogn), but worst
# case O(n**2).
# Not in-place. Uses O(n) memory.
def self.sort1(array)
end
# In-place.
def self.sort2!(array, start = 0, length = array.length, &prc)
# p start, length, array
prc ||= proc {|a,b| a <=> b }
re... | true |
a52a279092f16431dda11fae3870b465f60f14e2 | Ruby | mmkserver1/mmk | /app/models/bloodpressure_threshold.rb | UTF-8 | 1,148 | 2.921875 | 3 | [] | no_license | class BloodpressureThreshold < MeasurementThreshold
after_initialize :init
validates_numericality_of :high_sys, :high_dia, :high_pulse, :low_sys, :low_dia, :low_pulse
def init
self.value["high_sys"] ||= 140
self.value["high_dia"] ||= 100
self.value["high_pulse"] ||= 120
self.value["lo... | true |
761dbda8285b9ca5267c8d54f0c180a2a6429c88 | Ruby | rachelsoh87/todo_assessment | /app/models/list.rb | UTF-8 | 1,025 | 2.8125 | 3 | [] | no_license | require_relative '../../config/application'
require_relative '../controllers/controller'
class List < ActiveRecord::Base
belongs_to :user
has_many :tasks
def list_all_tasks_in_table(list_id)
Display.list(list_id)
end
def add_tasks_to_table(input)
text = input.join(" ")
Task.create(list_id... | true |
d0c4c06f087a649ab6811387033554a165655f6a | Ruby | drbrain/drb-worm | /lib/drb/worm/daemon.rb | UTF-8 | 2,360 | 2.96875 | 3 | [
"MIT"
] | permissive | ##
# The daemon that runs on nodes infected with the worm.
#
# The daemon can either be spawned in the target context or started directly.
# The daemon is started with the URI of the local parent process (the process
# that spawned the daemon) and the URI of the master process (a
# DRb::Worm::Master).
#
# To spawn you ... | true |
e7dde1947e2c19dc664e9147dee5c7550e098e22 | Ruby | gabrirulli/leetcode | /easy_collection/array/rotate_array.rb | UTF-8 | 396 | 3.46875 | 3 | [] | no_license | nums = [1, 2, 3, 4, 5, 6, 7]
k = 25
def rotate(k, nums)
le = nums.length - 1
if k == nums.length || nums.length <= 1
p nums
return
end
if k > nums.length
k = k%nums.length
k.times do
nums.unshift(nums[le])
nums.pop
end
p nums
return
else
k.times do
nums.unsh... | true |
c4163d87a33608a3162f09fcedd66d4e943ee82d | Ruby | bluemihai/dbc-teacher | /app/models/phase_day.rb | UTF-8 | 1,316 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'psych'
class PhaseDay < ActiveRecord::Base
YAML_FILE = File.open("#{Rails.root}/db/seeds/phase_days.yml", 'r')
YAML_FILE_NAME = "#{Rails.root}/db/seeds/phase_days.yml"
has_many :phase_lead_requests
has_many :resources
has_many :challenges
default_scope -> { order(:phase_no).order(:day_no) }
sc... | true |
a556fe6705aa9997ee1cea614524ff87223a0cf5 | Ruby | kpediad/EdxCli | /lib/EdxCli/cli.rb | UTF-8 | 2,005 | 3.3125 | 3 | [
"MIT"
] | permissive | class EdxCli::Cli
EDX_PROGRAMS_URL = "https://www.edx.org/course/?program=all&availability=starting_soon"
WORD_COUNT = 6
def run #Program start
puts "Welcome to the EdX starting soon programs!"
display(get_programs)
select_action
end
def get_programs
EdxCli::Program.all ||= EdxCli::Program.... | true |
3ebb8e4417484a0b1afdaec74cb8ab0907eaf971 | Ruby | emiliocm9/Bubble-Sort-Ruby-Project | /tests.rb | UTF-8 | 3,213 | 3.53125 | 4 | [] | no_license | require './enumerable_methods.rb'
test_array1 = [11, 2, 3, 56]
test_array2 = %w(a b c d)
test_array3 = %w[f g h i]
p "========================================="
# my_each
p 'my_each'
p test_array1.each
test_array2.each { |x| p x }
test_array3.each { |x| p x }
test_array1.my_each { |x| p x }
test_array2.my_each { |x| ... | true |
2f89cd16f03f68121b9ff61c721a8c9f6a5adea7 | Ruby | dmitrinesterenko/learning_machine-learning | /spec/trainer_spec.rb | UTF-8 | 1,111 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'spec_helper'
describe C::Trainer do
let(:humans) do
{"Anderson Cooper":1.0,
"Andy Anderson": 1.0,
"Megan Melody": 1.0,
"Buzzy": 0.2,
"S1243": 0.1,
"chair": 0.1
}
end
let(:buzz_aldrin) do
{"Buzzy": 1.0}
end
let(:new_record) do
{"Bobby Smurda": 1.0}
... | true |
936c5bff6fac243167b298a52ad89ae0283ddd75 | Ruby | igscl/atm | /bianca.rb | UTF-8 | 282 | 3.296875 | 3 | [] | no_license | arr = ["hola", "hello", "arigato"]
# max = arr.max_by(&:length).length
max = 0
puts "*" * 9
for word in arr
if word.length > max
max = word.length
end
end
for word in arr
spaces = max - word.length
puts "* " + word + " " * spaces + " *"
end
puts "*" * 9
| true |
6ed0380d5c759fc4b49178b7f9fb0cd3f97afbaa | Ruby | tarcea/mask_article | /spec/mask_article_spec.rb | UTF-8 | 721 | 3.046875 | 3 | [] | no_license | require_relative '../mask_article.rb'
describe 'mask_article' do
it "should generate the right string when searching for 1 word" do
expect(mask_article("Hello World! This is crap!", ["crap"])).to eq "Hello World! This is <strike>crap</strike>!"
end
it "should generate the right string when searching for 2 wo... | true |
df09b0be195cf2575fb8963ed062ea3545b63a22 | Ruby | Currency-One/deepstream-ruby | /lib/deepstream/list.rb | UTF-8 | 2,242 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | require_relative './record'
require_relative './exceptions'
module Deepstream
class List < Record
LIST_CALLBACKS = %i{added removed}
attr_reader :version
def initialize(*args)
super
@data = []
@handlers = {}
end
def add(record_name)
unless @data.include?(record_name)
... | true |
c4ecf874310738233f542ad0a3ed0b54bab92315 | Ruby | kzq/vending-machine | /lib/change_machine.rb | UTF-8 | 470 | 3.25 | 3 | [] | no_license | class ChangeMachine
attr_accessor :hoppers
attr_reader :currency
HOPPER_CAPACITY = 25
def load_cash(currency: GBP)
@currency = currency
@hoppers = money.collect do |coin|
hopper(coin: coin,quantity: HOPPER_CAPACITY)
end
end
private
def money
@currency.money
end
def hopper(coi... | true |
2e9574a2738863f04e50bf74c852f790140f420a | Ruby | nanutza/wolf_foo_bar | /ruby/gps6/my_solution.rb | UTF-8 | 4,368 | 4.0625 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [with: Wellington - guide ].
# We spent [1.5] hours on this challenge.
# EXPLANATION OF require_relative
#
#
require_relative 'state_data'
#link with another file the directory declaring the relative path.
#require needs the full path or url
class VirusPredictor
# thi... | true |
0660c8f5ba9ff6929a93b181fac35e83befd4fa8 | Ruby | nofxx/git-issues | /lib/git-issues/providers/github.rb | UTF-8 | 1,844 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | require 'octokit'
# API documentation:
# http://developer.github.com/v3/
class RepoProvider::Github
URL_PATTERNS = [
/^(ssh:\/\/)?git@github.com:(?<user>[^\/]+)\/(?<repo>.+?)(\.git)?$/,
/^https:\/\/github.com\/(?<user>[^\/]+)\/(?<repo>.+?)(\.git)?$/
]
def self.get_repo url
# find the url pattern t... | true |
f0b3c38f73a272cd8217ad8ca49026ad0950e5a1 | Ruby | BrunaCristina1/nivelamento-aluno | /Simulado/04-simulado.rb | UTF-8 | 965 | 4.5 | 4 | [] | no_license | #04-simulado.rb
#4) Defina uma função chamada “imprimir_tabela”, que deve receber um número inteiro como parâmetro e deve
#imprimir na tela uma tabela de números seguindo a seguinte regra:
#1
#2 4
#3 6 9
#...
#n*1 n*2 n*3 ... n*n
#Valide se o parâmetro é um número maior que zero, se não for, a função deve imprimir na ... | true |
8a7f84a5268c684629418556b2709f53631bb77d | Ruby | dnkelly97/card_game_app | /app/controllers/rooms_controller.rb | UTF-8 | 10,196 | 2.609375 | 3 | [] | no_license | class RoomsController < ApplicationController
before_action :set_current_user
def new
end
def create
@room = Room.create_room!(:name => params[:room_name],
:max_players => params[:max_players],
:game_type => params[:game_type],
:pri... | true |
c4efafc4a9504d066825b24f467ce2f744c3aaf0 | Ruby | fanjieqi/LeetCodeRuby | /401-500/470. Implement Rand10() Using Rand7().rb | UTF-8 | 170 | 3.234375 | 3 | [
"MIT"
] | permissive | # The rand7() API is already defined for you.
# def rand7()
# @return {Integer} a random integer in the range 1 to 7
def rand10()
1 + 10.times.map{rand7}.sum % 10
end
| true |
202967d2e7e908137d110fad80535c5b9ddffb3d | Ruby | ismasan/websockets-examples | /lib/channel.rb | UTF-8 | 1,450 | 3.4375 | 3 | [] | no_license | # A channel keeps track of connected sockets and broadcasts events to all of them.
# Event format is JSON for:
#
# ['Socket-event_name', some_data]
#
# Where 'some_data' can be any valid JSON data type, so you can push your own messages:
#
# @channel.send_message :user_connected, :name => 'ismael', :bday => '29/11/77'
... | true |
a7b7ba7057e871c491d3eebc9592bad947a22be0 | Ruby | ashabbir/ruby_rnd | /lsi/lsi.rb | UTF-8 | 555 | 3.421875 | 3 | [] | no_license | require 'classifier-reborn'
require 'pry'
lsi = ClassifierReborn::LSI.new
strings = [ ["This text deals with dogs. Dogs.", :dog],
["This text involves dogs too. Dogs! ", :dog],
["This text revolves around cats. Cats.", :cat],
["This text also involves cats. Cats!", :cat],
... | true |
c8489e9a91418c254e14d97b95a2a57947c91b39 | Ruby | StlMaris123/ruby_tutorials | /headfirst/chapter10/word_splitter.rb | UTF-8 | 282 | 3.421875 | 3 | [] | no_license | class WordSplitter
include Enumerable
attr_accessor :string
#creates a new instance with its string
#attribute set to the give string
def initialize(string)
self.string = string
end
def each
string.split("").each do |word|
yield word
end
end
end
| true |
35121c9f6824d93a46af42f4fca72b9f32440cb6 | Ruby | shaggyone/ems_russia | /lib/ems_protocol/ems.rb | UTF-8 | 1,106 | 2.703125 | 3 | [] | no_license | class EmsProtocol::Ems
def self.all
EmsProtocol::Location.all.map {|x|
{
:internal => x["value"],
:name => x["name"],
:type => (x["type"]=="cities") ? :city : :region
}
}
end
def self.all_cities
EmsProtocol::Location.all_cities.map {|x|
{
:i... | true |
97403c38facbb226f34dc5b842001f3b679fa8bc | Ruby | radarek/cs_workshops | /exercsises/constants.rb | UTF-8 | 44 | 2.625 | 3 | [] | no_license | module Foo
PI = 3.1415
end
puts Foo::PI
| true |
18ff0addd9e50b2bc5f1b9f5226b8f53750fff05 | Ruby | justineshaw/LS-Intro-to-Programming | /hashes/ex3.rb | UTF-8 | 264 | 3.953125 | 4 | [] | no_license | # use a Hash
person = {name: 'Bob', occupation: 'web developer', hobbies: 'painting'}
# print keys
person.each_key {|key| puts key}
# print all values
person.each_value {|value| puts value}
# print keys and values
person.each do |k, v|
puts "#{k}: #{v}"
end
| true |
44f57e678c7b6b48fb884030d54241aa950bede9 | Ruby | theomoji/rails-index-show-new-create-lab-dumbo-web-100818 | /db/migrate/01_coupons.rb | UTF-8 | 1,087 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Coupons < ActiveRecord::Migration
def change
create_table :coupons do |t|
t.string :coupon_code
t.string :store
end
end
end
# _______________________________________________________
#
# class Smoothies < ActiveRecord::Migration
# def change
# create_table :smoothies do |t|
# t.... | true |
69c5f3860a213473e8cc329bbc5aae1456ed6307 | Ruby | paulghaddad/level_up_exercises | /dino_catalog/lib/json_export.rb | UTF-8 | 341 | 2.671875 | 3 | [
"MIT"
] | permissive | module JsonExport
def convert_to_json(ruby_object)
array_of_objects = convert_object_to_array(ruby_object)
File.open("json_export.json", "w") do |f|
f.puts JSON.generate(array_of_objects)
end
end
def convert_object_to_array(object)
object.inject([]) { |array, attribute| array << attribute.... | true |
a64bd0dfac9d15604a9fac03d603a3abcd017f54 | Ruby | mattgwagner/Project-Euler | /Ruby/Euler14.rb | UTF-8 | 1,107 | 3.859375 | 4 | [] | no_license | ##The following iterative sequence is defined for the set of positive integers:
##
##n → n/2 (n is even)
##n → 3n + 1 (n is odd)
##
##Using the rule above and starting with 13, we generate the following sequence:
##13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
##
##It can be seen that this sequence (starting at 13... | true |
62f2e24e308e938ffa6f0dab4a1238e8dc283b32 | Ruby | IAMCorporativos/ancar | /lib/importers/base_importer.rb | UTF-8 | 1,640 | 2.609375 | 3 | [] | no_license | module Importers
class BaseImporter
attr_reader :filepath
def initialize(year, extname, filepath)
@year = year
@filepath = filepath
@extname = extname
end
def run
PublicActivity.enabled = false
activity_log(self.class, "Inicio con parámetros: #{@year} / #{@filepat... | true |
6594c3f2d7ff4c0680e0fab6a2cfbb042c6d512a | Ruby | iNO-4/Ruby-retry | /Ruby-retry-1.7.rb | UTF-8 | 2,844 | 4.25 | 4 | [] | no_license | # 「if文」は、「もしAならばBを実行し、AでなければCを実行」のように、条件や状況に応じて実行内容を変えたい場合に使用する
# 条件に当てはまれば「true」、当てはまらなければ「false」という真意判定を行い、条件に当てはまる場合は「if ~ end」までの処理が行われる
# if 条件
# 処理
# end
puts "実行1"
apple = 110
if apple >= 100
puts "りんごの値段は100円以上です" # true → 処理される
end
if apple <= 100
puts "りんごの値段は100円以上です" # false → 処理されない
end
# 結果は「りんごの... | true |
3218500f25d11251e43fefcc1118b0516823fc4f | Ruby | stevieing/courtbooking | /app/models/slots/null_constraints.rb | UTF-8 | 569 | 2.5625 | 3 | [] | no_license | module Slots
##
# NullConstraints allows for the removal of decision trees in mainly the series
# and the slots class. This could be expanded further into general application
# configuration.
class NullConstraints
##
# NullConstraints will never be valid.
# Eventually this can be changed by repl... | true |
342cb9b083ce832dafc488dba0832e20d58a64f8 | Ruby | benwicker/name_generator | /name_generator.rb | UTF-8 | 1,962 | 3.4375 | 3 | [] | no_license | # require './mailer.rb'
require './person.rb'
require './assignment.rb'
require './texter.rb'
texter = Texter.new()
peopleList = [
Person.new('Ben', 0, '+18658043274', true, true),
Person.new('Emily', 0, '+12703048369', true, true),
Person.new('Becca', 1, '+13143699128', true, true),
Person.new('Phil'... | true |
64364d89d71c40be596a4cea8d78a1669528a47a | Ruby | D-Lessenden/sweater_weather | /spec/models/forecast_spec.rb | UTF-8 | 1,314 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
describe Forecast do
it 'has functioning wind_direction' do
expect(Forecast.wind_direction(348.76)).to eq('North')
expect(Forecast.wind_direction(12)).to eq('North North-East')
expect(Forecast.wind_direction(35)).to eq('North East')
expect(Forecast.wind_direction(57)).to eq('Eas... | true |
270e23631cf6bf24c581943b75c4b9f9d0f06c9c | Ruby | beatrizNajera/scrabble | /app.rb | UTF-8 | 791 | 2.640625 | 3 | [] | no_license | require 'sinatra'
require "./lib/Scrabble.rb"
get '/' do
@@scrabble = Scrabble.new
@letrasIniciales=@@scrabble.obtenerLetrasIniciales
@valorLetras=@@scrabble.obtenerValoresIniciales
erb :scrabble
end
post '/validarPalabra' do
@palabraIngresada = params["palabraIngresada"]
@@scrabble.capturarPalabra param... | true |
4d8331d6096a05350270f7dd744649d07954f396 | Ruby | kurehajime/classifile | /lib/classifile/classify.rb | UTF-8 | 505 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Classifile
module Classifile
##
# Classify files by DSL
class Classify
attr_reader :file, :to_path
def run(target_file, to_path, &block)
raise "TypeError" unless target_file.is_a?(TargetFile)
state = State.new(target_file)
state.to_path = to_path
... | true |
2aafceff68486862fa13d96248f4c1af25f6b1b3 | Ruby | BBSQ/test | /result_file_writer.rb | UTF-8 | 1,152 | 3.1875 | 3 | [] | no_license | require 'csv'
class ResultFileWriter
def initialize(parsed_products, file)
@parsed_products = parsed_products
@file = file
end
def write_to_csv
p = 0
CSV.open(@file, "w") do |csv|
@parsed_products.map do |product|
n = 0
if product.name != ""
until n == product.pri... | true |
d51137e03c18f929b6f014b463b78a06f2c67906 | Ruby | pbrudny/branching_cleaner | /lib/branching_cleaner/branches_cleaner.rb | UTF-8 | 351 | 2.65625 | 3 | [
"MIT"
] | permissive | module BranchingCleaner
class BranchesCleaner < Base
def run
branches_to_drop_database.each do |branch|
puts "* Removing: #{branch}"
BranchCleaner.new(branch).run
end
end
private
def branches_to_drop_database
@branches ||= GIT::branches.split - ['master', '*', cur... | true |
a88424cb9aad634ca866d66a83ae6c5f52d93dfb | Ruby | bootstraponline/ruby_dot | /lib/ruby_dot/class_processor.rb | UTF-8 | 2,744 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | module RubyDot
# Collect fully qualified class & module names
#
# https://github.com/whitequark/parser/blob/master/lib/parser/ast/processor.rb#
# https://github.com/whitequark/ast/blob/master/lib/ast/processor/mixin.rb
class ClassProcessor < ::Parser::AST::Processor
def initialize
super
reset... | true |
6bc784a04fc8de5affc777c9079a357585c2f8f7 | Ruby | crishoj/dep_feat | /spec/conll/token_spec.rb | UTF-8 | 1,418 | 2.515625 | 3 | [] | no_license |
require 'spec/spec_helper'
require 'lib/conll/token'
describe Conll::Token do
before(:each) do
@token = Conll::Token.parse(@token_line)
end
it "should return a Token for a parsed line" do
@token.should be_kind_of(Conll::Token)
end
it "should have a form" do
@token.should respond_to(:form)
e... | true |
3129d41b9574d5d26783334dfbdcadf7bba35680 | Ruby | randsina/bsuir-courses-ruby | /grep/grep.rb | UTF-8 | 2,209 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'zlib'
class Grep
def initialize
@options = {}
@files = []
optparse = OptionParser.new do |opts|
opts.banner = "Usage: ./grep.rb [OPTION]... PATTERN [FILE]..."
@options[:context] = 0
opts.on("-A", "--context=NUM", "Print NUM lines of ou... | true |
683654074d47780373df6bdf06c318bd26098598 | Ruby | hillstew/museo_1908 | /test/photograph_test.rb | UTF-8 | 1,193 | 2.875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/photograph'
class PhotographTest < Minitest::Test
def setup
@attributes = {
id: "1",
name: "Rue Mouffetard, Paris (Boy with Bottles)",
artist_id: "4",
year: "1954"
}
@attributes_with_strings = {
"id"=> "1",
... | true |
a329bd4e508c3f717289c523ae287f48b68e1173 | Ruby | rukshanuddin/COVID_STATS | /lib/covid/API.rb | UTF-8 | 2,768 | 2.65625 | 3 | [
"MIT"
] | permissive | class API
def initialize(country)
uri = URI('https://api.smartable.ai/coronavirus/stats/' + country )
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['Cache-Control'] = 'no-cache'
request['Subscription-Key'] = 'f8d9123060974ea9aeb5b8d26f8cf98a'
... | true |
257e824b770f3210c3f6bcbe1eeb1fb6d4474e63 | Ruby | seamusabshere/switches | /lib/tasks/capistrano_tasks.rb | UTF-8 | 2,536 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # assumes you've got roles, deploy_to, rails_env
require 'pp'
require 'active_support'
require 'zlib'
# basically { :a => 1, :b => 2 }.eql?({ :b => 2, :a => 1}) => true
class StrictComparableHash < Hash
def eql?(other)
self == other
end
# must return an integer or #eql? will be ignored by Comparable
# as... | true |
4ef42fbd99397f21136a2a55f6583ed060d8c6a2 | Ruby | SisuTokenSale/MVPdevelopment | /app/models/concerns/date_marshaler.rb | UTF-8 | 163 | 2.59375 | 3 | [] | no_license | class DateMarshaler
def self.dump(date)
date.is_a?(String) ? date : date.to_s(:db)
end
def self.load(date_string)
Date.parse(date_string)
end
end
| true |
ecfcceb9211811b85a3e102f7abb83633745d39a | Ruby | rrrene/cadenza | /spec/nodes/filtered_value_node_spec.rb | UTF-8 | 1,932 | 2.734375 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Cadenza::FilteredValueNode do
subject { Cadenza::FilteredValueNode }
let(:var_a) { Cadenza::VariableNode.new("foo") }
let(:var_b) { Cadenza::VariableNode.new("bar") }
let(:filter_a) { Cadenza::FilterNode.new("baz", [var_b]) }
... | true |
d0a99fe7707c924607658a51e3af03d6fc106cb0 | Ruby | sauron/aprende.a.programar | /ejercicios/10/10-04.rb | UTF-8 | 326 | 2.9375 | 3 | [] | no_license | def puedeHacerse unProc
if rand(2) == 0
unProc.call
end
end
def hacerDosVeces unProc
unProc.call
unProc.call
end
parpadeo = Proc.new do
puts '<parpadeo>'
end
mirada = Proc.new do
puts '<mirada>'
end
puedeHacerse parpadeo
puedeHacerse mirada
hacerDosVeces parpadeo
hacerDosVeces ... | true |
979bc279f5d39eec18ffeba9c7948f0a19a2b554 | Ruby | jamesjlandry/programming-univbasics-nds-green-grocer-part-1-hou01-seng-ft-060120 | /lib/grocer.rb | UTF-8 | 465 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def find_item_by_name_in_collection(name, collection)
grocery_item = nil
collection.each do |hash|
if hash[:item] == name
grocery_item = hash
end
end
grocery_item
end
def consolidate_cart(cart)
receipt = []
purchases = {}
cart.each do |item|
purchases = find_item_by_name_in_collect... | true |
9479cdb58bf09489abaf1e6c1ef04a3503a47cc7 | Ruby | curzonj/generic_agent | /lib/generic_agent/agent.rb | UTF-8 | 606 | 2.546875 | 3 | [] | no_license | module GenericAgent
class Agent
include Utilities
class << self
def instances
@instances ||= []
end
def load_from(path, namespace=[])
@namespace = namespace.dup.freeze
instance_eval(File.read(path))
end
def resolve_name(name)
[ @namespace, name... | true |
a8f33109e9a88b7c7660293713a76489ee3691dc | Ruby | bassnode/liner_notes | /Liner Notes.app/lib/ruby-processing/helper_methods.rb | UTF-8 | 4,016 | 2.84375 | 3 | [
"MIT"
] | permissive | module Processing
module HelperMethods
# Nice block method to draw to a buffer.
# You can optionally pass it a width, a height, and a renderer.
# Takes care of starting and ending the draw for you.
def buffer(buf_width=width, buf_height=height, renderer=@render_mode)
buf = create_graphics(buf_w... | true |
48748a46a8fe9b27a41e456828419a69df138c91 | Ruby | soulnafein/html_to_markdown | /tests/html_to_markdown/headers_tests.rb | UTF-8 | 917 | 2.84375 | 3 | [] | no_license | require_relative '../tests_setup.rb'
module HtmlToMarkdown
class HeadersTests < MiniTest::Unit::TestCase
def test_that_h1_are_converted_correctly
html = "<h1>An header</h1>"
markdown = "An header\n" +
"=========\n\n"
assert_equal markdown, HtmlToMarkdown.parse(html)
end
... | true |
c8e3d56a63e412c58450b7b95c9f2a57d7dbd490 | Ruby | AJ8GH/oystercard-solo | /spec/oystercard_spec.rb | UTF-8 | 3,298 | 2.84375 | 3 | [] | no_license | describe Oystercard do
let(:entry_station) { double(:entry_station) }
let(:exit_station) { double(:exit_station) }
let(:empty_log) { instance_double(JourneyLog, history: []) }
subject { described_class.new(journey_log) }
let(:journey_log) do instance_double(
JourneyLog, :journey_log,
... | true |
328d1215cddf5674c1fe44971d6460b3b86d1fdf | Ruby | paulmccarthy42/code | /soccer_data.rb | UTF-8 | 434 | 3.03125 | 3 | [] | no_license | text = File.open("football.dat")
array_of_values = []
text.each_line do |x|
array_of_values << x.split(" ")
end
array_of_values.each do |line|
line.delete("-")
end
array_of_values.delete_if {|x| x[0].include?("-")}
array_of_values.delete_if {|x| x.include?("Team")}
test = 0
array_of_values.sort_by! {|x| (x[6]... | true |
a7ec9e31056859006cf953af0f8d5754ce4948ce | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/5eeb6b3257934e74bdd3be63de8e7bee.rb | UTF-8 | 332 | 3.484375 | 3 | [] | no_license | module Nucleotides
def adenosine; 'A' end
def cytidine; 'C' end
def guanosine; 'G' end
def thymidine; 'T' end
def uracil; 'U' end
end
class DNA
include Nucleotides
attr_reader :sequence
def initialize(sequence)
@sequence = sequence
end
def to_rna
sequence.tr(thymidine, uracil... | true |
3dcb41b08c34741ec23a9083315bc14157b7a1f8 | Ruby | moryachok/snippets | /ruby/shorthands.rb | UTF-8 | 153 | 3.328125 | 3 | [] | no_license | # ! - the ampersand
arr = [12,54,23]
arr.sort #[12,23,54], creates brand new list
p arr #[12,54,23]
arr.sort! # modify same list
p arr #[12,54,23]
| true |
b58a6b9dd069a785c70916249213564512b31ca2 | Ruby | JonathanHDavis/lesson-02-homework | /lesson_02_homework.rb | UTF-8 | 1,221 | 4.1875 | 4 | [] | no_license | # # Code Reading
# #creates the fizzbuzz
def fizzbuzz(num)
# Example comment line
#a case statment compares the == and makes conditions
case
#when num divided by the number has remainder, puts string
when num % 15 == 0 then "FizzBuzz"
when num % 3 == 0 then "Fizz"
when num % 5 == 0 then "Buzz"
... | true |
1240b1533e28cd5a32826ecd80101cc474ae6bc7 | Ruby | Haneczka/ruby_training | /test_flatland_game.rb | UTF-8 | 3,718 | 3.21875 | 3 | [] | no_license | require_relative 'flatland_game'
#ugly global variable, to be extracted to class
$tests_stat = {:all => 0, :passed => 0}
def should_be_equal(arg1, arg2)
$tests_stat[:all] += 1
if arg1 == arg2
$tests_stat[:passed] += 1
puts "OK"
else
puts "Test failed: '" + arg1.to_s + "' is not equal to '" + arg2.to_... | true |
522b496b02069cf455ed0d3675c71fc5575c87e0 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/d5c608eed20b457186187dfe754687f8.rb | UTF-8 | 426 | 3.390625 | 3 | [] | no_license | module Hamming
class << self
def compute(first, second)
check_sequences!(first, second)
first.length.times.reduce(0) do |differences, i|
first[i] != second[i] ? differences + 1 : differences
end
end
private
def check_sequences!(first, second)
if first.length != secon... | true |
aa9866e119129153badafca9fd0afdf0fb0fdff8 | Ruby | mwduncan2018/RubyGettingStarted | /Testing/TestUnit/dev/foobar.rb | UTF-8 | 1,089 | 3.78125 | 4 | [] | no_license | module Foobar
class SpecialCharacterError < StandardError
end
class Person
attr_accessor :first_name
attr_accessor :last_name
attr_accessor :age
attr_accessor :salary
attr_accessor :profession
def initialize first_name, last_name, age, salary, profession
... | true |
041bacf843cd4f7d842b70745393ac0706a40005 | Ruby | exp-ndrew/parcels | /lib/Parcel.rb | UTF-8 | 417 | 3.171875 | 3 | [] | no_license | class Parcel
def initialize (length, height, width, weight)
@length = length.to_f
@height = height.to_f
@width = width.to_f
@weight = weight.to_f
end
def length
@length
end
def height
@height
end
def width
@width
end
def weight
@weight
end
def volume
@lengt... | true |
4a99d6e0624374f9b1596324efbd59f04701dae1 | Ruby | MajesticForReal/THP | /day_11/my_super_test_project/lib/04_simon_says.rb | UTF-8 | 739 | 4.09375 | 4 | [] | no_license | def echo(string)
return string
end
def shout(string)
return string.upcase
end
def repeat(string, num = 2)
((string + " ") * num).strip #strip enlève les espaces avant et après un string
end
def start_of_word(string, num)
array = string.split("")
return array[0...num].join
end
def first_word(str... | true |
e1b15bcb08c6b94619266d77822870ba07fbb999 | Ruby | cprice404/puppet-connection-validator | /spec/lib/puppet_spec/http/test_server.rb | UTF-8 | 2,312 | 2.734375 | 3 | [] | no_license | require 'thin'
module PuppetSpec
module Http
class TestServer
class FakeApp
def call(arg)
# This is a callback for handling web requests; it's expected to return a
# a Rack-compatible response ([code, headers, body]). For our purposes, all
# that really matters is that it returns a 200/OK so that t... | true |
482de64174ed11143cf501ec5c5599ef9bc32d91 | Ruby | alexauritt/SecretSanta | /test/santa_assigner_test.rb | UTF-8 | 4,441 | 3.1875 | 3 | [] | no_license | require "test/unit"
require 'mocha'
require_relative "../src/main"
require_relative "../src/santa_assigner"
require_relative "../src/person"
class SantaAssignerTest < Test::Unit::TestCase
def setup
@person1 = Person.new(2,"Fred","James","asdf@asdf.com")
@person2 = Person.new(3,"Mark","James","mark@asdf.com")... | true |
7194170027284c5a7019dc1a564431a0197ecd7d | Ruby | bricestacey/nostos-source-illiad | /lib/nostos-source-illiad/generators/source_illiad_generator.rb | UTF-8 | 1,604 | 2.625 | 3 | [] | no_license | require 'rails/generators'
module SourceIlliad
class InstallGenerator < Rails::Generators::Base
def configure
# Ask General Questions
puts "General Configuration:"
number_of_days_to_poll = ask('How many days in the past would you like to poll Illiad? [7]')
number_of_days_to_poll = 7 if nu... | true |
9d7a44d7c310d750ff7f1c1332397f4a0ff4c4be | Ruby | BBQlettuce/checkers | /game.rb | UTF-8 | 3,411 | 3.765625 | 4 | [] | no_license | require 'byebug'
require_relative 'board'
class Game
attr_reader :p1, :p2, :gameboard
attr_accessor :current_player
def initialize(p1, p2)
@p1 = p1
p1.color = :black
@p2 = p2
p2.color = :red
@current_player = p1
@gameboard = Board.new
end
def play
puts "Play Checkers\n"
unt... | true |
b4ba6f533bb979328b41d73c266c8a1e6f15d9ab | Ruby | dacoloma/learn_ruby | /06_timer/timer.rb | UTF-8 | 315 | 3.25 | 3 | [] | no_license | class Timer
#write your code here
attr_accessor :seconds
def seconds
@seconds = 0
end
def time_string
h = @seconds / 3600
m = (@seconds % 3600 ) / 60
s = (@seconds % 3600 ) % 60
h=format("%02d",h)
m=format("%02d",m)
s=format("%02d",s)
return "#{h}:#{m}:#{s}"
end
end
| true |
aecd6d27fd2dcbb92258c3c45e25b43429606d60 | Ruby | northcott-j/facebook_data_analyzer | /lib/facebook_data_analyzer.rb | UTF-8 | 1,825 | 2.65625 | 3 | [] | no_license | # frozen_string_literal: true
# My script for 'I analyzed my facebook data and it's story of shyness,
# loneliness and change'
module FacebookDataAnalyzer
require 'facebook_data_analyzer/view_model_generators/view_model_generator'
require 'facebook_data_analyzer/view_model_generators/friends_view_model_generator'
... | true |
3fdb5063398988d4e43608b935f2fabab935ba7c | Ruby | Kevintudiep/rocket | /rocket_test.rb | UTF-8 | 1,412 | 2.78125 | 3 | [] | no_license | require "minitest/autorun"
require_relative "rocket"
class RocketTest < Minitest::Test
# Write your tests here!
def setup
@rocket = Rocket.new
end
def test_name_updates
actual = @rocket.name = ("bob")
expected = ("bob")
assert_equal(expected, actual)
end
def test_colour_updates
actu... | true |
0babe2bcd0463c4180185251ed59405cc35d805e | Ruby | 4moms/suitable_services | /lib/suitable_services/base.rb | UTF-8 | 321 | 2.578125 | 3 | [
"MIT"
] | permissive | module SuitableServices
class Base
def self.invoke(options = {})
self.new(options).execute!
end
def initialize(options = {})
@options = options
end
def execute!
raise NoMethodError, "#{self.class}#execute! is undefined"
end
private
attr_accessor :options
end
end... | true |
68137e807fb3d59f9b5fcaad06369ee8eb9438cb | Ruby | Karaignee/marketfinder | /app/models/event.rb | UTF-8 | 1,078 | 2.515625 | 3 | [] | no_license | # == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# title :string(255)
# start :datetime(255)
# end :datetime(255)
# repeat :integer
# location :string(255)
# longitude :float
# latitude ... | true |
c2a8bf83dac5d9ec5e8e8789ba700fcb2a1099f8 | Ruby | RaccoonCode96/Study_Ruby | /Oop/oop05.rb | UTF-8 | 558 | 3.421875 | 3 | [] | no_license | # set, get메서드
class C
def initialize(v)
@value = v
end
def show()
p @value
end
def getValue()
return @value
end
def setValue(v)
@value = v
end
end
c1 = C.new(10)
# p c1.value()
p c1.getValue()
# p c1.value = 20
c1.setValue(20)
c1.show()
# 직접 읽고 쓰고는 불가능하... | true |
e284d6723e6d377aee394e8fb0d6cc96843f2230 | Ruby | domo2192/Enigma | /lib/decrypt.rb | UTF-8 | 275 | 2.59375 | 3 | [] | no_license | require './lib/enigma'
encrypted_text = File.open(ARGV[0])
enigma = Enigma.new
decoded = enigma.decrypt(encrypted_text, ARGV[2], ARGV[3])
File.open(ARGV[1], 'w').write(decoded[:decryption])
p "Created '#{ARGV[1]}' with the key #{decoded[:key]} and date #{decoded[:date]}"
| true |
6ba31dfd754b51a4183fbeccbf22d79565f8d398 | Ruby | pruebasqwerty/repositoriopruebas | /lib_diego.rb | UTF-8 | 744 | 2.765625 | 3 | [] | no_license | MAIL_FORMAT = /[a-z0-9._%+-]*@[a-z0-9.-]*\.[a-z]{2,4}/
INTEGER_FORMAT = /[0-9]{1,32}/
def make_paperclip_hash(file_hash)
hash = {}
hash['tempfile'] = file_hash[:tempfile]
hash['filename'] = file_hash[:filename]
hash['content_type'] = file_hash[:type]
hash['size'] = file_hash[:tempfile].size
return hash
end... | true |
c6335cc4e5ddf3c9b2d70273e4bca48e300f9f20 | Ruby | AdamCross/My-First-Ruby | /Inheritance.rb | UTF-8 | 641 | 4.375 | 4 | [] | no_license | class Main
def self.sayHello(people)
for person in people
p "Hello #{person.name}, you are #{person.age}, and #{person.gender}"
end
end
end
class Person
attr_reader :name, :age, :gender
# Could use attr_writer to make write-only, attr_accessor to make read/write
def initialize(name, age, gender... | true |
4f17dee61fd16a4e9251e428777815ed9ee4d1bf | Ruby | rxfork/guard-webrick | /lib/guard/webrick.rb | UTF-8 | 2,391 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'guard'
require 'spoon'
require 'launchy'
require 'socket'
require 'timeout'
module Guard
class WEBrick < Plugin
attr_accessor :pid
def initialize(options={})
super
@options = {
:host => '0.0.0.0',
:port => 3000,
:ssl => false,
:docroot... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.