text stringlengths 10 2.61M |
|---|
class NewWorkoutCell < UICollectionViewCell
attr_reader :reused
attr_accessor :custom_delegate
def rmq_build
rmq(self).apply_style :new_workout_cell
q = rmq(self.contentView)
self.contentView.styleClass = 'new_workout_cell'
@exercise_label = q.append(UILabel, :exercise_label).get
end
def ... |
require 'soar_customer'
require 'jsender'
require 'lib/web/support/logging'
require_relative 'model_factory'
module SoarSc
module Web
module Models
class Customer
include Jsender
attr_reader :configuration
attr_accessor :data_provider
class SoarCustomerDaasError < StandardE... |
require 'test_helper'
class KeywordTest < ActiveSupport::TestCase
setup do
@keyword = keywords(:keyword1)
@amazon = YAML.load(open('test/fixtures/amazon.txt').read)
@rakuten_books = YAML.load(open('test/fixtures/rakuten_books.txt').read)
@product = products(:keyword_search1)
Product.all.each(&:... |
require 'test_helper'
class ArrayTest < ActiveSupport::TestCase
context '#to_xml method' do
setup do
@version = Gem::Version.new(RUBY_VERSION)
@ruby_24 = Gem::Version.new('2.4.0')
end
should 'not add the attr params as default' do
xml = Nokogiri::XML::Document.parse([1,2].to_xml)
... |
require_relative 'linked_list'
def create_new_list
#tests creating a new list
list = LinkedList.new()
end
def test_push
#test pushing nodes onto list
list = LinkedList.new()
list.push("Mask")
list.push("Majora's")
list.push("Zelda")
list.push("Legend")
list.push("The")
puts list.to_s
unless li... |
module LayoutHelper
def title
title = ''
title << "#@title - " if @title
title << @cobrand.name if @cobrand
title << " (#{Rails.env.last(3).upcase})" unless production?
title
end
def body_class
classes = [page_type]
classes << 'ros' if... |
# frozen_string_literal: true
require 'rake/testtask'
require 'fileutils'
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
t.test_files = FileList['test/*_test.rb']
t.verbose = true
t.warning = false
end
desc Rake::Task['test'].comment
task :default => :test
|
#GET request
get '/sample-44-how-to-assemble-document-and-add-multiple-signatures-and-signers-to-a-document' do
haml :sample44
end
#POST request
post '/sample-44-how-to-assemble-document-and-add-multiple-signatures-and-signers-to-a-document' do
#Set variables
set :client_id, params[:clientId]
set :pri... |
class Admin::PollsController < Admin::ResourceController
model_class Poll
def clear_responses
if @poll = Poll.find(params[:id])
@poll.clear_responses
flash[:notice] = t('polls_controller.responses_cleared', :poll => @poll.title)
end
redirect_to :action => :index
end
protected
def ... |
class Batch
def self.generate
new id: Guid.generate,
uri: Uri.generate,
created_at: Time.generate.format,
batch_size: Int.generate,
persisted_batch_size: Int.generate,
account_reference: AccountReference.generate,
created_by: String.generate,
name: String.ge... |
Rails.application.routes.draw do
# homepage ("/") goes to planes controller, index action
root to: "planes#index"
# CRUD routes for planes
resources :planes
# get "/planes", to: "planes#index"
# post "/planes", to: "planes#create"
# get "/planes/new", to: "planes#new"
# get "/planes/:id/edit", to: "p... |
require "yaml"
require "ostruct"
# Public: The node class.
#
# A node which describes the data tree behaviour, and all methods
# to be called on a data node. Node inherits from (OpenStruct)[http://www.ruby-doc.org/stdlib-1.9.3/libdoc/ostruct/rdoc/OpenStruct.html]
# which is part of Ruby standard library. OpenStruct is... |
require 'rails_helper'
RSpec.describe Student, type: :model do
before :each do
Student.create(UIN:'123456789',First_Name:'John',Last_Name:'Smith',Email:'smith@tamu.edu',Phone_Number:'0987654321')
end
it 'Should Create Student Object' do
expect(:index).to eq(:index)
end
end
|
module RSence
# Namespace for plugin classes and modules
module Plugins
end
end
# Contains the PluginBase module which has common methods for the bundle classes
require 'rsence/plugins/plugin_base'
# guiparser.rb contains the Yaml serializer for gui trees.
# It uses JSONRenderer on the client to build user ... |
require_relative "../base"
describe SfnParameters::Safe::Ssl do
let(:key) { "TEST_KEY" }
let(:salt) { "TEST_SALT" }
let(:subject) { described_class.new(key: key, salt: salt) }
it "should have key set" do
expect(subject.arguments[:key]).to eq(key)
end
it "should have salt set" do
expect(subject.ar... |
class SendUserActivityAlertsJob < ApplicationJob
def perform(user_con_profile, event)
SendUserActivityAlertsService.new(
user_con_profile: user_con_profile,
event: event
).call!
end
end
|
require "selenium-webdriver"
require "test/unit"
class Collection_Share_Class < Test::Unit::TestCase
def setup
@driver = Selenium::WebDriver.for :chrome
@driver.get('https://noteswsd2021.herokuapp.com/')
@driver.manage.window.maximize
end
def test_collection
@driver.find_elemen... |
module Decoder
class Country
include ::CommonMethods
attr_accessor :code, :name
def initialize(args)
self.code = args[:code].to_s
self.name = args[:name]
self.states = Decoder.locale[Decoder.i18n][self.code][:states]
end
def states
@states
end
def states=(_st... |
# coding: utf-8
require 'nokogiri'
require 'mechanize'
require 'logger'
module GradeAPI
@@login_uri = "https://innsida.ntnu.no/sso/?target=KarstatProd"
@@report_path = "/karstat/makeReport.do"
@@report_uri = "http://www.ntnu.no#{@@report_path}"
@@agent = Mechanize.new
@@lang_map = [
:candidates,
... |
# frozen_string_literal: true
module ActiveRecord
class SchemaMigration < ActiveRecord::Base # :nodoc:
class << self
def table_exists?
connection.table_exists?(table_name)
end
end
end
end
|
class AddExchangeRateDateRangeConstraint < ActiveRecord::Migration
def up
execute <<-eos
CREATE FUNCTION unique_exchange_rate_date_range(record_id integer,
new_anchor text,
new_float text,
... |
class SongsController < ApplicationController
before_filter :is_admin, :except => [:index, :show]
respond_to :html, :json
def new
@song = Song.new
respond_with @song
end
def create
@song = Song.new(params[:song])
if @song.save
respond_with @song
else
redirect_to new_song_pa... |
# frozen_string_literal: true
class GroupInstructorsController < ApplicationController
before_action :admin_required
def index
group_instructors = GroupInstructor
.includes(group_semester: :semester, group_schedule: :group)
.order('group_schedules.weekday, group_schedules.start_at, groups.from... |
class ViewedCallsMutation < Types::BaseMutation
description "Marks all calls as viewed"
argument :contact_id, ID, required: false
field :success, Boolean, null: true
policy ApplicationPolicy, :logged_in?
def resolve
calls = if input.contact_id
Call.for_contact(contact)
else
Call
en... |
class AddIpToPoints < ActiveRecord::Migration[5.2]
def change
add_column :points, :ip, :string
add_column :points, :subnet_mask, :string
add_column :points, :dns1, :string
add_column :points, :dns2, :string
end
end
|
class RenameAverageDriverLengthToAverageDriveLengthInStatistics < ActiveRecord::Migration
def change
rename_column :statistics, :average_driver_length, :average_drive_length
end
end
|
# frozen_string_literal: true
require 'yaml'
require_relative 'station'
class RailroadMenu
attr_reader :action_menu, :exit_index
def initialize
@action_menu = parse_menu_from_file('menu.yml')
@exit_index = nil
end
def print_menu
puts 'Выберите действие:'
action_menu.each_with_index do |item,... |
# frozen_string_literal: true
module Api
module V1
class SessionsController < ApplicationController
def create
user = User.find_by(email: params[:email])
if user&.valid_password?(params[:password])
@current_user = user
token = generate_token
s = Session.create(... |
require 'spec_helper'
require 'support/test_classes'
describe 'enumerable syntax' do
let(:mapper) { Perpetuity[Article] }
let(:current_time) { Time.now }
let(:foo) { Article.new("Foo #{Time.now.to_f}", '', nil, current_time - 60) }
let(:bar) { Article.new("Bar #{Time.now.to_f}", '', nil, current_time + 60) }
... |
require 'minitest/autorun'
require 'modelstack'
class ModelStackTest < Minitest::Test
def test_version
assert_equal "0.0.0",
ModelStack::VERSION
end
end |
class CreateDownloadData < ActiveRecord::Migration
def change
create_table :download_data do |t|
t.date :date
t.integer :audio_file_id
t.integer :downloaded
t.integer :hits
t.timestamps
end
end
end
|
# ActiveAdmin.register Product do
# # scope :unreleased
# index do
# column :name
# column :description
# column :title
# column :stock
# column :image
# column :user
# column :category
# column "Release Date", :released_at
# column :price, :sortable => :price do |product|
# ... |
RSpec.describe "shared/activities/_tab_nav_item" do
subject do
render partial: "shared/activities/tab_nav_item", locals: {tab: tab, path: path, "@tab_name": tab_name}
Capybara.string(rendered)
end
let(:path) { "https://example.com" }
describe "controller name matches the current tab" do
let(:tab_n... |
class BrochureSelection < ActiveRecord::Base
belongs_to :brochure
belongs_to :reservation
validates :brochure, presence: true
validates :percent,
presence: true, :if => ->{ self.reservation == true }
# validates_presence_of :brochure
acts_as_paranoid
# Brochure method to include associations with... |
# frozen_string_literal: true
# run a test task
require 'spec_helper_acceptance'
windows = os[:family] == 'windows'
describe 'linux package task', unless: windows do
describe 'install action' do
it 'installs rsyslog' do
apply_manifest("package { 'rsyslog': ensure => absent, }")
result = run_bolt_ta... |
json.array!(@our_advantages) do |our_advantage|
json.extract! our_advantage, :id, :title, :description
json.url our_advantage_url(our_advantage, format: :json)
end
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../../lib"))
require "zznamezz_test_case"
class TC_R001_01_AN_EXAMPLE_TEST < Test::Unit::TestCase
include ZZnamezzTestCase
def setup
# specify setup parameters
@certificate = :regular # this is the default user for this test
... |
require 'spec_helper'
require 'legion/json'
SimpleCov.command_name 'lib/legion/json'
RSpec.describe Legion::Json do
before(:all) { @json_string = '{"foo":"bar"}' }
it 'has a version number' do
expect(Legion::Json::VERSION).not_to be nil
end
it 'can load a parser for current platform' do
hash = Legio... |
require 'spec_helper'
describe CommentsController do
#Create method test
describe "POST create" do
#create a page before each operation (method call)
before(:each) do
page = FactoryGirl.create(:page)
end
#Testing valid attributes as a params
context "with valid attributes" d... |
class Tshirt < ApplicationRecord
belongs_to :user
validates :name, presence: true
validates :description, presence: true, length: { maximum: 150 }
validates :photo, presence: true
monetize :price_cents
belongs_to :user
has_many :items
mount_uploader :photo, PhotoUploader
def self.tagsArray(limit)
... |
class CreateHospitalsProcedures < ActiveRecord::Migration
def change
create_table :hospitals_procedures do |t|
t.integer :drg_id
t.string :drg_def
t.integer :provider_id
t.string :provider_name
t.integer :total_discharges
t.float :avg_covered_charges
t.float ... |
require 'spec_helper'
describe "project_files/new" do
before(:each) do
assign(:project_file, stub_model(ProjectFile,
:project => nil,
:url => "MyString",
:data => ""
).as_new_record)
end
it "renders new project_file form" do
render
# Run the generator again with the --webrat f... |
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'users#new'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions... |
class Candy
attr_accessor :candy
def initialize(candy)
@candy = candy
end
def type
candy
end
end
|
# frozen_string_literal: true
class CalculatorService < Calculator::Calculator::Service
def unary_operation(service_request, _call)
@received_metadata = _call.metadata
case service_request.operand
when '+'
result = service_request.x * 1
when '-'
result = service_request.x * -1
... |
class Airport < ApplicationRecord
has_many :airport_flights
has_many :flights, through: :airport_flights
end
|
module Libis
module Workflow
VERSION = '2.1.10' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
end
end
|
class Doctor::SessionsController < ApplicationController
layout "empty"
before_action :require_doctor_signin, :only => :destroy
skip_before_filter :session_expiry
skip_before_filter :update_activity_time
def new
if doctor_signed_in?
redirect_to '/doctor/dashboard'
end
end
def create
@d... |
class Message < ApplicationRecord
belongs_to :conversation
belongs_to :user
validates_presence_of :body, :conversation_id, :user_id
validates :body, :length => { :maximum => 1000, :minimum => 1 }
def convo_time
created_at.strftime("%d/%m/%y at %l:%M %p")
end
def message_time
... |
class UserMailer < ApplicationMailer
def user_created(user)
@user = user
@url = new_user_session_url
@title = "Thanks for joining aepi.org.au, #{@user.first_name}"
mail(to: @user.email, subject: @title)
end
def user_created_admin_notification(user, new_user)
@user = user
@new_user = new... |
module Api
class InvalidToken < StandardError
end
class AccessDenied < StandardError
end
class InvalidParams < StandardError
end
end |
require "rails_helper"
feature "Account Creation" do
scenario "allow acsess to Log in page" do
visit new_user_session_path
Capybara.ignore_hidden_elements=false
expect(page).to have_content 'login form anchor for capybara'
Capybara.ignore_hidden_elements=true
end
scenario "allow acsess to Regis... |
require 'active_support/concern'
module ApiPresenter
module Concerns
module Presentable
extend ActiveSupport::Concern
private
# Instantiates presenter for the given relation, array of records, or single record
#
# @example Request with included records
# GET /api/posts?inc... |
class AddIndexOnMachineIdToSearsRegistrations < ActiveRecord::Migration
def self.up
add_index :sears_registrations, :machine_id
end
def self.down
drop_index :sears_registrations, :machine_id
end
end
|
require 'spec_helper'
feature 'Viewing a workshop page' do
let(:workshop) { Fabricate(:sessions) }
let(:member) { Fabricate(:member) }
scenario "A logged-out user can view an event" do
visit workshop_path workshop
expect(page).to be
end
scenario "A logged-in user can view an event" do
login m... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Photo do
let(:photo_object) { photo }
let(:subject) { described_class.new(photo_object) }
it 'should create a photo object' do
expect(subject).to be_kind_of(Photo)
end
it 'should have an id attribute' do
expect(subject.id).to be_t... |
class StudentRecord < ApplicationRecord
belongs_to :student
validates :student_id, presence: true, uniqueness: true
validates :student_number, presence: true, uniqueness: true
def self.params_errors(params)
params_errors = {}
student_number = params[:student_number]
if student_number.empty?
p... |
#!/usr/bin/ruby
# Calendar
version = "1.0.0" # 2016-02-10
#
# This script outputs a monthly calendar.
# It's very configurable, and can produce CSS-ready HTML output, as well
# as the more conventional monospaced calendar for the command-line.
#
# Made by Matt Gemmell - mattgemmell.com - @mattgemmell
#
github_url = "... |
$:.unshift File.expand_path("../lib", __FILE__)
require "mengpaneel/version"
Gem::Specification.new do |spec|
spec.name = "mengpaneel"
spec.version = Mengpaneel::VERSION
spec.author = "Douwe Maan"
spec.email = "douwe@selenight.nl"
spec.summary = "Mengpaneel makes Mixpanel ... |
class Fabric < ActiveRecord::Base
attr_accessible :color, :price, :quantity, :serial, :meters_sold, :rolls_sold, :total_profit
has_many :records
def self.repeated_serial?(serial_num)
return !Fabric.where("serial=?", serial_num).blank?
end
def add_new_record(data_hash)
# Get the date and use it to cr... |
Pakyow::App.bindings do
scope :link do
restful :link
# TODO https://github.com/iamvery/pinster-pakyow/pull/7#issuecomment-197944275
binding :url do
{
href: bindable[:url],
content: bindable[:url],
}
end
end
end
|
#
# Cookbook Name:: hadoop_wrapper
# Recipe:: default
#
# Copyright © 2013-2016 Cask Data, 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... |
class HappyHour < ActiveRecord::Base
has_many :bargains, dependent: :destroy
belongs_to :location
attr_accessible :days, :end_time, :name, :start_time, :version, :record_number, :same_bargains
scope :open_today, -> { where("days like '%#{self.todays_letter}%'") }
def show_bargains
if same_bargains
... |
require 'rails_helper'
feature "user signs out" do
before(:each) do
@user = FactoryBot.create(:user)
sign_in @user
visit root_path
click_on "sign out"
end
scenario "they see a flash message" do
expect(page).to have_content("Signed out successfully")
end
scenario "they don't appea... |
require 'uniform_notifier/base'
require 'mysql2'
class UniformNotifier
class Mysql < Base
@config = nil
class << self
def active?
@config && mysql_client
end
def setup_connection(config = {})
@config = config
create_table
end
protected
# Bullet ... |
require 'kfsdb'
require 'csv'
require 'json'
Org = Struct.new(:chart, :org, :name, :type)
OrgKey = Struct.new(:chart, :org)
class OrgFinder
def initialize
@parents = {}
@orgs = {}
end
def find_campus(chart, org, con)
end
def find_school(chart, org, con)
end
private
def find_parent(chart, org, con)... |
require 'test_helper'
class MatchesControllerTest < ActionDispatch::IntegrationTest
setup do
@match = matches(:one)
end
test "should get index" do
get matches_url, as: :json
assert_response :success
end
test "should create match" do
assert_difference('Match.count') do
post matches_url... |
class Gallery < ActiveRecord::Base
attr_accessible :experiment_id, :picture_id, :tool_id
validates :picture_id, presence: true
belongs_to :experiment, class_name: 'Experiment'
belongs_to :tool, class_name: 'Tool'
belongs_to :picture, class_name: 'Picture'
end
|
class CallRoute < ActiveRecord::Base
# https://github.com/rails/strong_parameters
include ActiveModel::ForbiddenAttributesProtection
ROUTING_TABLES = ['prerouting', 'outbound', 'inbound', 'dtmf']
has_many :route_elements, :dependent => :destroy, :order => :position
validates :name,
:presence =>... |
# frozen_string_literal: true
RSpec.describe Ringu do
it "has a version number" do
expect(Ringu::VERSION).not_to be nil
end
end
|
class Deal < Highrise::Deal
include ReadOnlyResource
def self.with_preloaded_deal_data(deals)
deals.tap do |deals|
DealDataPreloader.new(deals).preload
end
end
def self.filter(filter, deals)
filter_method = "#{filter}_filter"
send(filter_method, deals) if respond_to?(filter_method)
end... |
require 'spec_helper'
require 'yt/models/playlist_item'
describe Yt::PlaylistItem, :device_app do
subject(:item) { Yt::PlaylistItem.new id: id, auth: $account }
context 'given an existing playlist item' do
let(:id) { 'UExTV1lrWXpPclBNVDlwSkc1U3Q1RzBXRGFsaFJ6R2tVNC4yQUE2Q0JEMTk4NTM3RTZC' }
it 'returns val... |
class History < ApplicationRecord
has_one :buy
belongs_to :item
belongs_to :user
end
|
class DishesController < ApplicationController
def index
end
def show
@dish = Dish.find params[:id]
end
def new
@restaurant = Restaurant.find params[:restaurant_id]
@dish = Dish.new
respond_to do |format|
format.html { render 'new' }
format.js { render 'new.js.erb' }
end
end
... |
h = {}
puts h.class
h = { :name=> "John", :lastname=> "Doe" }
puts h
# symbols are unique objects and refer to the same object. symbols are mainly used for has keys
#
h = {"name"=> "John"} # another way to assign hash keys and values
|
class Comment < ApplicationRecord
belongs_to :user
belongs_to :product
validates :content, presence: true
validates :content, :length => { :maximum => 1000, :minimum => 1 }
def created_time
created_at.strftime("%m/%d/%y at %l:%M %p")
end
end
|
#
# Copyright 2009 Huygens Instituut for the History of the Netherlands, Den Haag, The Netherlands.
#
# This file is part of New Women Writers.
#
# New Women Writers is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundat... |
# Build a class AnimalSorter that accepts a list of animals on
# initialization.
# Define a to_a method to account for the species in the test suite.
# Return an array that contains two arrays, the first one
# should include the sea creatures, the second, land animals.
# Read the test suite for an example of a neste... |
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
# https://github.com/rails/rails-controller-testing
# Even with the rails-controller-testing gem installed, we need these two lines to enable it
require 'rails-controller-testing'
Rails::Controller::Testing.install
# Need to use .env to shim in the CAS server UR... |
require 'test_helper'
class CrunchAlgorithmsControllerTest < ActionController::TestCase
setup do
@crunch_algorithm = crunch_algorithms(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:crunch_algorithms)
end
test "should get new" do
get :ne... |
# Represents all baskets
class Baskets
attr_reader :rows
def initialize(file)
@rows = []
parse_file(file)
end
private
# Parses the whole file, turning it into sets of item ids
def parse_file(file)
File.readlines(file).each do |line|
parse_line(line)
end
end
# Parses one line, ... |
class Faculty
include DataMapper::Resource
property :id, Serial
property :code, String
property :name, String, :nullable => false
has n, :lectures
def full_name
"#{code} #{name}"
end
# def full_name_with_lectures_count
# "#{full_name} <span>(#{lectures.count})</span>"
# end
end
|
class MovieService
class << self
include ApiClientRequests
def build(movie_json)
body = movie_json.respond_to?(:body) ? movie_json.body : movie_json
if body.is_a? Array
body.map{|movie_json| Movie.new(movie_json)}
else
Movie.new body
end
end
def request_uri(op... |
# encoding: UTF-8
class InvoicesController < ApplicationController
before_filter :check_autentication, only: [:edit, :update, :destroy]
layout 'page'
# GET /invoices
# GET /invoices.json
before_filter :load_users, :only => [:edit, :show, :new]
def index
@kid_id = params[:kid_id]
if current_user... |
class AddForeignKeysToReferenceTables < ActiveRecord::Migration
extend MigrationHelpers
def self.up
foreign_key(:accounts, :user_id, :users)
foreign_key(:product_images, :product_id, :products)
end
def self.down
# none - need the keys
end
end
|
require 'bcrypt'
class User
include DataMapper::Resource
property :id, Serial
property :name, String
property :email, String
property :password_digest, Text
attr_reader :password
attr_accessor :password_confirmation
validates_confirmation_of :password
def password=(password)
@password = password
se... |
# frozen_string_literal: true
require 'faker'
FactoryBot.define do
factory :company do
name { Unique.next! { Faker::Company.name } }
end
factory :project do
name { Unique.next! { Faker::Company.name } }
company
end
factory :user do
end
factory :company_user do
user
company { Compa... |
require 'rails_helper'
describe 'An admin' do
describe 'visiting the dashboard can go to all items for admin' do
before :each do
@admin = create(:user, role: 1)
@item = Item.create(title: 'bike lights', description: 'wonderful led', price: 10, image: 'https://www.elegantthemes.com/blog/wp-content/upl... |
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Mirador viewer', type: :system do
context 'Configure Mirador' do
it 'configures a manifest given an integer value' do
value = 123_456
visit "/mirador/#{value}"
expect(page.html).to match(/const manifest =.*#{value}/)
end
... |
require 'rails_helper'
RSpec.describe Application, type: :model do
describe 'relationships' do
it {should have_many :application_pets}
it {should have_many(:pets).through(:application_pets)}
end
describe 'class methods' do
describe '#search' do
it 'returns partial matches' do
# Partial M... |
require 'models/rover.rb'
class MarsGrid
attr_reader :height, :width, :rovers
def initialize (input)
@coordinates = input.split
@rovers = []
parse_mars_grid
parse_rovers
end
def within_bounds?(x, y)
x >= 0 and x <= @height and
y >= 0 and y <= @width
end
def move_rovers
@rovers... |
Rails.application.routes.draw do
root 'welcome#home'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
get '/auth/facebook/callback', to: 'sessions#create'
post '/logout', to: 'sessions#destroy'
resources :users, only: [:index, :show, :create]
get '/signup', to:'users#new', as: 'new... |
class Access < ActiveRecord::Base
before_create :generate_uuid
validates :request_token,
:presence => true,
:uniqueness => true
validates :request_token_secret,
:presence => true,
:uniqueness => true
validates :user_id,
:presence => true,
... |
# Recipes Controller
class RecipesController < ApplicationController
# Authentication and Authorization hacks
# before_action :authenticate_user!
load_and_authorize_resource
before_action :set_recipe, only: [:show, :edit, :update, :destroy]
# GET /recipes
# GET /recipes.json
def index
@recipes = if ... |
#I received direction for the below soultion from https://stackoverflow.com/questions/35778202/how-can-i-sort-an-array-of-strings-based-on-a-non-standard-alphabet. This was my first exposure to the .tr method and it seems to be something that could be very versatile in future labs.
def alphabetize(arr)
alphatbet = ... |
class Cour < ApplicationRecord
validates :titre, presence: true, length: { in: 4..50 }, uniqueness: true
validates :description, presence: true, length: { in: 4..1000 }
has_many :lecons, dependent: :destroy
validates_associated :lecons
end
|
class ProductSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :brand, :price, :sold_at, :quantity,
:need_to_rebuy, :is_favorite, :dont_rebuy, :category, :image
# has_many :makeup_bags
# has_many :shopping_lists
end
|
Rails.application.routes.draw do
mount Adminpanel::Engine => "/adminpanel"
end
|
# frozen_string_literal: true
require './lib/player.rb'
describe Player do
describe '#name' do
it 'returns name' do
player1 = Player.new('Andrew', 1)
expect(player1.name).to eq "\e[33mAndrew\e[0m"
end
it 'returns name for 2nd player' do
player2 = Player.new('Andrew', 2)
expect(p... |
json.array!(@book_launchers) do |book_launcher|
json.extract! book_launcher, :book_id, :launcher_id
json.url book_launcher_url(book_launcher, format: :json)
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.