text stringlengths 10 2.61M |
|---|
class AgentSerializer < ActiveModel::Serializer
attributes :id, :alias, :barcode
has_many :hits
end
|
# Copyright 2012 6fusion, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed t... |
# -*- coding : utf-8 -*-
require 'spec_helper'
describe Mushikago::Hanamgri::GetListAnalysesRequest do
shared_examples_for 'a valid request instance for list_analyses' do |n, o|
subject{ Mushikago::Hanamgri::GetListAnalysesRequest.new(n, o) }
it{ should be_kind_of(Mushikago::Http::GetRequest) }
its(:path... |
# https://inside.pixiv.blog/subal/4615
module LaravelMixHelper
class BundleNotFound < StandardError; end
def asset_bundle_path(entry, **options)
raise BundleNotFound, "Could not find bundle with name #{entry}" unless manifest.key? entry
asset_path(manifest.fetch(entry), **options)
end
def javascript_... |
module SolrIndexer
def self.refresh_and_reindex(types)
self.refresh_external_data
self.reindex(types)
end
def self.reindex(types)
Rails.logger.info("Starting Solr Re-Index")
types_to_index(types).each(&:solr_reindex)
Sunspot.commit
Rails.logger.info("Solr Re-Index Completed")
end
def... |
ActionController::Routing::Routes.draw do |map|
map.resources :whitelist_emails, :controller => "whitelist_emails"
end |
class PostsController < ApplicationController
# before_action :post_params
def index
@posts = Post.order("created_at DESC")
end
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
if @post.save
redirect_to root_path, notice: "最高の癒しを投稿しました"
else
render :n... |
# frozen_string_literal: true
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 :users_events
... |
# frozen_string_literal: true
# rubocop:todo all
require 'spec_helper'
describe Mongo::Server::Description do
%w[ismaster isWritablePrimary].each do |primary_param|
context "#{primary_param} as primary parameter" do
let(:replica) do
{
'setName' => 'mongodb_set',
primary_param... |
class ProductoMovimiento < ActiveRecord::Base
self.table_name='productos_movimientos'
attr_accessible :producto_id, :tipo_movimiento_id, :cantidad_entrada, :cantidad_salida, :fecha_movimiento, :compra_detalle_id, :remision_detalle_id, :devolucion_id, :producto_diluido_id
scope :ordenado_id, -> {order... |
class AddNombreToFields < ActiveRecord::Migration
def change
add_column :fields, :nombre, :string
end
end
|
Fabricator(:house) do
price 100_000.0
address "La Tabariere"
location "Fresnay-le-Samson"
zip "61120"
latitude 48.8829769
longitude 0.208493
region "Pays d'Auge"
title "La Normande bourgeoise"
description "Alentours : 4km de Vimoutiers, village tou..."
bedrooms 4
size 200.0
garden_size 6000.0
... |
class CreateCommentVotesTable < ActiveRecord::Migration
def change
create_table :comment_votes do |t|
t.integer :comment_id
end
end
end |
require 'rspec/support/spec'
require 'rspec/support/ruby_features'
RSpec::Support::Spec.setup_simplecov do
minimum_coverage 93
end
require 'yaml'
begin
require 'psych'
rescue LoadError
end
RSpec::Matchers.define :include_method do |expected|
match do |actual|
actual.map { |m| m.to_s }.include?(expected.to_... |
require "test_helper"
require 'models/movie'
require 'app'
describe "Movie" do
include Rack::Test::Methods
def app
API::App
end
describe "Create Movie " do
before do
post "/movies", movie: {
name:"life of pi",
description:"a beautiful adventure of a castaway..",
imageurl:"https://1.bp.blogspot... |
class DonationsController < ApplicationController
load_and_authorize_resource
def index
@donations = Donation.confirmed
@your_donations = current_user.donations if current_user
end
def create
@donation = Donation.new(params[:donation])
@donation.currency = params[:donation][:currency]
if ... |
require 'test_helper'
class RelativesControllerTest < ActionDispatch::IntegrationTest
setup do
@relative = relatives(:one)
end
test "should get index" do
get relatives_url
assert_response :success
end
test "should get new" do
get new_relative_url
assert_response :success
end
test "... |
module V1
class NicknameFansController < ApplicationController
before_action :set_club, only: :from_club
skip_before_action :authenticate_user!
def index
@fans = NicknameFan.all
respond_with :v1, @fans
end
def from_club
@fans = @club.nickname_fans
respond_with :v1, @fan... |
# == Schema Information
#
# Table name: galleries
#
# id :bigint not null, primary key
# title :string not null
# description :text
# user_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
class Gallery < Applic... |
# encoding: UTF-8
module OmniSearch::Engines
# a scoring system devised to match
# the incidence of 'trigrams' sequences of three letters
# doggie has a few
# dog ogg ggi gie
#
class Triscore < Base
def score_list
results = []
matches.each do |match|
score = match_score(match)
... |
# frozen_string_literal: true
module Dynflow
module Executors
class Parallel
class Pool < Actor
class JobStorage
def initialize
@jobs = []
end
def add(work)
@jobs << work
end
def pop
@jobs.shift
end
... |
require File.dirname(__FILE__) + '/../test_helper'
class HelpfulsControllerTest < ActionController::TestCase
ANON_TOKEN_COOKIE_NAME = ApplicationController::ManageAnonymousToken::ANON_TOKEN_COOKIE_NAME
def setup
@helpful_given_action_points = 20
@helpful_received_action_points = 40
actio... |
class CreatePhotos < ActiveRecord::Migration
def up
create_table :photos do |t|
t.integer "gallery_id"
t.string "nazwa"
t.integer "pozycja"
t.boolean "widoczne", :default => true
t.string "opis"
t.attachment :zdjecie
t.timestamps null: false
end
end
def down
drop_ta... |
require 'rails_helper'
feature 'Projects CRUD' do
before :each do
User.destroy_all
user = User.new(first_name: 'Bob', last_name: 'Dole', email: 'bob@dole.com', password: 'bob', admin: true)
user.save!
visit root_path
click_link 'Sign In'
fill_in :email, with: 'bob@dole.com'
fill_in :pass... |
require 'test_helper'
class ListTest < ActiveSupport::TestCase
test "list requires name" do
list = List.new()
assert_not list.valid?, "Name is required"
end
test 'valid list' do
list = List.new(name: 'TestList')
assert list.valid?, 'Name is only required field for list'
... |
require 'spec_helper'
describe "Memos update:" do
subject { page }
context "when user is logged in" do
let(:user) { FactoryGirl.create(:user) }
let(:memo) { FactoryGirl.create(:memo, user: user) }
let(:submit) { "Update" }
before do
log_in user
visit edit_memo_path memo
end
aft... |
class CustomerService < ActiveRecord::Base
belongs_to :partner
has_many :timetable_customer_services
accepts_nested_attributes_for :timetable_customer_services, allow_destroy: true
attr_accessible :active_record,
:partner_id,
:timetable_customer_services_attributes
validates :partner_i... |
# encoding: utf-8
require "spec_helper"
require "logstash/patterns/core"
describe "SHOREWALL" do
let(:pattern) { "SHOREWALL" }
context "parsing a message with OUT interface" do
let(:value) { "May 28 17:23:25 myHost kernel: [3124658.791874] Shorewall:FORWARD:REJECT:IN=eth2 OUT=eth2 SRC=1.2.3.4 DST=1.2.3.4... |
class ApplicantDeclaration < ApplicationRecord
has_paper_trail
belongs_to :applicant
has_many :declaration_details,dependent: :destroy
accepts_nested_attributes_for :declaration_details, allow_destroy: true
end
|
require 'time'
class Event < ApplicationRecord
has_many :event_users, dependent: :destroy
has_many :users, through: :event_users
scope :name_search, -> (search_term) { where("name iLIKE ?", "%#{search_term}%")}
scope :city_search, -> (search_term) { where("city iLIKE ?", "%#{search_term}%")}
scope :state_sea... |
class AppnexusApi::LogLevelDataService < AppnexusApi::Service
def initialize(connection, options = {})
@read_only = true
@siphon_name = options[:siphon_name]
super(connection)
end
def since(time = nil)
params = {}
params[:siphon_name] = @siphon_name if @siphon_name
params[:updated_since]... |
Juno::Blog::Engine.routes.draw do
root :to => 'juno/blog/posts#index'
match '/:slug(.:format)' => 'juno/blog/posts#show', :defaults => { :format => 'html' }, :as => :post
end
|
#!/usr/bin/ruby
$:.unshift(File.dirname(__FILE__) + '/lib')
$:.unshift(File.dirname(__FILE__) + '/ext/nwsaprfc')
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/../ext/nwsaprfc')
require 'sapnwrfc'
$SAP_CONFIG = ENV.has_key?('SAP_YML') ? ENV['SAP_YML'] : 'sap.yml'
require 'test/u... |
# encoding: utf-8
class ChangeColumnRecipeStepDraftContent < ActiveRecord::Migration
def up
change_column :recipe_step_drafts, :content, :text
end
def down
change_column :recipe_step_drafts, :content, :string
end
end
|
require 'choice'
require 'erb'
require 'fileutils'
BASEDIR = File.dirname(__FILE__)
class String
def slug
#strip the string
ret = self.strip
#blow away apostrophes
ret.gsub! /['`]/,""
# @ --> at, and & --> and
ret.gsub! /\s*@\s*/, " at "
ret.gsub! /\s*&\s*/, " and "
#replace all n... |
json.array!(@apis) do |api|
json.extract! api, :id, :consultar
json.url api_url(api, format: :json)
end
|
class AddSplitMethodToExpense < ActiveRecord::Migration
def change
add_column :expenses, :split_method, :string, default: 'equally'
end
end
|
class UserSetting < ActiveRecord::Base
belongs_to :user
belongs_to :theme
def is_in_recruit_mode?
recruit_mode == 1
end
def is_in_apply_mode?
apply_mode == 1
end
def theme_name
theme.present? ? theme.name : "default"
end
end
|
class Unit
attr_reader :name, :health, :movement, :actions
attr_accessor :x, :y
def initialize (player, name)
@player = player
@name = name
@health = 10
@movement = 2
@actions = []
end
def hurt(damage)
return if dead?
@health -= damage
die if dead?
end
def dead?
ret... |
class Library
def initialize
@books = []
end
# putsメソッドの内部処理to_sを上書き
def to_s
puts "Library contents:"
# @booksをループさせる?
end
end
class Book
def initialize(hash)
@author = hash[:author]
@title = hash[:title]
@library = hash[:library]
end
# putsメソッドの内部処理to_sを上書き
def to_s
"T... |
class AddInviteCodeToStores < ActiveRecord::Migration
def change
add_column :stores, :invite_code, :string
end
end
|
module AIBot::Protocol
PROTOCOL_BLOCKS = {}
##
# Gets a protocol instance.
def self.for(symbol, configuration)
PROTOCOL_BLOCKS[symbol].call configuration
end
##
# Registers a protocol which the bot can use.
def self.register(symbol, &block)
PROTOCOL_BLOCKS[symbol] = block
end
##
# A pro... |
require_relative 'plane.rb'
DEFAULT_CAPACITY = 7
class Airport
def planes
@planes ||= []
end
def plane_count
planes.count
end
def land(plane)
# raise "Hanger is full" if full?
planes << plane
end
def take_off(plane)
planes.delete(plane)
end
def full?
plane_count == capacity
end
... |
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root "questions#index"
resources :questions
resources :answers, only: [:show, :create, :destroy, :update]
resources :questions do
resources :answers, only: [:show, :create,... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "rails_base"
config.vm.box_url = "/Users/michael/rails-workspace/lab-report-container/rai... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port,... |
RSpec.describe RSpec::Mocks::AnyInstance::MessageChains do
let(:recorder) { double }
let(:chains) { RSpec::Mocks::AnyInstance::MessageChains.new }
let(:stub_chain) { RSpec::Mocks::AnyInstance::StubChain.new recorder }
let(:expectation_chain) { RSpec::Mocks::AnyInstance::PositiveExpectationChain.new recorder }
... |
class AddChargeToDesignations < ActiveRecord::Migration[6.0]
def change
add_column :designations, :charge, :string
end
end
|
class RatesController < ApplicationController
require 'csv'
require 'open-uri'
before_action :authorize_admin
before_action :handle_retro_tiers, :handle_rates_updates, :handle_administrative_rate, only: :create
def index
if params[:year].present?
@year = params[:year].to_i
@base_rat... |
json.users @users do |user|
json.call(
user, :id, :created_at, :email, :name
)
end
json.total @users.total_count
|
class InstitutionFacility < ActiveRecord::Base
belongs_to :facility
belongs_to :institution
end
|
require 'rails_helper'
describe UserOtpSender do
describe '#send_otp' do
context 'when user only has email 2FA and is not two_factor_enabled' do
it 'resets unconfirmed_mobile and only sends OTP to email' do
user = create(:user, unconfirmed_mobile: '5005550006')
allow(user.second_factors).to... |
require 'rails_helper'
RSpec.describe TopicsController, type: :controller do
let(:member) { create(:user) }
let(:other_member) { create(:user, name: "Other Member", email: "other_member@bloc.io") }
let(:admin) { create(:user, name: "Admin", email: "admin@bloc.io", role: :admin) }
let(:my_book_club) { create(:b... |
class AdminController < ApplicationController
before_action :require_admin
def require_admin
unless user_signed_in? && current_user.has_role?(:admin)
flash[:danger] = "You do not have admin access!"
redirect_to root_path
end
end
end |
ActiveAdmin.register Kbase::StationTrack do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
# or
# permit_params do
# permitted = [:perm... |
require_relative 'stripe_keys'
require 'rest-client'
require 'pry'
require 'json'
####################
# METHODS
####################
# Prints a list of products and returns
# the user's choice
def get_user_choice(products)
puts "AVAILABLE PRODUCTS"
products.each_with_index do |product, index|
puts "#{index}. ... |
require 'rubygems' # Try and fix the "no such file to load" errors
require 'addressable/uri' # Encoding
require 'csv' # CSV Parsing
require_relative 'DateTools' # Date handling
#require 'mail' ... |
# frozen_string_literal: true
# rubocop:todo all
# Copyright (C) 2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... |
module Ricer::Plug::Params
class PermissionParam < Base
def convert_in!(input, message)
permission = Ricer::Irc::Permission.by_name(input)
failed_input if permission.nil?
permission
end
def convert_out!(value, message)
value.to_label
end
end
end
|
class LessonsController < ApplicationController
before_action :authenticate_user!
before_action :req_enrolled_for_lessons
def show
end
private
def req_enrolled_for_lessons
if current_user.enrolled_in?(current_lesson.section.guide) != true
redirect_to guide_path(current_lesson.section.guide)... |
# == Schema Information
# Schema version: 20110406232901
#
# Table name: pages
#
# id :integer not null, primary key
# body :text
# title :string(255)
# page_img_url :string(255)
# page_name :string(255)
# activate_as_splash :boolean
# created_at ... |
require_relative '../simple_struct'
class Number < SimpleStruct.new(:value)
def to_s
value.to_s
end
def reducible?
false
end
def evaluate(environment)
self
end
end
|
SS::Application.routes.draw do
concern :deletion do
get :delete, :on => :member
end
concern :copy do
get :copy, :on => :member
put :copy, :on => :member
end
concern :move do
get :move, :on => :member
put :move, :on => :member
end
concern :template do
get :template, :on => :coll... |
# == Schema Information
#
# Table name: reports
#
# id :uuid not null, primary key
# device_id :uuid not null
# sender :text not null
# message :text not null
# created_at :datetime not null
#
require 'rails_helper'
RSpec.describe Report, typ... |
class RemoveUserFromTail < ActiveRecord::Migration[5.1]
def change
remove_column :tails, :user_id
end
end
|
require 'httparty'
require 'hashie'
class CommonStandardsDownload
BASE_URL = 'http://api.commonstandardsproject.com/api/v1/'
def self.run(api_key, limit=nil)
dl = self.new(api_key, limit)
dl.fetch
end
def initialize(api_key, limit=nil)
@api_key = api_key
@limit = limit
puts @limit
end
... |
class CreateChanperms < ActiveRecord::Migration
def change
create_table :chanperms do |t|
t.integer :user_id, :null => false
t.integer :channel_id, :null => false
t.integer :permissions, :null => false, :default => 0
t.boolean :online, :null => false, :default => false
... |
require 'spec_helper'
describe AdditionalCost do
let(:user) { User.make! }
it "should be invalid without a user and a name" do
additional_cost = AdditionalCost.new()
additional_cost.should have(1).error_on(:name)
additional_cost.should have(1).error_on(:user_id)
additional_cost.errors.count.should... |
class Restaurant < ActiveRecord::Base
has_many :reviews, dependent: :destroy
validates :name, presence: true, uniqueness: true, length: { minimum: 2 }
validates :cuisine, presence: true
def average_rating
if self.reviews.any?
memo = self.reviews.to_ary.inject(0) { |m, v| m + v.rating }
memo / self.reviews.... |
class UpdateColumnNameInUsers < ActiveRecord::Migration[5.2]
def change
rename_column :users, :role, :site_role
end
end
|
require "integration/factories/collection_factory"
require "integration/factories/backend_services_factory"
class UrlMapsFactory < CollectionFactory
def initialize(example)
@backend_services = BackendServicesFactory.new(example)
super(Fog::Compute[:google].url_maps, example)
end
def cleanup
super
... |
class AddColumnsToAddress < ActiveRecord::Migration[5.1]
def change
add_column :addresses, :longitude, :float
add_column :addresses, :latitude, :float
add_column :addresses, :street_number, :string
add_column :addresses, :street_address, :string
add_column :addresses, :district, :string
add_co... |
require 'rails_helper'
RSpec.describe PropertyReservation, type: :model do
describe '#valid?' do
before(:each) do
property_type = PropertyType.create!(name: 'tipo')
property_location = PropertyLocation.create!(name: 'local')
property_owner = PropertyOwner.create!(email:... |
class Users::TweetsController < Users::BaseController
def index
@tweets = Tweet.time_line(current_user).paginate(:page => params[:page], :per_page => 10)
end
def create
@tweet = current_user.tweets.new(tweet_params)
if @tweet.save
render :create
else
render :create
end
end
p... |
class WebhookController < ApplicationController
def gem
if Rubygem.create(json)
head 200
else
head 400
end
end
protected
def json
@json ||= JSON.parse(request.body.read)
end
end
|
# Jenkins Pullover Main Application
# Author:: Sam de Freyssinet (sam@def.reyssi.net)
# Copyright:: Copyright (c) 2012 Sittercity, Inc. All Rights Reserved.
# License:: MIT License
#
# Copyright (c) 2012 Sittercity, Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this ... |
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most comm... |
class ProjectsController < ApplicationController
load_and_authorize_resource
before_action do
@participations = current_user.participations.ordered_by_last_usage.includes(:project)
@projects = @participations.map(&:project)
@other_projects = Project.where.not(id: @participations.select(:project_id)).o... |
class Admin::WebinarsController < ApplicationController
before_action :admin_access
def index
@upcoming = Webinars::Webinar.upcoming
@past = Webinars::Webinar.past
end
def new
@webinar = Webinars::Webinar.new(date: DateTime.current.change({ hour: 23, minute: 0 }))
end
def create
date = Da... |
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 :coats
has_many :messages
with_options p... |
require_relative './spec_helper'
require 'marquise'
describe Marquise do
describe ".new" do
it "bombs out without an argument" do
expect { Marquise.new }.to raise_error
end
it "returns a Marquise instance when given a zmq URL" do
expect(Marquise.new('tcp://localhost:4567')).to be_a(Marquise)
end
... |
# In the previous two exercises, you developed methods that convert simple numeric strings to signed Integers. In this exercise and the next, you're going to reverse those methods.
# Write a method that takes a positive integer or zero, and converts it to a string representation.
# You may not use any of the standard... |
class Note < ActiveRecord::Base
belongs_to :opportunity
validates :title, :description, presence: true
end
|
class DrugStocksQuery
include Memery
CACHE_VERSION = 1
def initialize(facilities:, for_end_of_month:)
@facilities = Facility.where(id: facilities)
set_facility_group
set_blocks
@for_end_of_month = for_end_of_month
@protocol = @facility_group.protocol
@district = @facility_group.region
... |
class Event < ActiveRecord::Base
has_many :users
has_many :comments, dependent: :destroy
validates :name, :state, :location, :date, presence: true
end |
class PortfoliosController < ApplicationController
def new
@portfolio = Portfolio.new
end
def create
@portfolio = Portfolio.new
@portfolio.name = params[:portfolio][:name]
@user = current_user
@portfolio.user_id = current_user.id
if @portfolio.save
flash.now[:notice] = "Portfol... |
require "test_helper"
describe SessionsController do
# it "should get login" do
# get login_path
# value(response).must_be :success?
# end
#
# it "should get new" do
# get sessions_new_url
# value(response).must_be :success?
# end
#
# it "should get destroy" do
# get sessions_destroy_... |
require_relative '../strategies/valid_types'
require_relative '../../domain/exceptions/no_elements_found'
require_relative '../../../../lib/rachinations/domain/modules/common/hash_init'
require_relative '../../../../lib/rachinations/domain/modules/common/refiners/number_modifiers'
class Edge
include HashInit
usin... |
module PaymentProcessing
class Subscribe
def initialize(options)
@member = options[:member]
@reference = options[:reference] ||= nil
@paystack_key = options[:paystack_key] ||= nil
@current_user = options[:staff_name]
@subscribe_date = options[:su... |
require 'rails_helper'
describe 'navigate' do
before(:all) do
@user = create(:user)
end
before do
login_as(@user, scope: :user)
end
describe 'index' do
before do
visit posts_path
end
it 'can be reached successfully' do
expect(page.status_code).to eq(200)
end
it 'has a title of Posts' do
... |
cask 'font-monoid-tight-large-l' do
version :latest
sha256 :no_check
# github.com/larsenwork/monoid was verified as official when first introduced to the cask
url 'https://github.com/larsenwork/monoid/blob/release/Monoid-Tight-Large-l.zip?raw=true'
name 'Monoid-Tight-Large-l'
homepage 'http://larsenwork.co... |
class UnitsController < ApplicationController
before_action :authenticate_user!
load_and_authorize_resource
before_action :set_current_user, only: :create
before_action :set_unit, only: [:edit, :update, :destroy]
respond_to :json, :html
def index
@units = Unit.includes(:act_indicator_relations, :meas... |
# Write a Ruby script that acts as a calculator:
# Ask the user for 2 numbers
# First show the result of the 2 numbers added together
# Then show the result of the second number deducted by the first number
# Show the result of the multiplication of the two numbers
# And finally show the result of t... |
=begin
INJECTOR
injector merupakan salah satu iterator yang dimiliki oleh ruby. Iterator ini merupakan iterator
yang lumayan sulit untuk digunakan dibandingkan dengan iterator lain. Iterator Injector memiliki
dua argumen. Argument pertama digunakan untuk sebagai variabel untuk menampung nilai dari akum... |
module VRBO
class Availability
attr_accessor :start_at, :duration, :error, :dates
# assumes dates are in ascending order
def initialize(the_dates = nil)
@dates = the_dates || []
if dates.any?
@start_at = Date.parse(dates.shift)
else
@start_at = Date.today
@error... |
class GuestUser < User
attr_accessor :name, :first_name, :last_name, :middle_name, :email
end
|
if Rails.env.production? || Rails.env.development?
class ActiveSupport::BufferedLogger
def formatter=(formatter)
@log.formatter = formatter
end
end
class Formatter
SEVERITY_TO_COLOR_MAP = {'DEBUG'=>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
def cal... |
class JoinCartItem < ApplicationRecord
belongs_to :cart
belongs_to :item
end
|
=begin
https://www.codewars.com/kata/56541980fa08ab47a0000040
=end
# my solution
def printer_error(s)
valid_chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm']
numerator = 0
s.each_char { |char| numerator += 1 if !valid_chars.include?(char) }
denominator = s.length
return ("#{numerator}/... |
require 'logger'
require 'rubygems'
require 'tailor/spacing'
require 'tailor/indentation'
require 'term/ansicolor'
module Tailor
# Calling modules will get the Ruby file to check, then read by line. This
# class allows for checking of line-specific style by Represents a single
# line of a file of Ruby code. I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.