source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 21/TicTacToe/spec/game_spec.rb | Ruby | mit | 19 | main | 1,581 | # frozen_string_literal: true
require_relative '../lib/game'
require_relative '../lib/board'
require_relative '../lib/player'
# rubocop:disable Metrics/BlockLength
describe Game do
subject(:game) { described_class.new }
before do
game.instance_variable_set(:@board, instance_double(Board))
end
describe ... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/Gemfile | Ruby | mit | 19 | main | 2,399 | source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.1.2"
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.0.3"
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/config/routes.rb | Ruby | mit | 19 | main | 322 | Rails.application.routes.draw do
devise_for :users
resources :friends
# get 'home/index'
get 'home/about'
# root 'home#index'
root 'friends#index'
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Defines the root path route ("/")
# root "articles#index"
en... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/config/application.rb | Ruby | mit | 19 | main | 704 | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Friends
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails v... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/config/environments/production.rb | Ruby | mit | 19 | main | 3,976 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your applica... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/config/environments/development.rb | Ruby | mit | 19 | main | 2,492 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/config/initializers/devise.rb | Ruby | mit | 19 | main | 15,203 | # frozen_string_literal: true
# Assuming you have not yet modified this file, each configuration option below
# is set to its default value. Note that some are commented out while others
# are not: uncommented lines are intended to protect your configuration from
# breaking changes in upgrades (i.e., in the event that... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/db/schema.rb | Ruby | mit | 19 | main | 1,632 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/db/migrate/20220524040121_devise_create_users.rb | Ruby | mit | 19 | main | 1,401 | # frozen_string_literal: true
class DeviseCreateUsers < ActiveRecord::Migration[7.0]
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.stri... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/db/migrate/20220524032601_create_friends.rb | Ruby | mit | 19 | main | 256 | class CreateFriends < ActiveRecord::Migration[7.0]
def change
create_table :friends do |t|
t.string :first_name
t.string :last_name
t.string :email
t.string :phone
t.string :twitter
t.timestamps
end
end
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/test/test_helper.rb | Ruby | mit | 19 | main | 402 | ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
class ActiveSupport::TestCase
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors, with: :threads)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/test/system/friends_test.rb | Ruby | mit | 19 | main | 1,272 | require "application_system_test_case"
class FriendsTest < ApplicationSystemTestCase
setup do
@friend = friends(:one)
end
test "visiting the index" do
visit friends_url
assert_selector "h1", text: "Friends"
end
test "should create friend" do
visit friends_url
click_on "New friend"
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/test/controllers/friends_controller_test.rb | Ruby | mit | 19 | main | 1,251 | require "test_helper"
class FriendsControllerTest < ActionDispatch::IntegrationTest
setup do
@friend = friends(:one)
end
test "should get index" do
get friends_url
assert_response :success
end
test "should get new" do
get new_friend_url
assert_response :success
end
test "should cre... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/app/controllers/friends_controller.rb | Ruby | mit | 19 | main | 2,320 | class FriendsController < ApplicationController
before_action :set_friend, only: %i[ show edit update destroy ]
before_action :authenticate_user!, except: [:index, :show]
before_action :correct_user, only:[:edit, :update, :destroy]
# GET /friends or /friends.json
def index
@friends = Friend.all
end
#... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/app/controllers/home_controller.rb | Ruby | mit | 19 | main | 287 | class HomeController < ApplicationController
def index
end
def about
@about_me = "My Name is Amey Thakur..."
@GitHub = "https://github.com/Amey-Thakur"
@LinkedIn = "https://www.linkedin.com/in/amey-thakur"
@Twitter = "https://twitter.com/iameythakur"
end
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 23-30/RailsFriends/app/models/user.rb | Ruby | mit | 19 | main | 295 | class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable
has_many :friends
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 13/Hash-3.rb | Ruby | mit | 19 | main | 901 | # Hash in Ruby
names = Hash.new
names["clever"] = "Filly"
names["hot"] = "Mega"
names["funky"] = "Amey"
names["sporty"] = "Hasan"
names.delete("sporty")
puts names.inspect
names.shift
puts names.inspect
names.delete_if{|key, value| key == "hot"}
puts names.inspect
people = Hash.new
people.store("dwarf", "Fi... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 13/Hash-2.rb | Ruby | mit | 19 | main | 664 | # Hash in Ruby
names = Hash.new
names["clever"] = "Filly"
names["hot"] = "Mega"
names["funky"] = "Amey"
names["sporty"] = "Hasan"
puts names["hot"]
puts names.fetch("funky")
puts names.values_at("clever", "sporty")
# For keys availability
puts names.has_key?("clever")
puts names.has_key?("nerd")
puts names.ke... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 13/Hash-1.rb | Ruby | mit | 19 | main | 609 | # Hash in Ruby
countries = {"IN" => "INDIA",
"US" => "UNITED STATES",
"HU" => "HUNGARY",
"UK" => "UNITED KINGDOM",
"NO" => "NORWAY", }
puts "The size of the Hash countries is #{countries.size}"
puts countries.keys.inspect
puts countries.values.inspect
countri... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 19/Arity_method.rb | Ruby | mit | 19 | main | 574 | # Using Arity method in procs
# This method allows us to find how many arguments a proc object expects to receive
my_proc = Proc.new{|x| "Filly " * x}
puts "Hey Filly...! I need #{my_proc.arity} arguments"
puts my_proc.call(5)
my_proc = Proc.new{|x, y| "Filly " * (x + y) }
puts "Hey Filly...! I need #{my_proc.ar... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 19/Difference_between_Procs_&_Lambda.rb | Ruby | mit | 19 | main | 1,224 | # Difference between Procs and Lambda
# Program of a Proc
def my_method
puts "Before Proc"
my_proc = proc{
puts "Inside Proc"
}
my_proc.call
puts "After Proc"
end
my_method
def my_method
puts "Before Proc"
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 14/Random_Numbers.rb | Ruby | mit | 19 | main | 1,124 | # Random numbers in Ruby
puts rand # 0 - 0.99
puts rand*10 # 0 - 0.99
puts (rand*10).to_i # Integer
puts (rand*30 + 10).to_i # Integer between 10 to 30
puts rand(10) #0 - 9
puts rand(10)+1
puts rand(0..10) # Include 10
puts rand(0...10) # Exclude 10
puts (0..5).map{rand(0..10)}
puts (0...5... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 14/Menu_Class.rb | Ruby | mit | 19 | main | 921 | # Menu class (User Defined Class)
class Menu
attr_reader:length_quit
def initialize(*menu_args)
@menu_args = menu_args
@length_quit = length_quit
end
def menu_get_choice
@menu_args.each_with_index do |item, index|
puts "#{index + 1}. #{item}"
end
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 4/Getter_Setter_&_Initialize_Method.rb | Ruby | mit | 19 | main | 733 | # Program of Getter, Setter and Initialize Method in Ruby Class
class Rectangle
# Constructor
def initialize(l,b)
@length = l
@breadth = b
end
# Setter
def setLength=(value)
@length = value
end
def setBreadth=(value)
@breadth = value
end
# Getter
def getLength
return @length
end
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 4/Getter_&_Setter.rb | Ruby | mit | 19 | main | 430 | # Program of Getter, Setter and Initialize Method in Ruby Class
class Rectangle
# Constructor
def initialize(l,b)
@length = l
@breadth = b
end
# Getter
def getLength
return @length
end
def getBreadth
return @breadth
end
end
# Creating an object
rect = Rectangle.new(50,30)
# Getter
x = rect.g... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 4/to_s_method.rb | Ruby | mit | 19 | main | 219 | # program for to_s method
class Rectangle
def initialize(l,b)
@l = 50
@b = 30
end
def to_s
return "Length is #{@l} & breadth is #{@b}"
end
end
rect = Rectangle.new(20,10)
puts "#{rect}"
puts rect |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 4/Shortcut_of_Getter_Setter_and_to_s_Method.rb | Ruby | mit | 19 | main | 433 | # Program for shortcut of getter, setter and also program of to_s method
class Animal
# Setter & Getter
attr_accessor :name, :age, :trait
def to_s
return "The pet name is #{name}, its age is #{age}, and it is #{trait}"
end
end
firstAnimal = Animal.new
firstAnimal.name = "Kitty"
firstAnimal.age = 12
firs... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 22/Hangman.rb | Ruby | mit | 19 | main | 2,080 | class Hangman
def initialize
@word = words.sample
@lives = 7
@word_teaser = ""
@word.first.size.times do
@word_teaser += "_ "
end
end
def words
[
["cricket", "A game played by gentleman"],
["jogging", "We are not walking.... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 10/Require & Require Relative/Class_in_modules.rb | Ruby | mit | 19 | main | 249 | # class in module
module Mymodule
class TestClass
def initialize
puts "TestClass object created"
end
def mymethod
puts "It is a user defined method"
end
end
end
myobject = Mymodule::TestClass.new
myobject.mymethod |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 10/Require & Require Relative/Modules.rb | Ruby | mit | 19 | main | 409 | #code for module
module Trig
PI = 3.14
def Trig.sinfunction(x)
puts Math.sin(x)
end
def Trig.cosfunction(x)
puts Math.cos(x)
end
end
module Moral
Very_bad = 0
Bad = 1
def Moral.sinfunction(badnesslevel)
if (badnesslevel == 0)
puts 'You are very bad'
else
puts 'You are just... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 10/Mixins/Mixins.rb | Ruby | mit | 19 | main | 358 | #Module A
module A
def a1
puts "We are in a1 method of Module A"
end
def a2
puts "We are in a2 method of Module A"
end
end
#Module B
module B
def b1
puts "We are in b1 method of Module B"
end
def b2
puts "We are in b2 method of Module B"
end
end
class Sample
include A
include B
e... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 10/Include statement concept/Mega.rb | Ruby | mit | 19 | main | 349 | # Include Statement
require_relative "Filly.rb"
class Decade
include Week
$no_of_years = 10
def no_of_months
puts "Today is " + Week::First_Day
number = $no_of_years * 12
puts "No. of months in 10 years is " + number.to_s
end
end
d1 = Decade.new
puts Week::First_Day
Week.weeks_in_month
Week.w... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 17/Freezing_Objects-2.rb | Ruby | mit | 19 | main | 383 | # Freezing Objects
class Mouse
attr_accessor:tail_length, :height
def initialize(t,h)
@tail_length = t
@height = h
end
end
mouse = Mouse.new(5, 10)
puts mouse.tail_length
puts mouse.height
mouse.freeze
if(mouse.frozen?)
puts "Yes! Mouse is fro... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 17/Freezing_Objects-1.rb | Ruby | mit | 19 | main | 204 | # Freezing Objects
=begin
# Syntax to freeze an object
object.freeze
# Syntax to check whether an object is frozen or not.. Returns an Boolean value
object.frozen?
=end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 9/Modules.rb | Ruby | mit | 19 | main | 413 | # Program for Modules
module Trig
PI = 3.14159265359
def Trig.sinfunc(x)
puts Math.sin(x)
end
def Trig.cosfunc(x)
puts Math.cos(x)
end
end
module Moral
Very_bad = 0
Bad = 1
def Moral.sinfunc(badnesslevel)
if (badnesslevel == 0)
puts "THE MEGA is very bad"
else
puts "Ame... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 9/Modules_with_Class.rb | Ruby | mit | 19 | main | 254 | # Program for MODULES
module Mymodule2
class TestClass
def initialize
puts "TestClass Object Created"
end
def mymethod
puts "It is a user defined method."
end
end
end
myobject = Mymodule2::TestClass.new
myobject.mymethod |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-5.rb | Ruby | mit | 19 | main | 556 | # Inheritance in Ruby
class Animal
attr_accessor:color, :name
def identify
return "My name is #{@name} and I am from #{self.class}"
end
end
class Tiger < Animal
def initialize(name, color)
@name = name
@color = color
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-4.rb | Ruby | mit | 19 | main | 359 | # Inheritance in Ruby
class Animal
attr_accessor:color, :name
end
class Tiger < Animal
def initialize(name, color)
@name = name
@color = color
end
def speak
return "Grrrr....!!"
end
end
tiger = Tiger.new("Filly", "Blue")... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-1.rb | Ruby | mit | 19 | main | 237 | # Inheritance in Ruby
class Person
attr_accessor:name, :age, :trait
end
class Sportsman < Person
attr_accessor:sports
end
sp = Sportsman.new
sp.age = 20
sp.name = "Filly"
sp.sports = "Basketball"
puts sp.inspect |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-3.rb | Ruby | mit | 19 | main | 359 | # Inheritance in Ruby
class Animal
attr_accessor:color, :name
def initialize(name, color)
@name = name
@color = color
end
end
class Tiger < Animal
def speak
return "Grrrr....!!"
end
end
tiger = Tiger.new("Filly", "Blue")... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-6_Method_Overriding.rb | Ruby | mit | 19 | main | 612 | # Method Overriding - Inheritance in Ruby
class ParentArea
# Constructor
def initialize(w, h)
@width = w
@height = h
end
# To calculate the area from Parent Class
def getArea
return "Area from Parent class is #{@width*@height}"
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 15/Inheritance-2.rb | Ruby | mit | 19 | main | 270 | # Inheritance in Ruby
class Animal
attr_accessor:color, :name
end
class Tiger < Animal
def speak
return "Grrrr....!!"
end
end
tiger = Tiger.new
tiger.color = "Blue"
tiger.name = "Filly"
puts tiger.inspect
puts tiger.speak |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 20/DateTIme_class.rb | Ruby | mit | 19 | main | 649 | =begin
Various ways to get Time and Date
1. Time class
2. Date class
3. DateTime class
# Date.new(yyyy,mm,dd)
# DateTime.new(yyyy, mm, dd, hh, mm, ss,'TimeZone')
=end
require 'date'
d = Date.new(2022, 07, 20)
puts d
d = Date.new
puts d
d = Date.parse('2000-07-20')
puts... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 20/Date_&_Time.rb | Ruby | mit | 19 | main | 887 | # Various ways to initialize the time object
# Time.new(YYYY, mm, dd, hh, mm, ss, 'Time Zone')
time = Time.new(2022, 7, 20, 21, 30, 45, '+05:30')
puts time
time = Time.new(2022, 7, 20, 21, 30, 45)
puts time
time = Time.new(2022, 7, 20)
puts time
time = Time.new(2022)
puts time
time = Time.new
puts time
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 20/Formatting_Time_&_Date.rb | Ruby | mit | 19 | main | 1,050 | # Formatting Time and Date
%a - The abbreviated weekday name (Sun)
%A - The full weekday name (Sunday)
%b - The abbreviated month name (Jan)
%B - The full month name (January)
%c - The preferred local date and time representation
%d - Day of the month (01 to 31)
%H - Hour of the day, 24-hour clock (00 to 23)
%... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 18/Procs_execution-5.rb | Ruby | mit | 19 | main | 369 | # Procs execution and more fundamental concepts
string1 = "Filly"
string2 = "Filly"
puts "Comparison results of strings: #{string1 == string2}"
proc1 = Proc.new{"Filly"}
proc2 = Proc.new{"Filly"}
puts "Comparison results of proc objects: #{proc1 == proc2}"
proc1 = Proc.new{"Filly"}
proc2 = proc1.dup
puts "Compa... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 18/&Block-2.rb | Ruby | mit | 19 | main | 200 | # Implicit way - using &Block
def my_method(&my_block)
puts "Hello Method"
my_block.call
return my_block
end
block_var = my_method{puts "Hello Block"}
block_var.call |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 12/Two-dimensional_array-1.rb | Ruby | mit | 19 | main | 259 | # 2D Array
cells = [['a', 'b', 'c', 'd', 'e'],['f', 'g', 'h', 'i', 'j']]
puts cells[1][2]
cells.each do|row|
row.each do|col|
print col.to_s + " "
end
puts
end
cells.each do|row|
puts row.join(', ')
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 12/Two-dimensional_array-2.rb | Ruby | mit | 19 | main | 239 | # 2D Array - Create 10*10 2D array with each element as "0"
box = []
10.times do |row|
box[row] = []
10.times do
box[row] << 0
end
end
for row in box
puts (row.inspect)
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 6/More_on_loops.rb | Ruby | mit | 19 | main | 213 | # More on loops
8.times do puts "Filly..!" end
4.times {puts "THE MEGA"}
3.upto (7) {puts "Amey"}
3.upto (7) {|i| puts "Amey #{i}"}
7.downto (3) {|i| puts "Amey #{i}"}
0.step(15,5){|i| puts "Hey Filly #{i}"} |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 6/While_modifier.rb | Ruby | mit | 19 | main | 220 | # Program for While Modifier
=begin
while modifier syntax:
begin
Code
end while condition
=end
$i = 0
$num = 5
begin
puts ("We are inside the loop with $i value = #$i");
$i += 1
end while $i < $num |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 6/Until_modifier.rb | Ruby | mit | 19 | main | 202 | # Program for Until Modifier
=begin
until modifier syntax:
begin
Code
end until condition
=end
$i = 0
$num = 5
begin
puts ("Inside the loop $i = #$i");
$i += 1
end until $i > $num |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 2/Passing_multiple_parameters_to_a_single_method.rb | Ruby | mit | 19 | main | 270 | # Passing multiple parameters to a single method in Ruby
def sample(*test)
puts "The number of parameters is #{test.length}"
for i in 0...test.length
puts "The parameters are #{test[i]}"
end
end
sample "Filly", "23", "F", "THE MEGA"
sample "Amey", "22", "M" |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 8/Block_with_parameters.rb | Ruby | mit | 19 | main | 203 | # Program of Block With Parameters
def call_block
puts "Start of method"
yield("Filly", "2022")
puts"End of method"
end
call_block do
|str, num| puts "Inside the block: " +str+" "+ num.to_s
end |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 16/Operator_overloading-3.rb | Ruby | mit | 19 | main | 230 | # Operator overloading in Ruby
# <", ">", "=" Comparable operators
include Comparable
def <=> (other)
return self.value<=>other.value
end
puts "Filly"<=>"Filly"
puts "Filly"<=>"Mega"
puts 10<=>20
puts 100<=>20 |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 16/Operator_overloading-1.rb | Ruby | mit | 19 | main | 472 | # Operator overloading in Ruby
class Animal
attr_accessor:name, :trait
def initialize(name, trait)
@name = name
@trait = trait
end
def +(other_object)
return Animal.new("#{self.name}#{other_object.name}", "#{self.trait}#{other_object.tra... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 16/Operator_overloading-4.rb | Ruby | mit | 19 | main | 433 | # Operator overloading in Ruby
# <", ">", "=" Comparable operators
class Myclass
include Comparable
attr_accessor:myname
def initialize(name)
@myname = name
end
def <=> (other)
return self.myname<=>other.myname
end
end
obj1 = Myclass.... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 16/Operator_overloading-5.rb | Ruby | mit | 19 | main | 701 | # Operator overloading in Ruby
# +", "-", "*", "/", "*", "%", "**" Operators
class Tester
attr_accessor:num
def initialize(num)
@num = num
end
def +(other)
return self.num+other.num
end
def *(other)
return ... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 16/Operator_overloading-6.rb | Ruby | mit | 19 | main | 486 | # Operator overloading in Ruby
# "[]", "[]", "<<", Operators using Array
class Tester
attr_accessor:arr
def initialize(*arr)
@arr = arr
end
def [] (x)
return @arr[x]
end
def []=(x, value)
@arr[x] = value
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 11/Array_basics_&_fundamentals-2.rb | Ruby | mit | 19 | main | 617 | # Array basics and fundamentals
names = Array.new(6, "Filly...!")
puts names
puts "#{names}"
digits = Array(0...9)
puts digits
digits = Array(0..9)
puts digits
puts digits.at(5)
fruits = ["apple", "banana", "pineapple"]
veggies = ["carrot", "radish", "cabbage"]
edibles = fruits + veggies
puts "Yeah, this... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 11/Array_basics_&_fundamentals-3.rb | Ruby | mit | 19 | main | 483 | # Array basics and fundamentals
a = ['F', 'i', 'l', 'l', 'y']
print a
print(a[0,5])
print(a[-5,5])
print(a[0..4])
print(a[-5..-1])
b = Array.new(a)
puts b
c= [1, 2, 3, 4]
a.concat(c)
print a
a.delete("i")
print a
a.delete_at(0)
print a
puts a.size
puts a.length
puts a.inspect
puts a.empty?
... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 11/Array_basics_&_fundamentals-1.rb | Ruby | mit | 19 | main | 268 | # Array basics and fundamentals
data = [ 1, 2.0, 4.9, "Filly", "Amey" ]
puts data
data.each{|x| puts x}
puts data[3]
puts data[-2]
data[0] = "THE MEGA"
puts data
# Push operation in array
data << "Hello World!"
puts data
puts data[-1]
data.pop
puts data |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 5/Class_Variable.rb | Ruby | mit | 19 | main | 441 | # Program for Class Variable i.e. @@x
class Filly
# Initialize our class variables
@@count = 0;
def initialize(l,b)
@length = l
@breadth = b
# @@count = @@count + 1
@@count += 1
end
def printcount()
puts "Number of objects created is: #{@@count}"
end
end
# Create two objects
filly1 ... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | web/source/Day 5/Class_Variable_with_Self_Method.rb | Ruby | mit | 19 | main | 442 | # Program for Class Variable i.e. @@x with self method
class Filly
# Initialize our class variables
@@count = 0;
def initialize(l,b)
@length = l
@breadth = b
# @@count = @@count + 1
@@count += 1
end
def self.printcount
puts "Number of objects created is: #{@@count}"
end
end
# Create... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | Ruby web/app.rb | Ruby | mit | 19 | main | 4,986 | require 'bundler/setup'
Bundler.require(:default)
require 'sinatra'
require 'commonmarker'
require 'json'
require 'fileutils'
# Dynamic Source Code Explorer logic
module RubyChallenge
# Source Code is in the parent directory of 'Ruby web'
SOURCE_DIR = File.expand_path('../Source Code', __dir__)
CURRICULUM_DATA ... |
github | Amey-Thakur/RUBY | https://github.com/Amey-Thakur/RUBY | Ruby web/README.rb | Ruby | mit | 19 | main | 17,272 | require 'commonmarker'
markdown_text = <<'MARKDOWN'
<div id="readme-top"><a name="readme-top"></a></div>
<div align="center">
# <a href="https://amey-thakur.github.io/RUBY/"><img src="docs/Ruby%20Logo.png" height="55" valign="middle"></a> <br> Ruby Programming Challenge
[
def create_initializer_file
template "railsui_icon.rb", "config/initializers/railsui_icon.rb"
end
def update_tailwind_config
tailwind_c... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | lib/railsui_icon/icon.rb | Ruby | mit | 19 | main | 4,095 | require "nokogiri"
module RailsuiIcon
class Icon
VALID_VARIANTS = %i[solid outline mini micro].freeze
attr_reader :name, :variant, :options, :custom_path
def initialize(name:, variant: RailsuiIcon.configuration.default_variant, options: {}, custom_path: nil)
@name = name
@variant = validate... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | lib/railsui_icon/configuration.rb | Ruby | mit | 19 | main | 221 | # frozen_string_literal: true
module RailsuiIcon
class Configuration
attr_accessor :default_class, :default_variant
def initialize
@default_class = ""
@default_variant = :outline
end
end
end |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | lib/railsui_icon/railtie.rb | Ruby | mit | 19 | main | 966 | module RailsuiIcon
class Railtie < ::Rails::Railtie
config.railsui_icon = ActiveSupport::OrderedOptions.new
initializer "railsui_icon.configure" do |app|
config_file = Rails.root.join("config", "initializers", "railsui_icon.rb")
app.config.railsui_icon.config_file = config_file
# Load the ... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | lib/railsui_icon/helpers.rb | Ruby | mit | 19 | main | 739 | # frozen_string_literal: true
module RailsuiIcon
module Helpers
include ActionView::Helpers::AssetUrlHelper
def icon(name, options = {})
options[:variant] ||= :outline
options[:class] = options.fetch(:class, nil)
custom_path = resolve_custom_path(options[:custom_path])
result = Rail... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/test_helper.rb | Ruby | mit | 19 | main | 983 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
require "rails/test_help"
# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_paths=... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/railsui_icon_test.rb | Ruby | mit | 19 | main | 500 | require "test_helper"
class RailsuiIconTest < ActiveSupport::TestCase
test "RailsuiIcon is a module" do
assert_kind_of Module, RailsuiIcon
end
test "RailsuiIcon has a version" do
assert_kind_of String, RailsuiIcon::VERSION
end
test "RailsuiIcon engine isolates namespace" do
assert_equal "railsu... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/railsui_icon/helpers_test.rb | Ruby | mit | 19 | main | 931 | require "test_helper"
require "fileutils"
class HelpersTest < ActiveSupport::TestCase
include Rails.application.routes.url_helpers
setup do
@dummy_class = Class.new do
include RailsuiIcon::Helpers
end
@dummy_instance = @dummy_class.new
end
test "icon helper renders with default options" do
... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/railsui_icon/icon_test.rb | Ruby | mit | 19 | main | 1,151 | require "test_helper"
require 'minitest/autorun'
require 'railsui_icon/icon'
class IconTest < Minitest::Test
def setup
RailsuiIcon.configure do |config|
config.default_variant = :outline
config.custom_icon_paths = ['/custom/icon/path']
end
end
def test_render_existing_icon
icon = Railsui... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/dummy/config/environments/production.rb | Ruby | mit | 19 | main | 4,099 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot. This eager loads most of Rails and
# your app... |
github | getrailsui/railsui_icon | https://github.com/getrailsui/railsui_icon | test/dummy/config/environments/development.rb | Ruby | mit | 19 | main | 2,595 | require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for developme... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | metadata.rb | Ruby | apache-2.0 | 19 | main | 573 | # frozen_string_literal: true
name 'drbd'
maintainer 'Sous Chefs'
maintainer_email 'help@sous-chefs.org'
license 'Apache-2.0'
description 'Provides resource-first DRBD installation and pair orchestration.'
version '5.0.0'
source_url 'https://github.com/sous-chefs/d... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | resources/drbd_install.rb | Ruby | apache-2.0 | 19 | main | 854 | # frozen_string_literal: true
provides :drbd_install
unified_mode true
property :instance_name, String, name_property: true
property :packages, [String, Array],
coerce: proc { |value| Array(value) },
default: lazy { default_packages }
property :manage_repository, [true, false], default: lazy { manag... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | resources/drbd_pair.rb | Ruby | apache-2.0 | 19 | main | 2,424 | # frozen_string_literal: true
provides :drbd_pair
unified_mode true
property :local_host, String, default: lazy { local_drbd_host }
property :local_ip, String, required: true
property :remote_host, String, required: true
property :remote_ip, String, required: true
property :disk, String, required: true
property :devi... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | examples/roles/drbd-pair-master.rb | Ruby | apache-2.0 | 19 | main | 355 | name 'drbd-pair-master'
description 'DRBD pair role.'
override_attributes(
'drbd' => {
'remote_host' => 'ubuntu2-1004.vm',
'remote_ip' => '192.168.0.1',
'local_ip' => '192.168.0.2',
'disk' => '/dev/sdb1',
'fs_type' => 'xfs',
'mount' => '/shared',
'master' => true,
}
)
run_list(
'reci... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | examples/roles/drbd-pair.rb | Ruby | apache-2.0 | 19 | main | 326 | name 'drbd-pair'
description 'DRBD pair role.'
override_attributes(
'drbd' => {
'remote_host' => 'ubuntu1-1004.vm',
'remote_ip' => '192.168.0.2',
'local_ip' => '192.168.0.1',
'disk' => '/dev/sdb1',
'fs_type' => 'xfs',
'mount' => '/shared',
}
)
run_list(
'recipe[xfs]',
'recipe[drbd::pai... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | attributes/default.rb | Ruby | apache-2.0 | 19 | main | 379 | # frozen_string_literal: true
default['drbd']['packages'] = nil
default['drbd']['remote_host'] = nil
default['drbd']['disk'] = nil
default['drbd']['mount'] = nil
default['drbd']['fs_type'] = 'ext3'
default['drbd']['dev'] = '/dev/drbd0'
default['drbd']['master'] = false
default['drbd']['port'] = 7789
default['drbd']['c... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | spec/unit/resources/drbd_pair_spec.rb | Ruby | apache-2.0 | 19 | main | 2,304 | # frozen_string_literal: true
require 'spec_helper'
describe 'drbd_pair' do
step_into :drbd_pair
platform 'ubuntu', '24.04'
context 'with configure action' do
recipe do
drbd_pair 'pair' do
local_host 'node-a'
local_ip '192.0.2.10'
remote_host 'node-b'
remote_ip '192.0.... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | spec/unit/resources/drbd_install_spec.rb | Ruby | apache-2.0 | 19 | main | 1,328 | # frozen_string_literal: true
require 'spec_helper'
describe 'drbd_install' do
step_into :drbd_install
context 'on ubuntu' do
platform 'ubuntu', '24.04'
recipe do
drbd_install 'default'
end
it { is_expected.to install_package(%w(drbd-utils)) }
end
context 'on red hat enterprise linux... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | test/integration/default/controls/default_spec.rb | Ruby | apache-2.0 | 19 | main | 675 | # frozen_string_literal: true
control 'drbd-install-01' do
impact 1.0
title 'DRBD userspace tools are installed'
describe file('/etc/drbd.conf') do
it { should exist }
end
describe command('drbdadm -V') do
its('exit_status') { should eq 0 }
end
end
control 'drbd-config-01' do
impact 0.7
titl... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | test/cookbooks/test/recipes/default.rb | Ruby | apache-2.0 | 19 | main | 212 | # frozen_string_literal: true
drbd_install 'default'
drbd_pair 'pair' do
local_host 'node-a'
local_ip '192.0.2.10'
remote_host 'node-b'
remote_ip '192.0.2.11'
disk '/dev/sdb1'
action :configure
end |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | libraries/helpers.rb | Ruby | apache-2.0 | 19 | main | 1,236 | # frozen_string_literal: true
module Drbd
module Cookbook
module Helpers
def default_packages
return %w(drbd8-utils) if platform?('debian') && node['platform_version'].to_i <= 9
return %w(drbd9x-utils kmod-drbd9x) if el9_x86_64_rpm_platform?
return %w(drbd-utils kmod-drbd) if platfo... |
github | sous-chefs/drbd | https://github.com/sous-chefs/drbd | recipes/pair.rb | Ruby | apache-2.0 | 19 | main | 648 | # frozen_string_literal: true
drbd_install 'default' do
packages node['drbd']['packages'] if node.dig('drbd', 'packages')
manage_repository !node['drbd']['custom_repo']
end
drbd_pair 'pair' do
remote_host node['drbd']['remote_host']
remote_ip node['drbd']['remote_ip']
local_ip node['drbd']['local_ip']
dis... |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | capitalize_names.gemspec | Ruby | mit | 19 | master | 830 | # -*- encoding: utf-8 -*-
# frozen_string_literal: true
require File.expand_path("../lib/capitalize_names/version", __FILE__)
Gem::Specification.new do |s|
s.name = "capitalize-names"
s.version = CapitalizeNames::VERSION
s.summary = "Capitalizes names; handles edge cases."
s.description = "A si... |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | lib/capitalize_names.rb | Ruby | mit | 19 | master | 491 | # frozen_string_literal: true
# originally based on http://dzone.com/snippets/capitalize-proper-names
require "capitalize_names/errors"
require "capitalize_names/suffixes"
require "capitalize_names/surnames"
require "capitalize_names/capitalizer"
module CapitalizeNames
class << self
def capitalize!(name, option... |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | lib/capitalize_names/suffixes.rb | Ruby | mit | 19 | master | 287 | # frozen_string_literal: true
module CapitalizeNames
SUFFIXES = [
"II",
"(II)",
"III",
"(III)",
"IV",
"(IV)",
"VI",
"(VI)",
"VII",
"(VII)",
"2nd",
"(2nd)",
"3rd",
"(3rd)",
"4th",
"(4th)",
"5th",
"(5th)",
]
end |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | lib/capitalize_names/surnames.rb | Ruby | mit | 19 | master | 9,673 | # frozen_string_literal: true
module CapitalizeNames
SURNAMES = [
"ApShaw",
"d'Albini",
"d'Aubigney",
"d'Autry",
"d'Entremont",
"d'Hurst",
"D'ovidio",
"DaSilva",
"DeAnda",
"deAnnethe",
"deAubigne",
"deAubigny",
"DeBardelaben",
"DeBardeleben",
"DeBaugh",
... |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | lib/capitalize_names/capitalizer.rb | Ruby | mit | 19 | master | 5,281 | # frozen_string_literal: true
module CapitalizeNames
class Capitalizer
attr_reader :name, :options
NAME = %r{
( # start capture
(?: # start first name token
(?:(?:van\ )|(?:de\ (?:la\ )?)|(?:d... |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | lib/capitalize_names/errors.rb | Ruby | mit | 19 | master | 210 | # frozen_string_literal: true
module CapitalizeNames
module Errors
class GenericError < StandardError; end
class InvalidName < GenericError; end
class InvalidOption < GenericError; end
end
end |
github | infiton/capitalize-names | https://github.com/infiton/capitalize-names | test/test_capitalize_names.rb | Ruby | mit | 19 | master | 6,788 | # frozen_string_literal: true
require "minitest/autorun"
require "capitalize_names"
class CapitalizeNamesTest < Minitest::Test
def test_capitalization
assert_equal("Tate", CapitalizeNames.capitalize("TATE")) # basic upcase
assert_equal("Smith", CapitalizeNames.capitalize("smith")) # basic downcase
asser... |
github | crayfishx/puppet-purge | https://github.com/crayfishx/puppet-purge | Gemfile | Ruby | apache-2.0 | 19 | master | 521 | source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_GEM_VERSION') ? "#{ENV['PUPPET_GEM_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.8.2'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
gem 'mocha'
# JSON must be 1.x on Ruby 1.9
if RUBY_VERSION < '2.0'
ge... |
github | crayfishx/puppet-purge | https://github.com/crayfishx/puppet-purge | Rakefile | Ruby | apache-2.0 | 19 | master | 660 | ENV['SPEC_OPTS'] ||= "--format documentation"
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc "Validate manifests, templates, and ruby files"
task :validate ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.