text stringlengths 10 2.61M |
|---|
=begin
#===============================================================================
Title: Party Trade Scene
Author: Hime
Date: Nov 8, 2013
--------------------------------------------------------------------------------
** Change log
Nov 8, 2013
- Initial release
-------------------------------------------... |
class CreateProgramsServicesTable < ActiveRecord::Migration
def up
create_table :programs_services, :id => false do |t|
t.references :program
t.references :service
end
end
def down
end
end
|
require 'lugg/request_matcher'
module Lugg
describe RequestMatcher do
it 'starts as inactive' do
expect(subject).not_to be_active
end
it 'starts as unfinished' do
expect(subject).not_to be_finished
end
context 'after matching a "Started" line' do
before do
subject =~ '... |
class TicketsController < ApplicationController
include SessionManagement
before_action :set_project
before_action :set_ticket, only: [:show, :edit, :update, :destroy]
before_action :require_login, except: [:show, :index]
helper_method :require_login
helper_method :current_user
def new
@ticket = @project.ti... |
module HBase
module Model
module CompressionType
NONE = "NONE"
RECORD = "RECORD"
BLOCK = "BLOCK"
CTYPES = [NONE, RECORD, BLOCK]
def to_compression_type(type_string)
CTYPES.include?(type_string) ? type_string : NONE
end
module_function :to_compression_type... |
class Status <ActiveRecord::Base
has_many :scoreboards
has_many :users, through: :scoreboards
end |
class ApplicationController < ActionController::Base
protect_from_forgery
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :username, :password, :password_confirmati... |
class CreateTableSkillAssessments < ActiveRecord::Migration
def self.up
create_table :skill_assessments do |t|
t.references :subject
t.references :subject_skill
t.references :subject_assessment
t.boolean :marks_added, :default => false
t.integer :submission_status
t.boolean :ed... |
module Destructable
def destroy(anyObject)
puts "I will destroy the object"
end
end
class User
# adds all the methods from module
include Destructable
#shortcut for writing getters/setters
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
... |
class RemoveUserIdFromCalendar < ActiveRecord::Migration
def up
remove_column :calendars, :user_id
end
def down
add_column :calendars, :user_id, :integer
end
end
|
#!/usr/bin/env ruby
require 'mojinizer'
resources = File.expand_path('../src/main/resources', File.dirname(__FILE__))
romaji_to_katakana = {}
romaji_to_hiragana = {}
kana_to_romaji = {}
romaji_to_katakana.merge!(Mojinizer::ROM_TO_KATA1)
romaji_to_katakana.merge!(Mojinizer::ROM_TO_KATA2)
romaji_to_katakana.merge!(Mo... |
class AddBrandingsToExistingStudios < ActiveRecord::Migration
class Studio < ActiveRecord::Base
has_one :branding
end
class Branding < ActiveRecord::Base
belongs_to :studio
end
def self.up
Studio.all.map { |s| s.branding= Branding.create! }
end
def self.down
end
end
|
require_relative '../../../../spec_helper'
describe 'govuk_envsys', :type => :class do
let(:file_path) { '/etc/environment' }
context 'as a file not a template' do
let(:facts) {{}}
# with_content does not currently accept an argument.
it { is_expected.to contain_file(file_path).with_source('puppet:///... |
require 'minitest/autorun'
require "rogue"
include ::Rogue
describe 'RogueObject' do
before do
@rogue_object = RogueObject.new
end
it 'can be set with arbitrary properties' do
@rogue_object.with_properties(first_name:'Clifton', last_name: 'Craig')
end
it 'can retrieve arbitrary properties with dot n... |
describe "volume template requests" do
let(:volume_template_format) do
{
"id" => String,
"instance_template" => String,
"name" => String,
"description" => String,
"parent" => Fog::Nullable:... |
# frozen_string_literal: true
def fizz_buzz(int)
if (int % 15).zero?
'Fizz Buzz'
elsif (int % 3).zero?
'Fizz'
elsif (int % 5).zero?
'Buzz'
else
int.to_s
end
end
|
class Idea
include Comparable
attr_reader :title,
:description,
:rank,
:id,
:tags,
:image,
:date
def initialize(attributes = {})
@title = attributes["title"]
@description = attributes["description"]
@rank ... |
class CreatePhoneNumbers < ActiveRecord::Migration
def change
create_table :phone_numbers do |t|
t.references :phonable, :polymorphic => true, :null => false
t.string :country_code, :null => false
t.string :phone_number, :null => false
t.timestamps
end
end
end |
class IdeasController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :find_idea, only: [:show, :edit, :update, :destroy, :like]
def index
@likes = session[:likes]
@ideas = Idea.all
@idea = Idea.new
end
def new
@idea = Idea.new
end
def cr... |
# Given a string that consists of some words and an assortment of non-alphabetic characters, write a method that returns that string with all of the non-alphabetic characters replaced by spaces. If one or more non-alphabetic characters occur in a row, you should only have one space in the result (the result should neve... |
class User < ApplicationRecord
has_secure_password
has_many :pictures
has_many :comments
validates :username, length: {minimum: 4}
validates :username, uniqueness: true
validates :email, uniqueness: true
validates :password, length: {minimum: 4}
def received_comments
end
en... |
class OrdersController < ApplicationController
before_action :set_order, only: [:show, :edit, :update, :destroy]
before_action :check_for_director_access, except: [:create, :new, :user_orders, :show]
def toggle_status_entregue
@order = Order.find params[:id]
@order.status = 1
@order.save
redirec... |
class Event < ActiveRecord::Base
belongs_to :user,:counter_cache => true
belongs_to :post
belongs_to :province
belongs_to :city
belongs_to :spot
belongs_to :event_tag,:counter_cache => true
has_one :event_fee,:dependent => :destroy
has_many :event_pictures,:dependent => :delete_all
has_many :eve... |
class UsersController < ApplicationController
before_action :authenticate_user!, only: [:edit, :update]
before_action :check_authorization, only: [:edit, :update]
before_action :set_user, only: [:show, :edit, :update]
def show
end
def edit
end
def update
if @user.update(user_params)
if par... |
require_relative 'singular_handler'
module YARD::Handlers::Ruby::ActiveRecord::Associations
class BelongsToHandler < SingularHandler
handles method_call(:belongs_to)
private
def return_description
"#{namespace} <b>belongs to</b> a #{class_name}"
end
end
end
|
class Parent
attr_reader :name
def initialize name, gender
@name = name
@gender = gender
end
end
|
require 'wicked_pdf'
require_relative './htmlentities'
require_relative './helpers'
require_relative './sparql_queries'
module DocumentGenerator
class VisitReport
include DocumentGenerator::Helpers
def initialize
@inline_css = ''
end
def generate(path, data, history)
coder = HTMLEntiti... |
#! ruby -Ku
=begin
2015/08/01
日記を書くためスクリプト
保存に関連する処理をまとめたファイル
=end
require "fileutils"
require "kconv"
OUTPUT_DIR = "nikki_output/" #日記の保存先フォルダ
#保存フォルダのチェック処理
def check_save_dir()
#保存フォルダが存在しない場合は、フォルダ作成する
if File.exists?(OUTPUT_DIR) == false
Dir::mkdir(OUTPUT_DIR)
end
end
#保存処理(マークダウン... |
class RemoveOwneridFromNotes < ActiveRecord::Migration[5.1]
def change
remove_column :notes, :owner_id, :integer
end
end
|
class Withdrawal
include ActiveModel::Model
attr_accessor :amount, :banknotes
validates :amount, numericality: { greater_than_or_equal_to: 0, allow_nil: true }
validate :notes_availability, unless: proc { |withdrawal| (withdrawal.amount.to_i % 10).zero? }
AVAILABLE_NOTES = [100, 50, 20, 10].freeze
def c... |
require 'chef/provider/package'
require 'open-uri'
require 'json'
class Chef::Provider::Package::Npm < ::Chef::Provider::Package
def initialize(new_resource, run_context)
super
@user = run_context.node[:npm][:user]
end
def load_current_resource
@current_resource = Chef::Resource::NpmPackage.new(@n... |
# frozen_string_literal: true
require 'test_helper'
class TeacherTest < ActiveSupport::TestCase
test 'validations' do
teacher = Teacher.new
refute teacher.valid?
assert_equal ["can't be blank"], teacher.errors.messages[:first_name]
assert_equal ["can't be blank"], teacher.errors.messages[:last_name... |
require 'test_helper'
class Users::ProfilesControllerTest < ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
test "should show artist profile to artist" do
artist = users(:artist)
sign_in(artist)
get profile_url(artist)
assert_response 200
end
test "should show artist ... |
class CreateGame < ActiveRecord::Migration[4.2]
def change
create_table :games do |t|
t.integer :home_team_id
t.integer :away_team_id
t.integer :stadium_id
t.string :date
t.string :time
end
end
end |
class ApplicationController < ActionController::Base
skip_before_action :verify_authenticity_token
before_action :configure_permitted_parameters, if: :devise_controller?
def after_sign_in_path_for(resource)
stored_location_for(resource) || '/restaurants'
end
protected
def configure_permitted_parameters
... |
require 'rails_helper'
describe StackExchange do
let(:stack_exchange) { StackExchange.new("stackoverflow", 1) }
describe "#questions", vcr: { cassette_name: "stack_exchange_questions" } do
it "should return a list of questions" do
questions = stack_exchange.questions
expect(questions.class).to eq... |
json.array!(@lawyers) do |lawyer|
json.extract! lawyer, :id, :firstname, :secondname, :email, :phonenumber, :lawfirm_id, :category_id, :username, :hashed_password, :salt, :role_id
json.url lawyer_url(lawyer, format: :json)
end
|
require 'yaml'
module SesProxy
class Conf
def self.get
YAML.load_file(File.join(ENV["HOME"],".ses-proxy","ses-proxy.yml"))
end
end
end |
class Api::TracksController < ApplicationController
def index
@tracks = Track.all
render 'index'
end
def create
name = params[:name]
roll = params[:roll]
@track = Track.new(name:name, roll:roll)
@track.save
render 'show'
end
def destroy
@track = Track.find_by_id(params[:id])
... |
class CreateUsers < ActiveRecord::Migration
def change
create_table :users, :id => false do |t|
t.uuid :contents, array:true
t.uuid :app_id
t.uuid :id, :primary_key => true, default: "uuid_generate_v4()"
t.string :auth_token
t.integer :role_mask
t.timestamps
end
end
end
|
class Sinatra::ContentFor2::HamlHandler < Sinatra::ContentFor2::BaseHandler
def is_type?
template.respond_to?(:is_haml?) && template.is_haml?
end
def block_is_type?(block)
template.block_is_haml?(block)
end
def capture_from_template(*args, &block)
eval("_hamlout ||= @haml_buffer", block.binding)... |
module Lolita
# Basic module for custom Lolita controllers. Is used in Lolita::RestController.
module ControllerAdditions
def self.included(base_class)
base_class.class_eval do
include Lolita::Controllers::InternalHelpers
include Lolita::Controllers::AuthenticationHelpers
if ... |
module Api
module V1
class PasswordsController < Devise::PasswordsController
skip_before_action :verify_authenticity_token
respond_to :json
api :POST, '/v1/passwords'
param :email, String, :required => true
def create
@user = User.find_by_email(params[:email])
if ... |
class FunnelsResultIsNoneByDefault < ActiveRecord::Migration
def self.up
change_column :funnels, :result, :string, :default => "none"
end
def self.down
change_column :funnels, :result, :string, :default => nil
end
end
|
require 'test_helper.rb'
class VotesControllerTest < ActionController::TestCase
test "User should be able to vote for survey question" do
login(users(:social))
old_rating = questions(:q1).rating
assert_equal old_rating, Vote.where(question_id: questions(:q1).id).count
assert_difference "Vote.coun... |
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, :omniauth_providers => [:facebo... |
class Seed
def self.begin
seed = Seed.new
seed.generate_items
end
def generate_items
Item.destroy_all
puts "Destroyed all items..."
20.times do |i|
item = Item.create!(
artist: Faker::Book.author,
title: Faker::Book.title,
cost: Random.rand(10...40),
ima... |
class SurveyResponseLink < ApplicationRecord
belongs_to :survey
belongs_to :survey_response
end
|
require 'rails_helper'
RSpec.describe Person, type: :model do
describe 'associations' do
it { is_expected.to have_one(:user).dependent(:restrict_with_error) }
it { is_expected.to have_one(:address).dependent(:destroy) }
it { is_expected.to have_many(:phones).dependent(:destroy).inverse_of(:person) }
en... |
require("minitest/autorun")
require('minitest/reporters')
require_relative("../fish.rb")
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
class TestFish < MiniTest::Test
def setup()
@fish = Fish.new("Nemo")
end
def test_get_name()
assert_equal("Nemo", @fish.name())
end
def test_set_... |
class House < ApplicationRecord
validates :name, :author, :source, presence: true
has_many :members
end
|
class User < ApplicationRecord
include Devise::JWT::RevocationStrategies::JTIMatcher
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,... |
require 'test/unit'
require 'de'
class DeOperatorTest < Test::Unit::TestCase
class SomeOperator < De::Operator; end
class SomeValidOperand < De::Operand;
def valid?
true
end
end
class SomeInvalidOperand < De::Operand;
def valid?
false
end
end
def test_constructor
assert_ra... |
require 'spec_helper'
require 'duo_calculator'
describe DuoCalculator do
before(:each) do
@user = FactoryGirl.create(:user)
@calculator = DuoCalculator.new(@user)
@team = FactoryGirl.create(:team)
@team.users << @user
end
context "get team members" do
it "should return the team members" do
... |
class Procedure < ApplicationRecord
belongs_to :task
validates :content, presence: true, length: { maximum: 255 }
validates :deadline, presence: true
validate :pretend_ago
#validatesを設定する必要あり
def check_finishment
if self.finishment == true
return "完了"
else
return "未完了"
... |
class Person
attr_accessor :first_name
def initialize(attributes = {})
@first_name = attributes[:first_name]
end
end |
class RenameVesselIceClass < ActiveRecord::Migration
def self.up
rename_column :vessels, :ice_class, :ice_class_id
end
def self.down
rename_column :vessels, :ice_class_id, :ice_class
end
end
|
#
# Specifying rufus-tokyo
#
# Tue Jan 27 16:30:34 JST 2009
#
require File.dirname(__FILE__) + '/spec_base'
require 'rufus/tokyo'
describe 'Rufus::Tokyo::List' do
before do
@l = Rufus::Tokyo::List.new
end
after do
@l.free
end
it 'should be empty initially' do
@l.size.should.be.zero
end
... |
class Transaction < ActiveRecord::Base
belongs_to :account
has_and_belongs_to_many :sub_categories
end
|
class Transaction < ApplicationRecord
belongs_to :account
validates :account_id, :amount, presence: true
end
|
# frozen_string_literal: true
module Pulfalight
class LocationCode
def self.config_file_path
Rails.root.join("config", "location_codes.yml")
end
def self.config_file
@config_file ||= IO.read(config_file_path.to_s)
end
def self.config_erb
@config_erb ||= ERB.new(config_file).re... |
class SoundboardController < ApplicationController
def index
end
def meow
play_and_respond_to "meow.mp3"
end
def woof
play_and_respond_to "woof.mp3"
end
def moo
play_and_respond_to "moo.mp3"
end
def meeh
play_and_respond_to "meeh.mp3"
end
private
def play_and_respond_to f... |
class SwordController < ApplicationController
before_action :check_for_valid_collection_slug, only: [:deposit]
before_action :check_basic_http_authentication, only: [:deposit, :service_document]
before_action :check_depositor_collection_permission, only: [:deposit]
def deposit
# here, take a look at the sl... |
require 'pry'
class Dog
attr_accessor :name, :breed, :id
# attr_reader :id
def initialize(props={})
# props.each {|k, v| self.send(("#{k}"), v)}
@id = props[:id]
# binding.pry
@name = props[:name]
@breed = props[:breed]
end
def self.create_table
sql = "CREATE TABLE dogs (
id INT... |
class Carta
attr_accessor :numero, :pinta
@@pintas = ['C','D','E','T']
def initialize(numero = Random.rand(1..13) , pinta= @@pintas.sample)
@numero = numero
@pinta = pinta
end
def to_s
"#{@numero} - #{@pinta}"
end
end
cinco_cartas = Array.new(5){Carta.new}
cinco_cartas... |
# frozen_string_literal: true
require 'test_helper'
module Vedeu
module Views
class DefaultAttributesTest
include Vedeu::Views::DefaultAttributes
def nil_for_testing_purposes
nil
end
alias client nil_for_testing_purposes
alias colour nil_for_testing_purposes
alias... |
class GameMailer < ApplicationMailer
default from: 'lagalaxygamereviews@gmail.com'
def new_game(gamerequest)
@gamerequest = gamerequest
mail(
to: gamerequest.user.email,
subject: "Request Approved for #{gamerequest.name}"
)
end
end
|
#!/usr/bin/env ruby
#^syntax detection
# use dependencies defined in metadata.json
# metadata
# use dependencies defined in Modulefile
# modulefile
# Shortcut for a module from GitHub's boxen organization
def github(name, *args)
options ||= if args.last.is_a? Hash
args.last
else
{}
end
if path = opt... |
require 'test_helper'
class Movie::ActorsControllerTest < ActionDispatch::IntegrationTest
setup do
@movie_actor = movie_actors(:one)
end
test "should get index" do
get movie_actors_url
assert_response :success
end
test "should get new" do
get new_movie_actor_url
assert_response :success... |
require 'spec_helper'
module Spree
describe Variant do
context "filter assemblies" do
let(:mug) { create(:product) }
let(:tshirt) { create(:product) }
let(:variant) { create(:variant) }
# this method implementation was unused & removed but may come back
# context "varia... |
class DeleteTopicCommand
include ActiveEvent::Command
attributes :id, :thema_id
end
|
# frozen_string_literal: true
RSpec.describe J8::Predicate do
before(:each) do
@predicate = J8::Predicate.new(->(object) { object == true })
end
describe '.new' do
context 'when given a valid callable' do
it 'then creates a new predicate' do
expect(@predicate).to be_a(J8::Predicate)
... |
class Book < ApplicationRecord
belongs_to :user
has_many :comments
has_many :categories
has_one_attached :image
extend ActiveHash::Associations::ActiveRecordExtensions
belongs_to_active_hash :category
validates :image, presence: true
validates :book_name, presence: true, length: { maximum: 30 }
vali... |
require_relative '../access_tokens/create'
module Users
class Authenticate < Mutations::Command
VALID_SCOPES = %w( user )
required do
string :username
string :password
string :grant_type, in: %w( password )
array :scope, class: String
end
def validate
if self.scope.siz... |
Thebigshake::Application.routes.draw do
devise_for :admins
mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'
root 'home#index'
resources :bands, only: [:show, :update]
get 'project', to: 'home#project'
get 'team', to: 'home#team'
get 'comments', to: 'home#comments'
end
|
require 'json'
class Calendario
def initialize(nombre)
@nombre = nombre
end
def getNombre()
@nombre
end
def setNombre(nombre)
@nombre = nombre
end
def to_json
{"nombre"=>@nombre}
end
end
|
require 'mocha/deprecation'
module Mocha
module Integration
end
end
integration_files = []
if defined?(Test::Unit::TestCase) && !(defined?(MiniTest::Unit::TestCase) && (Test::Unit::TestCase < MiniTest::Unit::TestCase))
integration_files << 'mocha/integration/test_unit'
end
if defined?(MiniTest::Unit::TestCase)
... |
require 'rails_helper'
RSpec.describe PhotosController, type: :controller do
login_user
let(:user) { current_user }
let(:album) { create(:album, user: user) }
let(:photo) { create(:photo, album: album) }
let(:request_exec) { get :edit, params: { user_id: user.id, album_id: album.id, id: photo.id } }
desc... |
class Poker
attr_accessor :hand1, :hand2
def initialize(hand1, hand2 = 0)
@hand1 = hand1
@hand2 = hand2
end
def best_hand
if hand2 == 0
hand1
end
end
end |
# https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
# 108. Convert Sorted Array to Binary Search Tree
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val = 0, left = nil, right = nil)
# @val = val
# @left = le... |
class Artist
attr_accessor :name
#an artist is initialized with a name and an empty @songs array
def initialize(name)
@name = name
@songs = []
end
#the artist class needs an instance method, the #add_song that takes in an argument of a song and adds the song to the artist collection of songs. The #add_s... |
require "fibs/version"
class Fibs
include Enumerable
def self.call(n)
Fibs.new(1, 1).take(n)
end
def initialize(seed1, seed2)
@a, @b = [seed1, seed2]
end
def each
loop do
yield @a
@a, @b = [@b, @a + @b]
end
end
end
|
require_relative '../command_options.rb'
class CleanupOptions
extend CommandOptions
def initialize(opts)
@dry_run = false
if opts.empty? or (opts.size == 1 and (opts[0] == '-n' or opts[0] == '--dry-run'))
@clean_pkg_cache = true
@clean_src_cache = true
else
@clean_pkg_cache = fals... |
# This code may look unusually verbose for Ruby (and it is), but
# it performs some subtle and complex validation of JSON data.
#
# To parse this JSON, add 'dry-struct' and 'dry-types' gems, then do:
#
# api_data = APIData.from_json! "{…}"
# puts api_data["…"]
#
# emojis = Emojis.from_json! "{…}"
# puts emojis[... |
require 'csv'
class User < ActiveRecord::Base
belongs_to :coaching_org, class_name: 'Org'
belongs_to :developing_engagement, class_name: 'Engagement'
has_many :posted_comments, foreign_key: 'user_id', dependent: :destroy
has_many :comments, dependent: :destroy, as: :commentable
has_many :client_orgs, class_n... |
require './test_helper.rb'
class TestEachWithObject < MiniTest::Unit::TestCase
def setup
@register = EachWithObject.new
end
def test_
assert_equal ["drib", "hsif"], @register.even_sum(["cat", "dog", "bird", "fish"])
assert_equal ["yknuhc"],
@register.even_sum(["why", "chunky", nil, "lucky", ... |
class CreateSws < ActiveRecord::Migration
def change
create_table :sws do |t|
t.integer :menu, :default => 0
t.boolean :use_mobile_menu, :default => true
t.boolean :use_db_menu, :default => true
t.boolean :use_yesterday_domitory_menu, :default => false
t.boolean :use_db_medi, ... |
module FellowshipOne
class ContributionList
include Enumerable
attr_reader :count, :page_number, :total_records, :additional_pages
# Constructor.
#
# @param options A hash of options for loading the list.
#
# Options:
# :page - The page number to get.
# :reader - The Reader to... |
class RemoveColumnsFromProducts < ActiveRecord::Migration
def change
remove_attachment :products, :picture
remove_column :products, :image
end
end
|
require "application_system_test_case"
class CommandActionsTest < ApplicationSystemTestCase
setup do
@command_action = command_actions(:one)
end
test "visiting the index" do
visit command_actions_url
assert_selector "h1", text: "Command Actions"
end
test "creating a Command action" do
visit... |
module RailsConnector
module CmsAttributes
extend ActiveSupport::Concern
module ClassMethods
def cms_attribute(name, options = {})
type = options[:type]
case type
when :string
default = options[:default] || ''
define_method(name) do
self[name] |... |
FactoryGirl.define do
factory :user do
email { Faker::Internet.email }
username { "user-#{ String.random_token() }" }
password "testing-password"
password_confirmation "testing-password"
display_name { Faker::Name.first_name + ' ' + Faker::Name.last_name }
after(:create) do |object|
obj... |
class Gallery
attr_reader :name, :city
@@all = []
def initialize(name, city)
@name = name
@city = city
@@all << self
end
def paintings
Painting.all.select{|painting| painting.gallery == self}
end
def artists
paintings.map {|painting| painting.artist}
end
def artists_names
... |
class Triangle
def initialize(a,b,c)
@a = a.to_i
@b = b.to_i
@c = c.to_i
end
def triangle?
if (@c < (@a+@b) && @a < (@c+@b) && @b < (@a+@c))
true
else
false
end
end
def equilateral?
if @a == @b && @b == @c && @a == @c
return true
end
false
end
def i... |
module AdminListHelper
STATUS_BOOTSTRAP_MAP = {
Post::STATUS[:killed] => "list-status label label-important",
Post::STATUS[:draft] => "list-status label",
Post::STATUS[:pending] => "list-status label label-warning",
Post::STATUS[:published] => "list-status label label-success"
}... |
print "Give me a number: "
number = gets.chomp.to_i #after gets input,then converted string value to integer using to_i
bigger = number * 100
puts "A bigger number is #{bigger}"
print "Give me another number: "
another = gets.chomp
number = another.to_i
smaller = number / 100
puts "A smaller number is... |
class AddApproveStatusAndPaidTimeToTimeslot < ActiveRecord::Migration[5.1]
def change
add_column :timeslots, :approve_status, :integer
add_column :timeslots, :paid_time, :datetime
#aproveStatus
#0 = waiting
#2 = rejected
#1 = approved
end
end
|
class CollectionsController < ApplicationController
before_filter :authenticate_user!, only: [:edit, :update, :destroy, :follow, :unfollow]
before_action :set_collection, only: [:show, :edit, :update, :destroy, :follow, :unfollow, :like, :unlike]
def follow
if request.xhr?
current_user.follow!(@collec... |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... |
require 'rails_helper'
RSpec.describe "the projects enpoints #delete", :type => :request do
context "when not logged in" do
it "returns 401 when tring to update a project" do
project = Project.create(title: "Post Test", description: "description")
delete "/projects/#{project.id}"
expect(response.status... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.