text
stringlengths
10
2.61M
class EventsController < ApplicationController before_action :set_user before_action :set_event, only: [:show, :update, :destroy] # GET /users/:user_id/events def index if @user json_response_event_list(Event.where(user_id: @user.id)) else json_response_event_list(Event.all) end end # GET /user...
# == Schema Information # # Table name: users # # id :integer not null, primary key # current_sign_in_at :datetime # current_sign_in_ip :inet # deleted_at :datetime # email :string default(""), not null # encrypted_password :string ...
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html root to: 'pages#home' get 'home_search', to: 'pages#home_search' resources :work_orders, only: [:show], param: :ref do post :search, on: :collection end end
require "uri" require "tss" require "base64" require "active_support/core_ext/securerandom" if SERVICE_CONFIGURATIONS[:horcrux] RSpec.describe ActiveStorage::Service::HorcruxService do DISK1 = ActiveStorage::Service.configure(:disk1, SERVICE_CONFIGURATIONS) DISK2 = ActiveStorage::Service.configure(:disk2, SERVICE...
class CreatorsController < ApplicationController respond_to :json # Check if a valid API-key exists before_action :api_key # Check if a valid token is sent. No need for #create to # have a check. Need an account to create an account? Not here. before_action :token_authenticate, except: [:create] # Set up offs...
class Gallery < ActiveRecord::Base validates :title, presence: true, length: {minimum: 3, maximum: 40} has_attached_file :mainimage, styles: { small: "3000x3000>", medium: "3000x3000>"} validates_attachment_content_type :mainimage, content_type: /\Aimage\/.*\Z/ validates :mainimage, presence: tr...
class ElasticClient def initialize(url, request_class, body) @url = url @request_class = request_class @body = body end def perform @uri = URI.parse(@url) http = Net::HTTP.new(@uri.host, @uri.port) request = @request_class.new(@uri, {'Content-Type' => 'application/json'}) if Sinatra:...
begin require 'spec' rescue LoadError require 'rubygems' gem 'rspec' require 'spec' end # Lets Game know we're running specs so that it doesn't require user input SHATTERED_SPEC = true SHATTERED_ROOT = File.dirname(__FILE__) require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "shattered", ...
class Photo < ActiveRecord::Base attr_accessible :description, :filename, :date_taken, :aws_filename, :job_id, :upload_user_id belongs_to :job belongs_to :upload_user, :class_name => "User", :foreign_key => "upload_user_id" validates :filename, :date_taken, :aws_filename, :job_id, :upload_user_id, presence: tru...
FactoryBot.define do sequence(:birthdate) { Faker::Date.between(from: 100.years.ago, to: 10.years.ago) } sequence(:company_name) { Faker::Company.name } sequence(:description) { Faker::Lorem.paragraph(sentence_count: 2) } sequence(:firstname) { Faker::Name.first_name } sequence(:french_address) { Faker::Addre...
def balance_check(string) # 1. Check for even number of characters if string.length % 2 != 0 return false end # 2. Hash for matching pairs matches = { '{' => '}', '(' => ')', '[' => ']'} # 3. Use an array as a "Stack" stack = [] # 4. Check every parentheses in string string.split('').each do |...
class CreateShortUrls < ActiveRecord::Migration[5.1] def change create_table :short_urls do |t| t.string :slug t.text :redirect t.references :user, dependent: :nullify # Don't want to delete any aliases if we delete the user that created them. t.timestamps end add_index ...
class ApplicationController < ActionController::Base protect_from_forgery before_filter :require_login def require_login if session[:me] @me = User.find session[:me] else flash[:error] = 'Authentication required' session[:from] = request.url redirect_to login_path end end def redirect_to_with_f...
module CreditCardValidator # module of helper functions for determining the validation of credit card numbers def card_patterns # block array of credit card companies and their validations [ { company: 'AMEX', begins: /^3[47]/, length: [15] }, { company: 'Discov...
ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require "paperclip/matchers" require 'shoulda-matchers' require 'database_cleaner' DatabaseCleaner.strategy = :truncation SPEC_WORKFILE_PATH = Rails.root + "system/legacy_workfile...
require 'minitest/autorun' require 'geocoder_simple' MiniTest.autorun class TestGeocoderSimple < MiniTest::Test def setup $stdout, @orig_stdout = open("/dev/null", 'w'), $stdout @geocoder = GeocoderSimple.new("東京都墨田区押上1丁目1−2") end def teardown $stdout = @orig_stdout end def test_address ...
class User < ActiveRecord::Base has_secure_password has_many :posts ## example: @user.posts runs Post.where(user_id: @user.id) ## can also do @user.posts.create(post parameters go here) has_many :votes ## example: @user.votes runs Vote.where(user_id: @user.id) has_many :voted_posts, through: :votes, sou...
class CommentsController < ApplicationController def create @tab = Tab.find(params[:tab_id]) @comment = @tab.comments.create!(params[:comment]) redirect_to @tab end end
Rails.application.routes.draw do get 'cv_generator/index' post 'display/' => 'cv_generator#display' root 'cv_generator#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
ActiveAdmin.register_page "league_ranking" do menu label: "順位表", priority: 4 config.breadcrumb = false require 'open-uri' require 'nokogiri' url = 'http://www.shinkanto-junko.jp/game.html' charset = nil html = open(url, 'r:Shift_JIS') do |f| charset = f.charset # 文字種別を取得 f.read # htmlを読み込んで変数ht...
# ! replace this values or edit it later in /etc/environment (do not forget logout/login after that) namespace = 'thenamespace' hub = 'thetopic' key = 'thekey' Vagrant.configure("2") do |config| config.vm.box = "ubuntu/bionic64" config.vm.box_check_update = false config.vm.provision :shell, inlin...
class AddDescription < ActiveRecord::Migration[5.1] # Adding coolmuns to the Article table def change add_column :articles, :description, :text add_column :articles, :created_at, :datetime add_column :articles, :updated_at, :datetime end end
#!/usr/bin/env ruby require 'optparse' require 'rubygems' $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require 'mass_migrator' options = {} opts_parser = OptionParser.new do |o| o.banner = "Usage: mass_migrate (up|show|down [MIGRATION NAME]) [OPTIONS]" o.on '-t', '--table-pattern [PATTERN]', 'Patter...
module Swa module Provider class CloudClient attr_accessor :opsworks def initialize(params = {}) self.opsworks ||= Aws::OpsWorks::Client.new( region: params[:region], credentials: Aws::Credentials.new(ENV["AWS_ACCESS_KEY"], ENV["...
class SuppliesController < ApplicationController # GET /supplies # GET /supplies.xml def index @supplies = Supply.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @supplies } end end # GET /supplies/1 # GET /supplies/1.xml def show @supply ...
require 'rails_helper' module Timeline RSpec.describe ExtractEventsService do before(:each) do @resources = 5.times.collect { |i| OpenStruct.new name: "Event #{6 - i}", happened_at: i.hours.ago } end it { expect(ExtractEventsService.call(resources: @resources).events).to be_a(Array) } it { exp...
class AddBottleHoldersChangeDateBottle < ActiveRecord::Migration def change add_column :bottle_holders, :date_bottle_change, :date add_column :bottle_holders, :last_day_cleaned, :date end end
# -*- encoding : utf-8 -*- class CreateProvinces < ActiveRecord::Migration def change create_table :provinces do |t| t.string :uuid, limit: 36, null: false t.string :name, limit: 50, null: false t.integer :cities_count, default: 0, null: false t.timestamps null: false end end end
FactoryGirl.define do factory :player do name 'Test Player' end factory :sport do name '9 Ball' end factory :rank do player { FactoryGirl.create(:player) } sport { FactoryGirl.create(:sport) } value 1000 end factory :game do winner { FactoryGirl.create(:player) } loser...
module RSence module Plugins # This class automatically loads a YAML file from "gui" subdirectory of a plugin. # # Extend your plugin from the {GUIPlugin__ GUIPlugin} class instead of the Plugin class to make this work automatically. # # @example Initialize like this from inside a...
require 'rails_helper' RSpec.describe 'contact list', type: :feature, js: true do context 'when there are no contacts' do it 'displays no contact message' do visit '/contacts' expect(page.body).to have_content('You have no contacts. Add a contact or upload a contact file.') end end context ...
require 'spec_helper' describe VotesController do let(:link) { FactoryGirl.create(:link) } let(:vote) { FactoryGirl.create(:vote) } describe '#create' do it 'should increase votes for the link by one' do @vote_params = { votable_id: link.id } expect{ post :create, vote: @vote_params ...
module TypicalSituation # Rails MIME responses. module Responses # Return the collection as HTML or JSON # def respond_with_resources respond_to do |format| yield(format) if block_given? format.html do set_collection_instance render end for...
class ACSConverter def initialize(options) @options = options end def straight { "FamilyNumber" => "legacy_family_id", "LastName" => "last_name", "Suffix" => "suffix", "Address1" => "family_address1", "Address2" => "family_address2", ...
# class EventCalendarsController < ApplicationController # # verify :method => :post, :only => [ :destroy, :create, :update ], # :redirect_to => { :action => :list } # # # def refresh_all # # This is the correct line for the agent to run. # # Calendar::refresh_all # # # We'll keep u...
module Bootsy class Image < ActiveRecord::Base belongs_to :image_gallery, touch: true mount_uploader :image_file, ImageUploader validates_presence_of :image_file, :image_gallery_id end end
module MantaFilesHelper def file_icon(file_obj) if file_obj.is_a?(MantaDir) "folder outline" elsif file_obj.is_a?(MantaFile) "file outline" end end def manta_breadcrumbs(full_path) root = "/#{current_manta_account.manta_username}/stor" if full_path == root link_to root, manta...
require File.dirname(__FILE__) + '/../test_helper' class SharesNotifierTest < ActiveSupport::TestCase test "action for review" do review = Factory(:review) notifier = SharesNotifier.new(Share.new(:content => review)) assert_equal "wrote a review on #{Cobrand.root.name}", notifier.send(:action) ...
require 'rails_helper' RSpec.describe SchoolsController, type: :controller do describe "schools#index action" do before :each do @user = FactoryGirl.create(:user) @user_admin = FactoryGirl.create(:user_admin) end it "should successfully show the page" do sign_in @user ...
class UserRoleAccess < ApplicationRecord belongs_to :access belongs_to :user_role end
class Mobilization < ActiveRecord::Base belongs_to :field validates_presence_of :date, :operation end
namespace :data do desc "Made users anonymous" task :anonymous, [:email_postfix, :pass] => :environment do |t, args| # TODO: redefining some custom validations, remove after User model is refactored class User def get_skip_zip_validation?; true; end def get_skip_first_name_validation?; true; end...
module Thing::Cell class Edit < Trailblazer::Cell include ActionView::RecordIdentifier include ActionView::Helpers::FormOptionsHelper include SimpleForm::ActionViewExtensions::FormHelper private def title "Edit #{model.model.name}" end end end
class CreateClubFeedPosts < ActiveRecord::Migration def change create_table :club_feed_posts do |t| t.integer :club_id, null: false t.integer :poster_id, null: false t.string :body, null: false t.timestamps end add_index :club_feed_posts, :club_id end end
class Airport < ActiveRecord::Base attr_accessible :city, :iata_code, :country, :region_conus has_many :originating_flights, :class_name => 'Flight', :foreign_key => 'originating_airport_id' has_many :arriving_flights, :class_name => 'Flight', :foreign_key => 'destination_airport_id' has_many :first_routes, :cl...
## Time Convert # Have the function TimeConvert(num) take the num # parameter being passed and return the number of hours # and minutes the parameter converts(ie. if num=63 then # the output should be 1:3)Seperate the number of hours # and minutes with a colon. def TimeConvert(num) return "#{num / 60}:#{num % 60}" en...
class ItemsController < ApplicationController before_action :set_item, except: [:index, :new, :create, :get_category_children, :get_category_grandchildren] def index @items = Item.all.includes(:pictures).order('created_at DESC') end def new if user_signed_in? @item = Item.new @item.picture...
require 'spec_helper' class AbstractHarness def process_action action, *args "Processed." end def append_info_to_payload payload payload end def self.log_process_action payload [] end end module Strumbar module Instrumentation module Mongoid describe ControllerRuntime do ...
namespace :db do desc "Fill database with sample data" task populate: :environment do make_users make_tasks make_relationships end end def make_users admin = User.create!(name: "Example User", email: "example@railstutorial.org", password: "foobar", ...
class PhoneNumberValidationValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value.blank? record.errors.add(attribute, '電話番号を入力してください。') elsif value !~ /^\d{10}$|^\d{11}$/ record.errors.add(attribute, '電話番号は不正な値です。') end end end
module Kuhsaft module AdminHelper # # When rendering the layout of our host application, # the paths of the host application are not visible to the engine # therefore we delegate all failing helper calls to 'main_app', # which is our host application # def method_missing(method, *args, &bl...
class Dish < ActiveRecord::Base belongs_to :user belongs_to :restaurant def self.get_dish_name #gets dish name from user puts "What is the name of the dish you would like to add?".bold.colorize(:blue) name = gets.chomp puts " " name end def dish_update puts "What would you like to update...
Rails.application.routes.draw do root to: 'pages#home' get 'about', to: 'pages#about' get 'contact', to: 'pages#contact' resources :posts, only: [:show, :index] resources :categories, only: [:show, :index] resources :strategies, :path => 'strategy', only: [:show, :index] # For details on the DSL...
require 'rails_helper' describe 'Property owner view reservations' do before(:each) do property_type = PropertyType.create!(name: 'tipo') property_location = PropertyLocation.create!(name: 'local') @property_owner1 = PropertyOwner.create!(email: 'nome1@mail.com', password:'123456') ...
#!/usr/bin/env ruby require 'optparse' require 'methadone' require 'aethyr/core/connection/server' class App include Methadone::Main include Methadone::CLILogging main do |command, subcommand| puts 'verbose output enabled' if options[:verbose] puts 'flag set to: ' + options['flag'] if opt...
class ParsesController < ApplicationController layout false def create @parse = Highlighter.perform(parse_params) end private def parse_params params.require(:parse).permit(:language, :source) end end
require 'rails_helper' describe 'Recipient' do before(:each) do @user1 = User.create(name: "Clayton", username: "Tester", email: "me@example", password_digest: "password", city: "Chicago") @user2 = User.create(name: "Mrs. Adolfo Fadel", username: "rosalee_renner", email: "jaron.mohr@blicklakin.info", passwor...
class CreatePatients < ActiveRecord::Migration def change create_table :patients do |t| t.belongs_to :clinic t.string :code t.string :firstname t.string :lastname t.date :birthdate t.string :gender t.string :civil_status t.string :email t.string :phone t...
class AddDeletedFlagToReport < ActiveRecord::Migration def self.up add_column :reports, :deleted, :boolean end def self.down remove_column :reports, :deleted end end
class OrdersController < ApplicationController def index authorize!(:read) @orders = Order.all.order(id: :desc) render( json: { success: true, code: 200, message: "Success", data: @orders.as_json(:include => [:order_i...
# frozen_string_literal: true module ContextRequestMiddleware # :nodoc: class Middleware def initialize(app) @app = app @data = {} end def call(env) request = ContextRequestMiddleware.request_class.new(env) request(request) if valid_sample?(request) status, header, body =...
# encoding: utf-8 require "rubygems" require "bundler/setup" # Loads bundler tasks Bundler::GemHelper.install_tasks # Loads the Hexx::RSpec and its tasks begin require "hexx-suit" Hexx::Suit.install_tasks rescue LoadError require "hexx-rspec" Hexx::RSpec.install_tasks end # Sets the Hexx::RSpec :test task t...
class Cart include Monify attr_reader :contents, :garments_quantity, :price def initialize(cart_data) @contents = cart_data || Hash.new(0) update end def add_to_cart(garment) @contents[garment.to_s] ||= 0 @contents[garment.to_s] += 1 end def remove_from_cart(garment) @contents.delet...
module SuperDiff module RSpec module Differs class HashIncluding < SuperDiff::Differs::Hash def self.applies_to?(expected, actual) SuperDiff::RSpec.a_hash_including_something?(expected) && actual.is_a?(::Hash) end private def operations Opera...
require 'rails_helper' RSpec.describe "Faq routing", type: :routing do it "routes the :index view correctly" do expect(get("/faq")).to route_to('faq#index') end end
class String def to_md5 Digest::MD5.hexdigest(self) end def escape_quotes self.gsub(/['"\\\x0]/,'\\\\\0') end end
# frozen_string_literal: true require_relative '../../lib/movement/en_passant_movement' require_relative '../../lib/movement/basic_movement' require_relative '../../lib/board' require_relative '../../lib/pieces/pawn' RSpec.describe EnPassantMovement do describe '#update_pieces' do subject(:movement) { described...
class CreateDeals < ActiveRecord::Migration def change create_table :deals do |t| t.integer :product_id, :references => :products t.string :description t.timestamps :valid_from t.timestamps :valid_to t.string :term_and_condition t.timestamps end end end
class Run < Thor desc "build", "run middleman build" def build `middleman build` end desc "watch", "Start watchr to convert haml, sass and coffee source as it is modified" def watch invoke :build system "watchr converters.watchr" end end
class ProjectsController < ApplicationController before_action :authenticate_entity! # == Begin == # Definition: "A startup can see a list of his projects" # This method allows you to get a list of projects and # moves with a session_id of an entity in order to # list all the project's of the startup ...
require 'rails/generators/active_record/migration' class I18nBackendDatabaseGenerator < Rails::Generators::Base include Rails::Generators::Migration extend ActiveRecord::Generators::Migration source_root File.expand_path('../templates', __FILE__) def create_migration migration_template "migrate/create_i18...
# coding: utf-8 class ArticlePresenter < BasePresenter include ActionView::Helpers include ApplicationHelper presents :article def title raw link_to(article.title, show_community_article_url(article.community, article)) end def text raw truncate(strip_tags(article.body), length: 140, omission: '......
class CreateProperties < ActiveRecord::Migration[5.2] def change create_table :properties do |t| t.string :post_code, null: false t.string :image_id t.float :size t.integer :status t.string :prefecture, null: false t.string :city, null: false t...
require 'test_helper' require './lib/blueprint_agreement/server' describe BlueprintAgreement::Server do let(:api_service) { ApiService.new(config) } let(:described_class) { BlueprintAgreement::Server } let(:instance) { described_class.new(api_service: api_service, config: config) } let(:config) { mock() } d...
#Model class created to instantiate and update in a single transaction the three models used on the dashboard view. It reduces the complexity of the dashboard controller and ensures data integrity since the three models are going to be simultaneously updated with the api data. class Dashboard include ActiveModel::Mo...
require "aethyr/core/actions/commands/emotes/emote_action" module Aethyr module Core module Actions module Ew class EwCommand < Aethyr::Extend::EmoteAction def initialize(actor, **data) super(actor, **data) end def action event = @data ...
module Nora class User < ApplicationRecord has_one :secure_token, foreign_key: :nora_user_id delegate :token, to: :secure_token, allow_nil: true def self.sign_in!(auth) find_or_initialize_by(provider: auth[:provider], uid: auth[:uid]).tap do |user| if user.persisted? user.secure_...
module RubyMotionQuery module Stylers BORDER_STYLES = { rounded: NSRoundedBezelStyle, square: NSRegularSquareBezelStyle, thick_square: NSThickSquareBezelStyle, thicker_square: NSThickerSquareBezelStyle, disclosure: NSDisclosureBezelStyle, shadowless_square: NSShado...
class EventsController < ApplicationController def index @events = Event.all end def new @event = Event.new end before_action :set_event, :only => [ :show, :edit, :update, :destroy] def create @event = Event.new(event_params) if @event.save redirect_to :action => :index flash[:notice] = "event was...
class Idol include Mongoid::Document field :name, type: String field :age, type: Integer field :test, type: String # field :birthday, :type => Date # to set name necessary validates_presence_of :name embeds_many :comments belongs_to :author end
class AddIntuitColumnsToCompanies < ActiveRecord::Migration def change add_column :companies, :intuit_access_token, :string add_column :companies, :intuit_access_secret, :string add_column :companies, :realm, :string add_column :companies, :intuit_name, :string end end
class Tenant < ActiveRecord::Base belongs_to :room, counter_cache: true, required: true belongs_to :user, required: true end
RSpec.describe Yaks::DefaultPolicy do subject(:policy) { described_class.new(options) } let(:options) { {} } let(:association) { Yaks::Mapper::HasMany.create('shoes') } describe '#initialize' do it 'should work without arguments' do expect(described_class.new.options).to eql described_class::DEFAULT...
# Original sort method: # # words = [] # while true # word = gets.chomp # break if word.empty? # words << word # end # puts words.sort # So, we want to sort an array of words, and we know how to find out which of # two words comes first in the dictionary (using <). # What strikes me as probably the eas...
class ReservationsController < ApplicationController layout "reservations" before_action :authenticate_user! def index authorize! :create, :reservation @rooms = Room.valid_room(params[:checkin], params[:checkout]) .page(params[:page]) .per Settings.reservation.page @c...
require_relative 'spec_helper' #get all the stuff we need for testing. require_relative '../tile_bag' require_relative '../player' #include the code from player.rb that we need to test. module Scrabble describe Player do let(:sebastian) {Player.new("Sebastian")} #This allows us to just use 'sebastian' as a new p...
require 'test_helper' class NewPostsTest < ActionDispatch::IntegrationTest def setup @user = users(:test_user) @post = Post.new(title:"Title", body: "test" * 10, user_id: @user.id) end test "post is valid" do assert @post.valid? end test "invalid post" do log_in_as(@user) get new_post_path assert_n...
# coding: utf-8 require 'imap-filter' include ImapFilter::DSL module ImapFilter module Functionality STATUS = {messages: 'MESSAGES', recent: 'RECENT', unseen: 'UNSEEN'} ISTAT = STATUS.map{ |k, v| [v, k] }.to_h def self.show_imap_plan puts '====== Accounts'.light_yellow _accounts.each do...
Rails.application.routes.draw do mount LatoPages::Engine => "/lato_pages" end
require 'byebug' require_relative "display" require_relative "null_piece" require_relative "piece" require_relative "pieces/rook" require_relative "pieces/bishop" require_relative "pieces/king" require_relative "pieces/queen" require_relative "pieces/knight" require_relative "pieces/pawn" class Board attr_accessor...
class Message < ActiveRecord::Base def new_message? self.is_read(current_user) end end
class RecommendationRequest # < RecommendationRequest.superclass module Cell class New < Abroaders::Cell::Base include Escaped # @param people [Collection<Person>] people who want to request a rec. # An error will be raised if any of them can't request a rec def initialize(people, optio...
require 'spec_helper' describe Blacklight do context "locate_path" do it "should find app/controllers/application_controller.rb" do result = Blacklight.locate_path 'app', 'controllers', 'application_controller.rb' expect(result).not_to be_nil end it "should not find blah.rb" do ...
require 'rails_helper' describe MemberEmail do describe ".free_day_pass_use" do let(:member) { FactoryBot.create(:affiliate_member) } let(:mail) { MemberEmail.free_day_pass_use(member) } it "renders the headers" do expect(mail.subject).to eq("Day pass use") expect(mail.to).to eq([member.ema...
require 'spec_helper' describe 'dvwa::default' do let(:subject) do ChefSpec::SoloRunner.new(file_cache_path: '/var/chef/cache', step_into: %w(dvwa_db)) do |node| node.override['dvwa']['version'] = '2' node.override['dvwa']['path'] = '/opt/dvwa-app' node.override['dv...
class RemoveOrderIdFromFormula < ActiveRecord::Migration def change remove_column :formulas, :order_id end end
module ActiveCampaign class Client module Tracks GET_METHODS = %w(event_list site_list).freeze unless defined?(GET_METHODS) PUT_METHODS = %w(site_whitelist_add).freeze unless defined?(PUT_METHODS) POST_METHODS = %w( event_status_edit site_status_edit event_add ).freeze unless defin...
require 'test_helper' class PostTest < ActiveSupport::TestCase test 'maximum test field length' do p = Post.new test: ('a' * 12) refute p.save assert_equal ['is too long (maximum is 10 characters)'], p.errors[:test] end end
class BookKey < ActiveRecord::Base belongs_to :book belongs_to :user enum state: {available: 0, actived: 1, blocked: 2} def self.generate_book_key datas, role, type_key quantity = datas.map{|e| e[1].to_i}.sum keys = KeyGenerator.uniq_keys BookKey.select(:key), :private, quantity ActiveRecord::Bas...
class Dictionary def initialize @entries = {} end def entries @entries end def add(animal) if animal.is_a?(Hash) @entries[animal.keys.first] = animal[animal.keys.first] else @entries[animal] = nil end end def keywords @entries.keys.sort end def include?(keyword...