text
stringlengths
10
2.61M
# encoding: utf-8 class ConversationsController < ApplicationController before_filter :authenticate_user! # before_filter :get_mailbox, :get_box, :get_actor before_filter :get_mailbox, :get_box before_filter :check_current_subject_in_conversation, :only => [:show, :update, :destroy,:reply] before_filter :mark...
require 'rails_helper' RSpec.describe "announcements/show", type: :view do before(:each) do @announcement = assign(:announcement, Announcement.create!( :name => "Name", :kind => "Kind", :title => "Title", :subtitle => "Subtitle", :column => 2, :lines => 3, :page => 4, ...
class TagExperience < ApplicationRecord belongs_to :tag belongs_to :experience end
module Spree class ReportGenerationService REPORTS = { finance_analysis: [ :payment_method_transactions, :payment_method_transactions_conversion_rate, :sales_performance, :shipping_cost, :sales_tax ...
class Rect def initialize(x, y, w, h) @x1 = x @y1 = y @x2 = x + w @y2 = y + h end def x1 @x1 end def y1 @y1 end def x2 @x2 end def y2 @y2 end def center center_x = (@x1 + @x2) / 2 center_y = (@y1 + @y2) / 2 [center_x.to_i, center_y.to_i] end de...
#Fedena #Copyright 2011 Foradian Technologies Private Limited # #This product includes software developed at #Project Fedena - http://www.projectfedena.org/ # #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 ...
class Car < ApplicationRecord validates :name, :color, presence: true validates :name, :space_uuid, uniqueness: { allow_blank: true } scope :unparked, -> { where space_uuid: nil } def can_park? # TODO: check if there is an available space end def park! # TODO: get an available space, claim it, an...
require_dependency "kanban_board_ui/application_controller" module KanbanBoardUi class AssignmentsController < ApplicationController before_filter :authenticate_user! def update @assignment = KanbanBoard::Assignment.find(params[:id]) authorize! :update, @assignment @project = @assignment.projec...
# -*- mode: ruby -*- # vi: set ft=ruby : Vagrant::Config.run do |config| config.vm.define :web do |web_config| web_config.vm.box = "precise32" web_config.vm.box_url = "http://files.vagrantup.com/precise32.box" web_config.vm.host_name = "lies-i-told-my-kids-playground" web_config.vm....
class TourDataController < ApplicationController before_filter :set_page before_filter :set_tour_data protected def set_page @page = Page.where(:handle => 'tour-data').first end def set_tour_data @tour_data = TourDatum.last(10) end end
shared_examples 'an event decorator' do it 'has a header' do decorator.header.should be end it 'has an enumerable body' do expect(decorator.body).to respond_to(:each) end end
class User < ActiveRecord::Base has_many :meetupsearches has_many :receipients, :through => :meetupsearches has_many :inverse_meetupsearches, :class_name => "meetup_searches", :friend_key => "receipient_id" has_many :inverse_receivers, :through => :inverse_meetupsearches, :source => :user has_many :meetings ha...
require "spec_helper" module SftpListen describe Configuration do let(:config) { SftpListen::Configuration.new } describe "#initialize" do it "sets the default user_name" do expect(config.user_name).to eql("") end it "sets the default password" do expect(config.password).t...
require 'pry' class Api::SectionsController < ApplicationController def index @sections = Section.all render json: @sections end def create # binding.pry @section = Section.new(section_params) if @section.save render json: @section else render json: { errors: @section.error...
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' gem 'bootsnap', '>= 1.1.0', require: false # Use postgresql as the database for Active Record gem 'pg' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0.7' # Use Uglifier as compressor for JavaScri...
require_relative 'regular_movie' module VideoStore class ChildrensMovie < RegularMovie def charge(days_rented) return 1.5 if days_rented <= 3 1.5 + (days_rented - 3) * 1.5 end end end
describe Rallio do describe '.application_id=' do it 'sets @application_id' do Rallio.application_id = 'foobar' expect(Rallio.instance_variable_get(:@application_id)).to eq 'foobar' end end describe '.application_id' do it 'returns the value set via .application_id=' do Rallio.appli...
require_relative 'p05_hash_map' def can_string_be_palindrome?(string) hsh = HashMap.new arr = string.chars arr.each do |el| if hsh[el] hsh[el] += 1 else hsh[el] = 0 end end count = 0 hsh.each do |k, v| if v % 2 == 0 count += 1 end end if count == ...
require 'spec_helper' describe 'Authentication for App API' do it 'disallows connection attempts when no SSL_CLIENT_VERIFY env var is set' do get '/api/app/ping', {}, {} response.status.should eq(401) end it 'disallows connection attempts when the client SSL cert was not verified' do get '/api/app/...
class SchedulerGame class States class Game < CyberarmEngine::GuiState KONAMI_CODE = [ Gosu::KB_UP, Gosu::KB_UP, Gosu::KB_DOWN, Gosu::KB_DOWN, Gosu::KB_LEFT, Gosu::KB_RIGHT, Gosu::KB_LEFT, Gosu::KB_RIGHT, Gosu::KB_B, Gosu::KB_A,...
#NOTE these records are present in the central database #and are used for translating the domain names class Domain include Mongoid::Document field :_id, type: String #domain for lookup field :subdomain end
# encoding: utf-8 # # © Copyright 2013 Hewlett-Packard Development Company, L.P. # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights #...
class Brewery < ApplicationRecord # dependent destroy should destroy logs on brewery distroy has_many :logs , dependent: :destroy has_many :users, through: :logs end
class UserController attr_reader :type def initialize(special_meanings, privileges, user_type_inheritance_inherit_previous) @pipe, @user, @special_meanings = Pipe.new, Main::Users.new, special_meanings identify_from_session @allowed_actions_by_data_object_name_and_condition = {} user_type_inherita...
class Lesson < ActiveRecord::Base belongs_to :learning_day belongs_to :course has_one :home_task, :dependent => :destroy default_scope :order=>"strftime('%H:%M', start_time)" def hometask if self.home_task content = self.home_task.content.gsub("\n","<br/>") else nil end end d...
require_relative '../../../games/8puzzle/board' require 'test/unit' require 'set' class TestBoard < Test::Unit::TestCase UNSOLVABLE_BOARD = { T1: 1, T2: 2, T3: 3, T4: 4, T5: 5, T6: 6, T7: 8, T8: 7, T9: 0 } EASY_GRID = { T1: 1, T2: 2, T3: 3, T4: 0, T5: 4, T6: 6, T7: 7, T8: 5, T9: 8 } ...
require "test_helper" class UseVanityControllerTest < ActionController::TestCase tests UseVanityController def setup super metric :sugar_high new_ab_test :pie_or_cake do metrics :sugar_high alternatives :pie, :cake default :pie end # Class eval this instead of including in t...
class User < ActiveRecord::Base devise :database_authenticatable, :registerable, :validatable has_many :tweets, dependent: :destroy has_many :videos, dependent: :destroy has_many :tracks, dependent: :destroy has_many :matches, dependent: :destroy after_create do validate_twitter_username validate...
class Person < ActiveRecord::Base scope :teenagers, where('age < 20 AND age > 12') scope :by_name, order(:name) end
Vagrant.configure(2) do |config| config.vm.box = "ubuntu/trusty64" config.vm.network "public_network" config.vm.provision "shell", inline: <<-SHELL sudo apt-get update sudo apt-get install -y libffi-dev libssl-dev gconf-service libgconf-2-4 libgtk2.0-0 fonts-liberation libappindicator1 xdg-utils libpango...
class FontInconsolataGForPowerline < Formula head "https://github.com/powerline/fonts.git", branch: "master", only_path: "Inconsolata-g" desc "Inconsolata-g for Powerline" homepage "https://github.com/powerline/fonts/tree/master/Inconsolata-g" def install (share/"fonts").install "Inconsolata-g for Powerline...
class AddCompanyIdToFinding < ActiveRecord::Migration[5.0] def change add_reference :findings, :company, foreign_key: true end end
# == Schema Information # # Table name: countries # # id :integer not null, primary key # name :string(255) default(""), not null # created_at :datetime not null # updated_at :datetime not null # class Country < ActiveRecord::Base has_many :brigades, dependent: :destro...
require 'rails_helper' RSpec.describe Book, :category, :type => :model do subject(:category) { create :category } context 'association' do it { should have_many :books } end context 'validation' do it { should validate_presence_of(:name) } it { should validate_length_of(:name).is_at_most(50) ...
class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable validates :first_name, presence: true, uniqueness: { sc...
Given(/^I am not logged in$/) do visit logout_path end # ERROR MESSAGE Then /^creation should fail with "(.*)"$/ do |msg| steps %Q{ Then I should see "#{msg}" } end Given(/^I am logged in on the "([^"]*) page$/) do |arg| visit "/org" click_link "Log in with GitHub" visit "/org" end Then /^the field "(....
# # Cookbook:: sturdy_ssm_agent # Recipe:: install # # Copyright:: 2017, Sturdy Networks # Copyright:: 2017, Jonathan Serafini # # 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://w...
class CreateTutorialWidget < ::RailsConnector::Migration def up create_obj_class( name: 'TutorialWidget', type: 'publication', title: 'Tutorial widget', attributes: [ {name: 'headline', type: 'string', title: 'Headline'}, {name: 'content', type: 'html', title: 'Content'}, ...
class Imovel < ApplicationRecord belongs_to :proprietario belongs_to :finalidade has_many :categorias end
class AddHotitemToSearch < ActiveRecord::Migration def self.up add_column :searches, :hotitem_id, :string end def self.down remove_column :searches, :hotitem_id end end
module Kata module Algorithms def self.find_non_existing_smallest_integer_number(array) return 1 if array.empty? # expected worst-case time complexity is O(N); # expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments). exi...
# Handles creating new sessions (loging in) and destroying sessions (logging out) class SessionsController < ApplicationController def create user = User.authenticate(params[:email], params[:password]); if user session[:user_id] = user.id redirect_to dashboard_path else flash.now[:alert] = 'Could not...
class AddUrgencyToGsa18fProcurement < ActiveRecord::Migration def change add_column :gsa18f_procurements, :urgency, :string end end
require 'rails_helper' RSpec.describe RoleCheck do context "Verify App Modules & Permission Constants" do it "Constants Permission should exists" do expect(CAN_READ).to eq 1 expect(CAN_UPDATE).to eq 2 expect(CAN_CREATE).to eq 4 expect(CAN_DELETE).to eq 8 end it "Constatns AppModu...
class TokenSerializer < ApplicationSerializer delegate :token, to: :object set_id :token end
require 'rubygems' require 'bundler' Bundler.setup $:.unshift(File.join(File.dirname(__FILE__), '../../lib/client/lib')) $:.unshift(File.dirname(__FILE__)) require 'mysql_helper' require 'json/pure' require 'singleton' require 'spec' require 'vmc_base' require 'curb' require 'pp' # The integration test automation ba...
class Timelog < ApplicationRecord belongs_to :day, optional: true belongs_to :user has_many :tag_taggables, as: :taggable, dependent: :destroy has_many :tags, through: :tag_taggables before_save :ensure_day after_save :save_main_tag scope :in_range, ->(from, to) { where('(start > :from AND start < :...
FactoryGirl.define do factory :user do sequence(:email) { |n| "finn-the-human-#{n}@land-of-ooo.ooo" } password 'boomboom' end end
class User < ActiveRecord::Base has_secure_password validates :email, presence: true, uniqueness: true validates :name, length: { minimum: 3, maximum: 30 } validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, on: :create } has_many :comments has_many :ratings end
# Cookbook:: fivem # Attributes:: mariadb_server # # 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...
class User < ActiveRecord::Base belongs_to :referrer, :class_name => "User", :foreign_key => "referrer_id" has_many :referrals, :class_name => "User", :foreign_key => "referrer_id" attr_accessible :email validates :email, :uniqueness => true, :format => { :with => /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\...
module Boilerpipe::Extractors class DefaultExtractor def self.text(contents) doc = ::Boilerpipe::SAX::BoilerpipeHTMLParser.parse(contents) ::Boilerpipe::Extractors::DefaultExtractor.process doc doc.content end def self.process(doc) filters = ::Boilerpipe::Filters # merge adj...
module Elevate class Callback def initialize(controller, block) @controller = controller @block = block end def call(*args) if NSThread.isMainThread invoke(*args) else Dispatch::Queue.main.sync { invoke(*args) } end end private def invoke(*args)...
FactoryGirl.define do factory :attachment do file_file_name "example.png" file_content_type "image/png" file_file_size 1000 user proposal end end
module QueryModelPatch # Get all descendants projects for given ids. def get_descendant_projects(value, all = []) if all.empty? all = value end projects = Project.where(parent_id: value) new_ids = [] projects.each do |project| new_ids.push(project.id) all.push(project.id) ...
require 'rails_helper' RSpec.describe ServiceRequest, type: :model do it { is_expected.to belong_to(:protocol) } it { is_expected.to have_many(:sub_service_requests) } end
class ChangeTypeToDataType < ActiveRecord::Migration[5.1] def change rename_column :data, :type, :data_type end end
class ApplicationController < ActionController::API rescue_from Exceptions::AuthorizationError, with: :unauthorized_error rescue_from Exceptions::InvalidHeaderError, Exceptions::EmptyObjectError, Exceptions::WrongHeaderError, with: :invalid_exceptions rescue_from Exceptions::AuthenticationError, with: :authentica...
# 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 rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
#! /usr/bin/env ruby # require 'bundler/setup' require 'json' require 'net/http' require 'openssl' require 'pp' require 'socket' require 'thread' require 'etcd' MARATHON = ENV.fetch 'MARATHON_URL' USER, _, PASS = ENV.fetch('MARATHON_AUTH').partition ':' ips = Hash.new do |this, host| this[host] = Socket::getaddrin...
require_relative 'convert' def greet(name) puts "Hi #{name}! Welcome to Dudley's Pig Emporkium" end test_cases = [ { number: 4, base: 2, expected: '100' }, { number: 322, base: 16, expected: '142' }, { number: 187, base: 2, ...
class Numeric def restrict(var = {}) min = var[:min] || 0 max = var[:max] || 255 self < min ? min : (self > max ? max : self) end def to_hex to_s(base=16).rjust(2, '0') end end
class StreamFavoritesController < FavoritesController def create if @favable.is_a?(Stream) and not @favable.is_public? redirect_to @redirect_location and return false end super end protected def get_favable @favable = Stream.find(params[:id]) end def get_favorite @...
require 'spec_helper' describe "account_types/show" do before do assign(:account_type, Factory(:assets)) end it "should show the name of the account type" do render rendered.should have_content("Name: Assets") end it "should show the code of the account type" do render rendered.shou...
class RemoveColumnBillTotalAmountInBillentries < ActiveRecord::Migration[5.0] def change remove_column :billentries, :bill_total_amount end end
class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? before_action :set_host def set_host Rails.application.routes.default_url_options[:host] = request.host_with_port end protected #サインイン後の遷移先指定 def after_sign_in_path_for(resource) ...
class ConfigureTimeStampItems < ActiveRecord::Migration[5.2] def change remove_column :users, :created_at remove_column :users, :updated_at remove_column :photos, :created_at remove_column :photos, :updated_at remove_column :follows, :created_at remove_column :follows, :updated_at remove_c...
class FeeCollectionBatch < ActiveRecord::Base belongs_to :batch belongs_to :finance_fee_collection has_many :collection_particulars, :finder_sql=>'select cp.* from collection_particulars cp inner join finance_fee_particulars ffp on ffp.id=cp.finance_fee_particular_id where cp.finance_fee_collection_id=#{finan...
# == Schema Information # # Table name: ad_boxes # # id :integer not null, primary key # grid_x :integer # grid_y :integer # column :integer # row :integer # order :...
class Matricula < ActiveRecord::Base self.table_name = 'matriculas' self.inheritance_column = 'ruby_type' self.primary_key = 'id' if ActiveRecord::VERSION::STRING < '4.0.0' || defined?(ProtectedAttributes) attr_accessible :codigo, :empresa_id end belongs_to :empresa, :foreign_key => 'empresa_id', :cla...
class RenameTreatsToTreatments < ActiveRecord::Migration def change rename_table :treats, :treatments end end
class ChangeDatatypeFrameTypeOfBikes < ActiveRecord::Migration[5.0] def change change_column :bikes, :frame_type, :integer end end
# # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>) # Copyright:: Copyright (c) 2013 Opscode, Inc. # License:: Apache License, Version 2.0 # # 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 #...
require 'spec_helper' describe ActionView::Helpers::FormBuilder do class Post def user_id 1 end end let(:template) do ActionView::Base.new end describe "#autocomplete_select" do let(:post) { Post.new } let(:builder) { ActionView::Helpers::FormBuilder.new(:item, post, template, {})...
require 'test_helper' class ImportFileTest < ActiveSupport::TestCase test "invalid won't import" do imp = ImportFile.new assert !imp.import end test "import valid file" do file = Rack::Test::UploadedFile.new('test/samples/example_input.tab', 'text/plain') imp = ImportFile.new(file: file) ...
=begin Tests du model Article =end require 'spec_helper' require_model 'article' describe Article do # ------------------------------------------------------------------- # La classe # ------------------------------------------------------------------- describe "Classe" do it "doit répondre à :article_cou...
# A method named `binary_to_decimal` that receives as input an array of size 8. # The array is randomly filled with 0’s and 1’s. # The most significant bit is at index 0. # The least significant bit is at index 7. # Calculate and return the decimal value for this binary number using # # the algorithm you devised in cl...
Rails.application.routes.draw do resources :produces root 'welcome#index' resources :users do resources :favorites end # custom route, get by username get 'users(/username/:username)', to: 'users#display' resources :markets, only: [:index] end
require_relative 'bike' class DockingStation def release_bike Bike.new end def dock(bike) # use an instance variable to store the Bike # in the 'state' of this instance @bike = bike end attr_reader :bike #longer way #def bike #(we need to return the bike we dock) #@bike #end end
class Ledger < ApplicationRecord belongs_to :group belongs_to :character belongs_to :spec end
class Requisicao < ActiveRecord::Base has_many :itens, :dependent => :destroy has_many :eventos belongs_to :unidade belongs_to :usuario belongs_to :empresa belongs_to :departamento ESTADOS = { :pendente => 'Pendente', :confirmado => 'Confirmado', :enviado => 'Enviado', :recebido => 'Rece...
namespace :edu do task :default => :docker EDU_DOCKER_DIR = "#{DOCKER_DIR}/edu" task :docker => [:clean,:install] do task('docker:mk').reenable task('docker:mk').invoke(EDU_DOCKER_DIR.split('/').last) end task :install do Dir.chdir PROJ_DIR do ['dev:clean', 'dev:all', "dev:install[#{EDU_D...
module Rails module Rack module Log class Level class RuleSet attr_reader :rules def initialize(options = {})#:nodoc: @rules = [] end protected def add_rule(condition, options = {}) #:nodoc: @rules << Rule.new(condition, opt...
require "rails_helper" RSpec.feature "用户可以将商品添加到购物车" do # given(:product) { FactoryGirl.create(:product, name: "电水壶", price: 50) } given(:user) { FactoryGirl.create(:user) } scenario "如果正确填写商品数量" do FactoryGirl.create(:product, name: "电水壶", price: 50) login_as(user) visit "/" click_link "电水...
#!/bin/env ruby require 'yaml' def parse_body(body, &blk) @body_sep = "%" lines = [] body.split(@body_sep).each do |b| hash = YAML::load(b) next unless hash if block_given? then yield hash else lines << b end end lines end if __FILE__ == $0 then #srand(99) File.open("log...
# spec/requests/todos_spec.rb require 'rails_helper' RSpec.describe 'Pages API', type: :request do # initialize test data let!(:pages) { create_list(:page, 10) } let(:page_id) { pages.first.id } # Test suite for GET /pages describe 'GET /pages' do # make HTTP get request before each example befor...
module Authenticable def current_user # if there is a current user return the user return @current_user if @current_user # check the request header to get the token # from Authorization header = request.headers['Authorization'] header = header.split(' ').last if header begin # token decode ...
class CreateDefaultSectionsForExistingIssues < ActiveRecord::Migration class Issue < ActiveRecord::Base has_many :sections end class Section < ActiveRecord::Base belongs_to :issue end def up Issue.find_each do |issue| section = issue.sections.create(default: true) connection.update(...
class Manager < ActiveRecord::Base has_many :custom_requests, class_name: "TaskMaster::CustomRequest", as: :requestor end
require 'cloudformation_mapper/resource' class CloudformationMapper::Resource::AwsResourceCloudtrailTrail < CloudformationMapper::Resource register_type 'AWS::CloudTrail::Trail' type 'Template' parameter do type 'Template' name :Properties parameter do type 'Boolean' name :IncludeGlo...
module FeatureMacros def register_with(email, password) visit "/users/sign_up" fill_in "user_email", :with => email fill_in "user_password", :with => password fill_in "user_password_confirmation", :with => password click_button "Sign up" expect(page).to have_text("A message with a confirmation...
class AddInChatToUsers < ActiveRecord::Migration def change add_column :users, :in_chat, :boolean end end
# 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 'spec_helper' require 'app/models/config/base' require 'app/models/config/eslint' describe Config::Eslint do it_behaves_like 'a service based linter' do let(:raw_config) do <<-EOS.strip_heredoc rules: quotes: [2, "double"] EOS end let(:hound_config_content) do ...
require 'rockpaperscissors' describe Rockpaperscissors do describe 'returns winner' do it 'rock is beaten by paper' do expect(subject.winner('Bob', :rock, 'Alice', :paper)).to eq("Alice") end it 'rock is beaten by spock' do expect(subject.winner('Bob', :rock, 'Alice', :spock)).to eq("Alice...
require "open3" require_relative "vars" # Scenario: Install dependencies When(/^I install dependencies$/) do cmd = "ansible-playbook playbook.backup.yml -i host.ini --private-key=#{PATHTOKEY} --tags 'setup'" output, error, @status = Open3.capture3 "#{cmd}" end Then(/^it should be successful$/) do expect(@status.s...
class User < ApplicationRecord has_secure_password mount_uploader :avatar, AvatarUploader end
class BidItem < ActiveRecord::Base include Tire::Model::Search include Tire::Model::Callbacks belongs_to :organizer # 全文检索 mapping do indexes :id, :index => :not_analyzed indexes :title, :analyzer => 'ik' indexes :organizer_id, :index => :not_analyzed indexes :auction_id, :index => :not_anal...
# Set correct `contributor` for all patreon users module Users class SetPatreonContributorsService def initialize(patron_ids) @patron_ids = patron_ids end def perform User.where(provider: 'patreon').each do |user| user.update(contributor: @patron_ids.include?(user.uid)) end ...
require_relative "piece" require_relative "board" class Bishop < Piece attr_accessor :pos, :board, :color include Slideable def initialize(symbol,board,pos) @color = symbol @board = board @pos = pos end def move_dirs dirs = self.diagonal_dirs possible_move = [] ...