text stringlengths 10 2.61M |
|---|
require 'rails_helper'
RSpec.describe Category, type: :model do
describe "カテゴリ登録テスト" do
let!(:user) { create(:user) }
let!(:item) { create(:item) }
let!(:category) { create(:category) }
context "カテゴリ作成" do
it "カテゴリ名が正しく入力されていること" do
expect(category).to be_valid
end
end
end
... |
require 'spec_helper'
describe SpecialtyList do
it { should belong_to(:user) }
describe '#add_keyword' do
before :each do
@list = FactoryGirl.create(:specialty_list)
@list.add_keyword('wires', 'electronics')
end
it 'should add a single keyword to the proper keyword array' do
@list.e... |
require "test_helper"
class UserScopeTest < ActiveSupport::TestCase
context "Given context" do
setup do
create_organizations
create_users
end
should "list users alphabetically" do
assert_equal [@cindy, @ed, @alex, @kathryn, @sophie, @ben, @chuck, @ralph], User.alphabetical
end
... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Achievement, type: :model do
it 'should validate presence of attributes' do
should validate_presence_of(:name)
should validate_presence_of(:description)
end
it 'validates uniqueness of name' do
should validate_uniqueness_of(:name)
... |
require 'bundler'
require 'rspec'
require 'rspec/core/rake_task'
require 'rspec/autorun'
require 'rcov'
Bundler::GemHelper.install_tasks
namespace(:spec) do
desc "run all specs with rcov"
RSpec::Core::RakeTask.new(:coverage) do |t|
t.pattern = 'spec/**/*_spec.rb'
t.rspec_opts = ["--profile","--format pro... |
require_relative 'db_connection'
require 'active_support/inflector'
# NB: the attr_accessor we wrote in phase 0 is NOT used in the rest
# of this project. It was only a warm up.
class SQLObject
def self.columns
@columns ||= DBConnection.execute2(
"SELECT * FROM #{table_name}"
).first.map(&:to_sym)
en... |
class CreateConceptcodes < ActiveRecord::Migration[5.0]
def change
create_table :conceptcodes do |t|
t.integer :encode
t.string :name
t.timestamps
end
add_index :conceptcodes, :encode, unique: true
end
end
|
Given(/^I (create|delete) the project$/) do |action, table|
assert_equal(true, ProjectHelper.send(action, table.hashes.first))
end
Given(/^The project with the name "([^"]*)" was successfully created$/) do |project_name|
assert_equal(true, ProjectHelper.goto_project(project_name))
end
Given(/^The project "([^"]*)... |
require './lib/ship'
require './lib/cell'
require './lib/board'
require './lib/game'
require 'pry'
require 'colorize'
loop do
puts "\n\n\n\u{1F6A2 1F4A3 1F4A6}WELCOME TO BATTLESHIP\u{1F4A6 1F4A3 1F6A2}".colorize(:light_blue)
puts "Enter p to play. Enter q to quit"
print "> "
answer = gets.chomp.downcase
unt... |
require_relative '../app.rb'
require 'rspec'
require 'rack/test'
require 'sinatra'
# require 'pry'
def is_valid_json?(json)
begin
JSON.parse(json)
return true
rescue Exception
return false
end
end
describe "AppointmentsAPI" do
include Rack::Test::Methods
def app
Sinatra::Application
end
... |
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# 有关 Fiber 的解释: (按照数据流的方向分为两部分)
# 在 `主线程' 中使用 resume 方法来启动(或继续执行)一个 `纤程'.
# 1. 第一次调用 fiber.resume, 会启动一个纤程,
# 如果 resume 调用时提供了实参, 会作为代码块形参传入代码块.
# 2. 如果非第一次调用 fiber.resume, 即, `恢复' 一个纤程, 会做两件事:
# - 从上次离开纤程的那个位置(调用 Fiber.yield 离开纤程的那个位置), 恢复纤程的执行.
# - 如果 resume 调用时提... |
class AddPriceColumnToPropertyOwnerTable < ActiveRecord::Migration
def change
add_column :property_posts, :price, :float
end
end
|
module ApplicationHelper
def login_helper style = ""
if !current_user.is_a?(GuestUser)
link_to "Logout", destroy_user_session_path, method: :delete, class: style
else
(link_to "Login", new_user_session_path, class: style)+" "+
(link_to "Register", new_user_registration_path, class: style)
... |
class User < ApplicationRecord
include Resonatable
authenticates_with_sorcery!
has_many :posts
has_many :comments
validates :password, confirmation: true, length: { minimum: 8 },
if: -> { new_record? || changes[:crypted_password] }
validates :password_confirmation, presence: true,
... |
class RenameImageColumnToRooms < ActiveRecord::Migration[6.0]
def change
rename_column :rooms, :image, :room_image
rename_column :users, :image, :user_image
end
end
|
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'estimates#show'
get 'estimates/:brand/', to: 'estimates#get'
end
|
class VirtualPresent < ActiveRecord::Base
NAMES = Settings.virtual_presents.names
validates :title, presence: true
validates :name, inclusion: { in: NAMES }
validates :name, uniqueness: true
validates :price, numericality: { greater__than_or_equal_to: 0 }
validates :value, numericality: { greater__than_or... |
class League < ActiveRecord::Base
include Auditable
attr_accessible :name, :to_year, :from_year, :games_attributes, :organization_id, :supports_games, :calc_points,
:teamstats_attributes, :leaguezones_attributes,
:show_map, :coordinate_lat, :coordinate_long, :zoom_level
has_ma... |
class BadgeService
def initialize(test_passage)
@test_passage = test_passage
@user = @test_passage.user
@test = @test_passage.test
end
def call
Badge.find_each do |badge|
method = "#{badge.rule}?"
add_badge!(badge) if respond_to?(method, true) && send(method, badge.rule_option)
en... |
class WordsController < ApplicationController
authorize_resource
before_action :find_word, only: [:show, :edit, :update, :destroy]
def index
@words = current_user.words.by_category(current_category).all
end
def show
end
def new
@word = Word.new
end
def create
@word = current_user.word... |
require 'rspec'
require 'player'
require 'deck'
require 'game'
describe "Game" do
let(:player_one) { double("player_one") }
let(:player_two) { double("player_two") }
let(:player_three) { double("player_three") }
subject(:game) { Game.new([player_one, player_two, player_three]) }
describe "#initializ... |
Pod::Spec.new do |s|
s.name = "Test"
s.version = "0.0.1-beta.1"
s.summary = "示例之 原生Test模块"
s.homepage = "https://github.com/axe-org/demo-test"
s.license = { :type => "MIT"}
s.author = { "luoxianmin... |
class AddAttachmentsBrochureToBrochure < ActiveRecord::Migration
def self.up
add_column :brochures, :brochure_file_name, :string
add_column :brochures, :brochure_content_type, :string
add_column :brochures, :brochure_file_size, :integer
add_column :brochures, :brochure_updated_at, :datetime
end
d... |
require_relative 'friend'
require 'minitest/unit'
require 'minitest/autorun'
class TestFriend < MiniTest::Unit::TestCase
def test_fullname
friend = Friend.new "martin", "Fowler"
assert_equal "FOWLER, Martin", friend.fullname
end
end
|
class CategoriesController < ApplicationController
before_filter :authenticate_user!
before_filter :is_admin
def index
if params[:id].blank? || params[:id].nil?
if current_user.is_super_admin?
@categories=Category.where(:deleted => false).order.page(params[:page]).per(10)
else
@ca... |
module Users
class User < ActiveRecord::Base
attr_accessible :real_name
has_one :credit_account
has_many :accounts, as: :account_owner, dependent: :destroy
end
end |
class User < ActiveRecord::Base
has_secure_password
validates_presence_of :name, :email, :password
validates_uniqueness_of :email
validates_format_of :email,:with => /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
has_many :activities
has_many :comments
def slug
self.name.downcase.gsub(" ","-")
end
def self.f... |
#
# Copyright 2011-2013, Dell
# Copyright 2013-2014, SUSE LINUX Products GmbH
#
# 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 requi... |
FactoryBot.define do
factory :user do
name {"Taro"}
sequence(:email) {Faker::Internet.email}
password {"00000000"}
password_confirmation {"00000000"}
lastname {"山田"}
firstname {"太郎"}
lastname_kana {"ヤマダ"}
firstname_kan... |
require "sinatra"
require "sinatra/reloader" if development?
require "sinatra/content_for"
require "tilt/erubis"
require 'pry'
configure do
enable :sessions
set :session_secret, 'secret'
end
before do
session[:lists] ||= []
session[:list_counter] ||= 0
end
helpers do
def checkable(list)
"complete" if ... |
class Workbench::JobLogsController < ApplicationController
include ExtJS::Controller
def index
page = get_page(Job)
data = JobLog.paginate :page => page, :order => 'id desc'
results = JobLog.count
render :json => {:results => results, :data => data.map{|row|row.to_record}}
end
end |
class UsersController < ApplicationController
load_and_authorize_resource
def show
@albums = @user.albums
end
end
|
module Enumerable
def my_each
i = 0
while i < self.length
yield self[i]
i += 1
end
self
end
def my_each_with_index
i = 0
while i < self.length
yield i,self[i]
i += 1
end
self
end
def my_select
arr = Array.new
self.my_each do |i|
return arr << i if yield i
end
self
end
d... |
module Yito
module Model
module Booking
#
# Holds the booking configuration
#
class BookingConfiguration
end
end
end
end
|
# Validating a phone number
class PhoneNumber
def initialize(phone_number)
@phone_number = phone_number
end
def number
return '0000000000' unless /[a-zA-Z]/.match(@phone_number).nil?
cleaned_number = @phone_number.gsub(/[^0-9]/, '')
number_size = cleaned_number.size
return '0000000000' if nu... |
cask :v1 => 'vistrails' do
version '2.1.1'
sha256 '38ac9da9af7a557cee6eb703517e38ea1bcc430706a436a182eec6f976275b02'
url "http://downloads.sourceforge.net/project/vistrails/vistrails/v#{version}/vistrails-mac-10.6-intel-#{version}-90975fc00211.dmg"
name 'VisTrails'
homepage 'http://www.vistrails.org/'
lice... |
class Networks::FormDataSerializer < ApplicationSerializer
object_as :network
attributes(
:name,
:address,
:vlan_id,
:notes,
)
type :string
def gateway
network.gateway.to_s
end
type :string
def dhcp_start
network&.dhcp_start&.to_s
end
type :string
def dhcp_end
netwo... |
class EventsController < ApplicationController
before_action :set_event, only: [:show, :edit, :update, :destroy]
before_action :admin? , only: [:new, :edit, :create, :update, :destroy]
before_action :authenticate_user!, only: [:index, :new, :create, :show, :edit, :update, :destroy]
def index
@events = Even... |
#!/usr/bin/env ruby
#Create a class
class PokerHand
attr_accessor :content
#Initializes an object and assings the entry list to var @content
def initialize(content)
@content = content
end
#Orders PokerHand content by sorting it and creating a whole string
def orderAndSortHand
... |
class UsersController < ApplicationController
load_and_authorize_resource
layout 'aquila'
def edit
end
def update
if @user.update_attributes(params[:user])
redirect_to challenges_path, notice: t('flash.users.updated')
else
render :edit
end
end
def define_role
@user = current... |
# Copyright (c) 2009-2012 VMware, Inc.
require "mysql2"
require "timeout"
module Mysql2
class Client
class << self
attr_accessor :default_timeout
attr_accessor :logger
end
alias :origin_initialize :initialize
alias :origin_query :query
def initialize(opts={})
wait_timeout = se... |
require 'net/http'
module Usecase
class DownloadAttachment
class ClientError < StandardError; end
def initialize(identifier:)
@identifier = identifier
end
def call
result = HTTParty.get(uri)
return result.body if result.success?
raise ClientError, result
end
priva... |
class ChangeLightningThumbs < ActiveRecord::Migration
def change
remove_column :lightning, :thumbsup
add_column :lightningdata, :thumbsup, :boolean
end
end
|
require "spec_helper"
describe PostsController do
describe "routing" do
it "routes to #index" do
get("/posts").should route_to("posts#index")
end
it "routes to #new" do
get("/posts/new").should route_to("posts#new")
end
it "routes to #show" do
get("/posts/1").should route_to(... |
class AddPwintyReferenceToOrders < ActiveRecord::Migration[6.0]
def change
add_column :orders, :pwinty_reference, :integer, index: true
end
end
|
class CreateFreezerLocations < ActiveRecord::Migration
def change
create_table :freezer_locations do |t|
t.references :sample, index: true
t.string :plate_barcode
t.string :plate_name
t.string :plate_type
t.string :process_step
t.string :box_type
t.string :box
t.str... |
class Admin::UploadsController < ApplicationController
layout 'admin'
before_filter :login_required
# GET /admin/blogs/1/uploads
# GET /admin/blogs/1/uploads.xml
# GET /admin/blogs/1/users/1/uploads
# GET /admin/blogs/1/users/1/uploads.xml
def index
@upload = Upload.new
@blog = Blog.find(params... |
control "M-1.9" do
title "1.9 Ensure auditing is configured for Docker files and directories
docker.socket (Scored)"
desc "
Audit docker.socket, if applicable.
Apart from auditing your regular Linux file system and system calls, audit
all Docker
related files and directories. Docker daemon runs with ro... |
require 'player'
describe Player do
let(:player) { Player.new('Grzegorz') }
it 'has a player' do
expect(player).to be_instance_of(Player)
end
it 'creates a player with 0 points' do
expect(player.points).to eq(0)
end
it 'creates a player with a name' do
expect(player... |
class User < ApplicationRecord
EMAIL_FORMAT = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
PASSWORD_FORMAT = /\A[a-zA-Z0-9_-]{9,}\Z/
has_many :user_rooms
has_many :rooms, through: :user_rooms
has_many :msgs
has_many :unread_msgs
attr_accessor :session_id
validates :name, presence: true
validates :... |
class Product
attr_accessor :sku
attr_accessor :price
attr_accessor :name
def initialize(name,sku,price)
@name = name
@sku = sku
@price = price
end
end
|
# frozen_string_literal: true
# == Schema Information
#
# Table name: ad_media # 広告媒体マスターテーブル
#
# id :bigint not null, primary key
# name(媒体名) :string not null
# created_at :datetime not null
# updated_at :datetime not null
# company_id(企業I... |
module Avocado
class Middleware::ResourceSerialization
def call(package)
request = package.request
name = infer_resource_name_from_request(request)
Avocado::RequestStore.instance.json.merge! resource: { name: name }
yield
end
private
def infer_resource_name_from_request(re... |
InertiaRails.configure do |config|
config.version = '1.0'
end |
ActiveAdmin.register Asset do
permit_params :bar_code, :serial_number, :asset_type_id, :location_id, :brand_id, :status, :user_id, :project_id, :description
controller do
def scoped_collection
super.includes(:location, :brand, :project, :user)
end
end
form do |f|
f.inputs 'Details' do
... |
class Country < ActiveRecord::Base
has_many :drink_country_mappings
has_many :drinks, :through => :drink_country_mappings
end
|
require 'border_patrol'
module InOrOut
class Group
def self.label_records records, polygons, latitude_column, longitude_column
output = []
records.each do |record|
group_found = false
point = BorderPatrol::Point.new(record[longitude_column].to_f, record[latitude_column].to_f)
... |
class Timer
#write your code here
attr_accessor :seconds
def initialize
@seconds = 0
end
def time_string
seconds = @seconds
seconds_r = seconds % 60
minutes = (seconds % 3600) / 60
hours = (@seconds/3600)
timer = "#{padded(hours... |
class PlacesController < ApplicationController
def index
end
def search
@places = BeermappingApi.places_in(params[:city])
if @places.empty?
redirect_to places_path, notice: "No locations in #{params[:city]}"
else
raise "APIX_APIKEY env variable not defined" if ENV['APIX_APIKEY'].nil?
... |
ActiveAdmin.register Question do
permit_params :body, :sender_id, :recipient_id, :response
filter :sender_id
filter :recipient_id
index do
selectable_column
id_column
column :sender_id
column :recipient_id
column :body do |question|
truncate(question.body, length: 80)
end
... |
class CreateElementExperiments < ActiveRecord::Migration
def change
create_table :element_experiments do |t|
t.references :element
t.references :experiment
t.timestamps
end
add_index :element_experiments, :element_id
add_index :element_experiments, :experiment_id
end
end
|
class CreateTeams < ActiveRecord::Migration
def change
create_table :teams do |t|
t.string :name, null: false
t.boolean :striped_shirt, default: false, null: false
t.integer :total_wins, default: 0, null: false
t.integer :total_losses, default: 0, null: false
t.integer :total_draws, ... |
class Video < ActiveRecord::Base
def self.search(query)
where("keyword like ?", "%#{query}%")
end
end
|
require_relative './rock'
require_relative './paper'
require_relative './scissors'
require_relative './rocket'
module OptionFactory
# VALID_INPUTS = %w(rock paper scissors).freeze
attr_reader :user_choice
ChoiceError = Class.new(StandardError)
CHOICE_MAP = {
rock: Rock,
paper: Paper,
scissors: Sc... |
class Transaction < ApplicationRecord
belongs_to :buyer, class_name: "User", optional: true
belongs_to :seller, class_name: "User", optional: true
belongs_to :gig, optional: true
belongs_to :request, optional: true
enum status: [:approved, :pending, :rejected]
enum transaction_type: [:trans, :w... |
require 'json'
# Expander: traces a given grammar downwards, and builds
# text by including terminal symbols and expanding
# non-terminal symbols. This is purely functional; unlike
# the original Python version it doesn't collect the pieces
# by building up state on a fresh object instance. Instead
# it uses recursion... |
class NotesController < ApplicationController
layout 'note'
load_and_authorize_resource
include Trackable
def index
#@notes = Note.all
@notes = Note.order('created_at desc').all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @notes }
end
end
d... |
# frozen_string_literal: true
module Menu
module MainMenuHelper
def main_menu
content_tag(:ul, safe_join(main_menu_buttons), class: 'simple')
end
private
def main_menu_yaml
return @main_menu_yaml unless @main_menu_yaml.nil?
main_menu_yaml = load_yaml('app/lib/nav/*.yml.erb')
... |
class SupportingCourse < ActiveRecord::Base
include Taggable
include Accessable
include Statusable
include Categorizable
include Searchable
include LibrarySearchable
MAX_SKILLS_COUNT = 5
# Suporte a busca global
searchable_for :title, :tags, :categories_names, if: ->(course) { course.status_publish... |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rails}
s.version = "1.2.6"
s.required_rubygems_version = nil if s.respond_to? :required_rubygems_version=
s.authors = ["David Heinemeier Hansson"]
s.cert_chain = nil
s.date = %q{2007-11-23}
s.default_executable = %q{rails}
s.descripti... |
module TryUntil
# External interface
# Example:
# include TryUntil
# result = Repeatedly.new(Probe.new(Object.new, :to_s))
# .attempts(5)
# .interval(10)
# .delay(10)
# .rescues([ ArgumentError, IOError ])
# .stop_when(lambda { |response| JSON.parse(response.body)['id'] == 'some_id' })
# ... |
class Restaurant < ApplicationRecord
validates :rating, numericality: { less_than_or_equal_to: 5, only_integer: true }
end
|
class PriceCalculator
attr_reader :total_price
def initialize(order)
@total_price = order.order_items
.map { |oi| oi.product }
.map { |p| p.price * (1 + tax_rate(order.address)) + p.weight.kg.to.lb.value * shipping_cost(order.address) }
.redu... |
class LessonClass < ActiveRecord::Base
belongs_to :lesson
belongs_to :class_detail
validates_uniqueness_of :class_detail_id,:scope => [:lesson_id]
end
|
# frozen_string_literal: true
require 'rails_helper'
describe Donut::DuplicateAccessionVerificationService do
subject { service.duplicate_ids }
let(:accession_number) { 'nul:999' }
let(:service) { described_class.new(accession_number) }
context 'when no duplicate accession numbers exist' do... |
class Task < ActiveRecord::Base
attr_accessible :active, :code, :description, :general, :rroute, :sequence, :title
default_scope order: 'sequence, created_at DESC'
translates :title, :description
validates :code, presence: true
validates :title, presence: true
validates :sequence, presence: tr... |
assert_raises(NoExperienceError) {employee.hire}
# alternatively:
assert_raises NoExperienceError do
employee.hire
end
|
class Medicine < ApplicationRecord
has_many :alias_names
has_many :medicine_diseases
has_many :medicine_efficacies
end
|
class AddTipsToItems < ActiveRecord::Migration
def change
add_column :items, :tips, :text
end
end
|
module Sequel::Plugins
class Registrants < Array
alias_method :orig_push, :push
def unique_class_add(v)
return self if !v.is_a?(Class) || self.include?(v)
self.delete_if { |m| m.to_s == v.to_s }
orig_push(v)
end
def <<(v)
unique_class_add(v)
self
end
def... |
actions :create, :delete
default_action :create
attribute :name, :kind_of => String, :name_attribute => true
attribute :network_name, :kind_of => String, :default => '%h'
attribute :owner, :kind_of => String, :default => 'root'
attribute :group, :kind_of => String, :default => 'root'
attribute :mode, :kind_of => Fix... |
require 'rails_helper'
RSpec.feature "Welcomes", type: :feature do
scenario 'Mostra a mensagem de Bem-Vindo' do
visit(root_path)
expect(page).to have_content('Seja Bem-Vindo!!!')
end
scenario 'Verificar o link de cadastro de clientes' do
visit(root_path)
expect(find('ul li')).to have_link('Cadastro ... |
class ProductsController < ApplicationController
before_action :apply_gon
before_action :authenticate_user!, except: [:index, :show]
before_action :set_product, only: [:edit, :show]
before_action :set_parents, only: [:index, :show]
def index
@products_ladies = Product.where(category_id: 1..205).where.not... |
class Agent < ApplicationRecord
validates_presence_of :first_name, :last_name, :last_4ssn, :supervisor
def full_name
"#{first_name} #{last_name}" + " Last 4 SSN -" + "#{last_4ssn}"
end
end |
Embulk::JavaPlugin.register_filter(
"reverse_geocoding", "org.embulk.filter.reverse_geocoding.ReverseGeoCodingFilterPlugin",
File.expand_path('../../../../classpath', __FILE__))
|
require_dependency "service_api/application_controller"
module ServiceApi
class PluginsController < ApplicationController
before_filter :authenticate
before_action :get_plugin_params, only: [:create, :get_versions, :set_versions]
def index
render json: $redis.hgetall('plugin')
end
def create
... |
#!/usr/bin/env ruby
require_relative '../lib/tuple'
Projectile = Struct.new(:position, :velocity)
Environment = Struct.new(:gravity, :wind)
def tick(projectile, environment)
new_position = projectile.position + projectile.velocity
new_velocity = projectile.velocity + environment.gravity + environment.wind
Proje... |
class FeedbacksController < ApplicationController
def new
@feedback = Feedback.new
end
def index
end
def show
@feedback = Feedback.find(params[:id])
end
def create
@feedback = Feedback.new(feedback_params)
respond_to do |format|
format.html {
if @user.save
... |
require 'singleton'
module XMLPipes #:nodoc:
class Configuration
include Singleton
IndexOptions = :docinfo, :mlock,
:morphologies, :min_stemming_len, :stopword_files, :wordform_files,
:exception_files, :min_word_len, :charset_dictpath, :charset_type,
:charset_table, :ignore_character... |
class RecipesController < ApplicationController
before_action :load_recipe, only: :show
def index
@all_recipes = ContentfulService.new.get_recipes
end
def show; end
private
def load_recipe
entry_id = params[:id]
@recipe_data = JSON.parse(ContentfulService.new.get_recipe(entry_id).body)
end... |
class IcseReport < ActiveRecord::Base
belongs_to :batch
belongs_to :exam
belongs_to :student
end
|
require 'rails_helper'
RSpec.feature 'Ordering devices within a virtual pool', skip: 'Disabled for 30 Jun 2021 service closure' do
let(:responsible_body) { create(:trust, :manages_centrally) }
let(:schools) { create_list(:school, 4, :with_preorder_information, :with_headteacher_contact, :with_std_device_allocation... |
# encoding: UTF-8
class SongResult
attr_accessor :id, :title, :link
def initialize(id, title, link)
@id = id
@title = title
@link = link
end
def to_json(*a)
{ 'id' => id, 'title' => title, 'link' => link }.to_json(*a)
end
end |
module V1
class TravelDestinationsController < ApplicationController
before_action :set_travel_destination, only: %i[detail_travel_destination]
skip_before_action :authenticate_request
def featured_destinations
@search = TravelDestination.limit(4).ransack(params[:q])
@travel_dest... |
require './lib/simulate_helper'
if ARGV.empty?
puts "Needs arguments"
puts "simulate.rb SPORT YEAR PERIODS(/ALL) (VERBOSE)"
exit
end
values = CLI.new
values.add_arg("sport", ARGV[0])
values.add_arg("year", ARGV[1].to_i)
values.add_arg("periods", ARGV[2])
values.change_arg("periods", values.args["periods"].to_... |
# Assignment operator
# Operador de Atribuição
name = "Ozzy Osbourne"
# Methods
# 1 ) Como se chama?
# 2 ) Quais são os parâmetros
# que o método recebe?
# Quais são os tipos esperados?
# 3 ) O quê o método retorna?
def full_name(first_name, last_name)
# I expect them to be strings
"#{first_name} #{last_n... |
require 'test_helper'
class NewGetCardsControllerTest < ActionDispatch::IntegrationTest
setup do
@new_get_card = new_get_cards(:one)
end
test "should get index" do
get new_get_cards_url
assert_response :success
end
test "should get new" do
get new_new_get_card_url
assert_response :succe... |
module RFPDF
COLOR_PALETTE = {
:black => [0x00, 0x00, 0x00],
:white => [0xff, 0xff, 0xff],
}.freeze
# Draw a circle at (<tt>mid_x, mid_y</tt>) with <tt>radius</tt>.
#
# Options are:
# * <tt>:border</tt> - Draw a border, 0 = no, 1 = yes? Default value is <tt>1</tt>.
# * <tt>:border_color</tt>... |
class Contact
@@counter = 0
attr_accessor :notes, :name, :id
def initialize
@id = Contact.get_id
end
def to_s
"ID: #{@id} Name: #{@name}\nNotes:#{@notes}"
end
def self.get_id
@@counter += 1
@@counter
end
end
|
class CreateDesembolsos < ActiveRecord::Migration
def change
create_table :desembolsos do |t|
t.integer :estado
t.date :fecha_solicitud
t.float :valor
t.float :girado
t.date :fecha_giro
t.text :condiciones
t.belongs_to :proyecto, index: true
t.timestamps
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.