code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class AddMotivationToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :motivation_id, :integer
end
def self.down
remove_column :characters, :motivation_id
end
end
| Ruby |
class CreateCharacters < ActiveRecord::Migration
def self.up
create_table :characters do |t|
t.string :name
t.integer :user_id
t.integer :career_path_id
t.integer :experience_to_spend, :default => 500
t.integer :experience_spent, :default => 4500
t.timestamps
end
end
... | Ruby |
class AddBirthrightToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :birthright_id, :integer
end
def self.down
remove_column :characters, :birthright_id
end
end
| Ruby |
class CreateCareers < ActiveRecord::Migration
def self.up
create_table :careers do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :careers
end
end
| Ruby |
class AddCareerToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :career_id, :integer
end
def self.down
remove_column :characters, :career_id
end
end
| Ruby |
class AddLureOfTheVoidToCharacters < ActiveRecord::Migration
def self.up
add_column :characters, :lure_of_the_void_id, :integer
end
def self.down
remove_column :characters, :lure_of_the_void_id
end
end
| Ruby |
class DefaultLureOfTheVoids < ActiveRecord::Migration
def self.up
LureOfTheVoid.delete_all
LureOfTheVoid.create(:name => 'Tainted')
LureOfTheVoid.create(:name => 'Criminal')
LureOfTheVoid.create(:name => 'Renegade')
LureOfTheVoid.create(:name => 'Duty Bound')
LureOfTheVoid.create(:name =>... | Ruby |
class CreateRoles < ActiveRecord::Migration
def self.up
create_table :roles do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :roles
end
end
| Ruby |
class CreateMotivations < ActiveRecord::Migration
def self.up
create_table :motivations do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :motivations
end
end
| Ruby |
class DefaultBirthrights < ActiveRecord::Migration
def self.up
Birthright.delete_all
Birthright.create(:name => 'Scavenger')
Birthright.create(:name => 'Scapegrace')
Birthright.create(:name => 'Stubjack')
Birthright.create(:name => 'Child of the Creed')
Birthright.create(:name => 'Savant'... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta4'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
gem 'devise', '1.1.rc2'
gem 'warden', '0.10.7'
gem 'cancan', '1.1.1'
gem 'nifty-generators', '0.4.0'
gem 'formtastic-rails3', '0.9.10.0'
gem 'pg'
# Use unicorn a... | Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
module ApplicationHelper
end
| Ruby |
module HomeWorldsHelper
end
| Ruby |
module LureOfTheVoidsHelper
end
| Ruby |
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
options[:header_message] ||= "Invalid Fields"
options[:message] ||= "Correct the following errors and try a... | Ruby |
module BirthrightsHelper
end
| Ruby |
module CharactersHelper
end
| Ruby |
module OriginPathStagesHelper
end
| Ruby |
module TrialsAndTravailsHelper
end
| Ruby |
module CareersHelper
end
| Ruby |
module RolesHelper
end
| Ruby |
module OriginPathsHelper
end
| Ruby |
# These helper methods can be called in your template to set variables to be used in the layout
# This module should be included in all views globally,
# to do so you may need to add this line to your ApplicationController
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
content_for... | Ruby |
module MotivationsHelper
end
| Ruby |
class Character < ActiveRecord::Base
attr_accessible :name, :user_id, :experience_to_spend, :experience_spent, :id,
:weapon_skill, :ballistic_skill, :strength, :toughness, :agility, :intelligence, :perception, :will_power,
:fellowship, :home_world_id, :lure_of_the_void_id, :motivation_id, :birthright_id, :car... | Ruby |
class TrialsAndTravails < ActiveRecord::Base
attr_accessible :name
has_many :characters
end
| Ruby |
class Career < ActiveRecord::Base
attr_accessible :name
end
| Ruby |
class OriginPathStage < ActiveRecord::Base
attr_accessible :name
has_many :origin_paths
end
| Ruby |
class LureOfTheVoid < ActiveRecord::Base
attr_accessible :name
has_many :characters
end
| Ruby |
class HomeWorld < ActiveRecord::Base
attr_accessible :name
has_many :characters
end
| Ruby |
class Birthright < ActiveRecord::Base
attr_accessible :name
has_many :characters
end
| Ruby |
class OriginPath < ActiveRecord::Base
attr_accessible :origin_path_stage_id, :name, :description
belongs_to :origin_path_stage
end
| Ruby |
class User < ActiveRecord::Base
belongs_to :role
has_many :characters
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable, :lockable and :timeoutable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
... | Ruby |
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new(:role_id => Role.find_by_name("Guest").id)
if user.role.name == 'Admin'
can :manage, :all
else
if user.role.name == 'Registered'
can :read, :all
can :create, Character
can :update, Ch... | Ruby |
class Role < ActiveRecord::Base
has_many :users
attr_accessible :name, :id
end
| Ruby |
class Motivation < ActiveRecord::Base
attr_accessible :name
has_many :characters
end
| Ruby |
class CharactersController < ApplicationController
load_and_authorize_resource
def index
@characters = Character.all
end
def show
end
def new
session[:character_params] = {}
@character.user_id = current_user.id
@character.weapon_skill = Character.generate_stat
@character.ballisti... | Ruby |
class OriginPathStagesController < ApplicationController
load_and_authorize_resource
def index
@origin_path_stages = OriginPathStage.all
end
def show
end
def new
end
def create
if @origin_path_stage.save
flash[:notice] = "Successfully created origin path stage."
redirect_t... | Ruby |
class BirthrightsController < ApplicationController
load_and_authorize_resource
def index
@birthrights = Birthright.all
end
def show
end
def new
end
def create
if @birthright.save
flash[:notice] = "Successfully created birthright."
redirect_to @birthright
else
re... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
layout 'application'
rescue_from CanCan::AccessDenied do |exception|
flash[:error] = "Access Denied."
redirect_to root_url
end
end
| Ruby |
class OriginPathsController < ApplicationController
load_and_authorize_resource
def index
@origin_paths = OriginPath.all
end
def show
end
def new
end
def create
if @origin_path.save
flash[:notice] = "Successfully created origin path."
redirect_to @origin_path
else
... | Ruby |
class HomeWorldsController < ApplicationController
load_and_authorize_resource
def index
@home_worlds = HomeWorld.all
end
def show
end
def new
end
def create
if @home_world.save
flash[:notice] = "Successfully created home world."
redirect_to @home_world
else
rend... | Ruby |
class LureOfTheVoidsController < ApplicationController
load_and_authorize_resource
def index
@lure_of_the_voids = LureOfTheVoid.all
end
def show
end
def new
end
def create
if @lure_of_the_void.save
flash[:notice] = "Successfully created lure of the void."
redirect_to @lure... | Ruby |
class RolesController < ApplicationController
load_and_authorize_resource
def index
@roles = Role.all
end
def show
end
def new
end
def create
if @role.save
flash[:notice] = "Successfully created role."
redirect_to @role
else
render :action => 'new'
end
end
... | Ruby |
class MotivationsController < ApplicationController
load_and_authorize_resource
def index
@motivations = Motivation.all
end
def show
end
def new
end
def create
if @motivation.save
flash[:notice] = "Successfully created motivation."
redirect_to @motivation
else
re... | Ruby |
class CareersController < ApplicationController
load_and_authorize_resource
def index
@careers = Career.all
end
def show
end
def new
end
def create
if @career.save
flash[:notice] = "Successfully created career."
redirect_to @career
else
render :action => 'new'
... | Ruby |
class TrialsAndTravailsController < ApplicationController
load_and_authorize_resource
def index
@trials_and_travails = TrialsAndTravails.all
end
def show
end
def new
end
def create
if @trials_and_travails.save
flash[:notice] = "Successfully created trials and travails."
re... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person',... | Ruby |
require 'formtastic'
ActionView::Base.send :include, Formtastic::SemanticFormHelper
# Set the default text field size when input is a string. Default is 50.
# Formtastic::SemanticFormBuilder.default_text_field_size = 50
# Set the default text area height when input is a text. Default is 20.
# Formtastic::SemanticForm... | Ruby |
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a probl... | Ruby |
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary atta... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
| Ruby |
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, :key => '_rtcg_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:se... | Ruby |
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in DeviseMailer.
config.mailer_sender = "please-change-me@con... | Ruby |
Rtcg::Application.routes.draw do |map|
resources :careers
resources :motivations
resources :trials_and_travails
resources :birthrights
resources :lure_of_the_voids
resources :home_worlds
resources :characters
resources :roles
devise_for :users
# The priority is based upon order of creation:... | Ruby |
require 'rubygems'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gem... | Ruby |
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)
module Rtcg
class Application < Rails::Application
# Se... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
Rtcg::Application.initialize!
| Ruby |
Rtcg::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
... | Ruby |
Rtcg::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserve... | Ruby |
Rtcg::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test sui... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rtcg::Application
| Ruby |
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
Rails::Application.load_tasks
| Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
#!/usr/bin/env ruby
# CSV to USF Converter, version 0.12, 06/11/2008
# Copyright (c) 2008, Hanjo Kim
# Released under the GPL
# Changelog
# 2008.11.04 : ver 0.1 - Initial version
# 2008.11.05 : ver 0.11
# 1. '-i' and '-o' options are required now.
# 2. change -d option parsing routine
# 3. Verificate the existence... | Ruby |
#!/usr/bin/env ruby
# CSV to USF Converter, version 0.12, 06/11/2008
# Copyright (c) 2008, Hanjo Kim
# Released under the GPL
# Changelog
# 2008.11.04 : ver 0.1 - Initial version
# 2008.11.05 : ver 0.11
# 1. '-i' and '-o' options are required now.
# 2. change -d option parsing routine
# 3. Verificate the existence... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google 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.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'rubygems'
require 'gserver'
require 'redis'
class SMTPServer < GServer
def initialize(*args)
super(*args)
@redis = Redis.connect
end
def serve(io)
@mail_msg = []
@data_mode = false
puts "Connected"
io.print "220 hello\r\n"
loop do
if IO.select([io], nil, nil, 0.1)
... | Ruby |
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
require 'rubygems'
require "sinatra"
require 'oauth'
require 'oauth/consumer'
enable :sessions
def new_Consumer(api_key='1869125062', api_key_secret='d128d7a473c7a06ba0b84284a24c... | Ruby |
require 'rubygems'
require "redis"
require "oauth"
require "cgi"
require "tmail"
redis = Redis.new(:thread_safe=>true)
trap(:INT) { puts; exit }
def consumer(api_key='1869125062', api_key_secret='d128d7a473c7a06ba0b84284a24c7924')
return OAuth::Consumer.new(api_key, api_key_secret ,
... | Ruby |
require 'rubygems'
require 'eventmachine'
require 'ostruct'
require 'redis'
class EmailServer < EM::P::SmtpServer
@host = "session.im"
@port = 25
def receive_plain_auth(user, pass)
true
end
def get_server_domain
@host
end
def get_server_greeting
"#{@host} smtp serv... | Ruby |
#! /usr/bin/ruby
#author newdongyuwei@gmail.com
require 'rubygems'
require "redis"
require "oauth"
require "cgi"
require 'uri'
require "tmail"
require "yaml"
require 'net/http'
require 'net/http/post/multipart'
redis = Redis.new(:thread_safe=>true)
trap(:INT) { puts; exit }
def new_consumer(api_key='1869125062', api... | Ruby |
#! /usr/bin/ruby
#by newdongyuwei@gmail.com
#mail2miniblog all in one
if GC.respond_to?(:copy_on_write_friendly=)
GC.copy_on_write_friendly = true
end
require 'rubygems'
require "sinatra"
require "sinatra/base"
require 'oauth'
require 'oauth/consumer'
require 'eventmachine'
require 'ostruct'
require 'redi... | Ruby |
$:.unshift '.'
ENV['RACK_ENV'] = "production"
require 'rubygems'
require 'main'
run Sinatra::Application
| Ruby |
require 'net/smtp'
message = <<MESSAGE_END
1This is an e-mail message to be sent in HTML format
2<b>This is HTML message.</b>
3<h1>This is headline.</h1>
MESSAGE_END
Net::SMTP.start('session.im', 25)do|smtp|
smtp.set_debug_output $stdout
smtp.send_message message, 'from@session.im', 'to@session.im'
end
| Ruby |
# put the file on the screen
puts "Hello,world!"
puts "Hello,again!"
puts "my name is chen-xiao-qing."
puts "I'm 22 years old"
puts "I'll do my best when I study ruby!"
#这个,太简单了,我就不说什么了,只是简单地打印字符串而已,不过你最好能:
#1.找找这个puts方法是定义在哪里?
#2.还有其他的可以输出到终端的方法,找一下还有哪些?定义在哪里?和puts有什么区别?
#3.找到这些方法定义的位置之后,搞清楚一个ruby程序在运行时,默认会加载哪些模块(mo... | Ruby |
require "test/unit"
class AboutExceptions<Test::Unit::TestCase
class MySpecialError<RuntimeError
end
def test_string1
assert_equal RuntimeError, MySpecialError.ancestors[1]
assert_equal StandardError, MySpecialError.ancestors[2]
assert_equal Exception, MySpecialError.ancestors[3]
asser... | Ruby |
require "test/unit"
class Test_koans<Test::Unit::TestCase
def test_assert_truth
assert true #This should be true
end
def test_assert_with_message
assert true, "This should be true -- please fix this"
end
def test_assert_equality
expected_value = 2
actual_value = 1 + 1
assert expected_val... | Ruby |
the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apricots']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
for number in the_count
puts "This is cout #{number}"
end
# number 可以用任何其他的词或字母代替,只代表the_count里面的元素
fruits.each do |fruit|
puts "A fruit of type: #{fruit}"
end
# x.each do |x| end 的用法,... | Ruby |
require "test/unit"
class Test_Koans<Test::Unit::TestCase
def test_nil_is_an_object
assert_equal true, nil.is_a?(Object),"Unlike NULL in other languages"
end
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
begin
nil.some_method_nil_doesnt_know_about
rescue Exception ... | Ruby |
require "test/unit"
class Test_Koans<Test::Unit::TestCase
def test_a_pattern_is_a_regular_expression
assert_equal Regexp, /pattern/.class
end
# 表明正则表达式属于 Regexp类
def test_a_regexp_can_search_a_string_for_matching_content
assert_equal "match", "some matching content" [/match/]
end
# 在string中搜寻ma... | Ruby |
require "test/unit"
class AboutIteration < Test::Unit::TestCase
def test_each_is_a_method_on_arrays
[].methods.include?("each")
end
def test_iterating_with_each
array = [1, 2, 3]
sum = 0
array.each do |item|
sum += item
end
assert_equal 6, sum
end
def test_each_can_use_curly_br... | Ruby |
require "test/unit"
class AboutBlocks < Test::Unit::TestCase
def method_with_block
result = yield
result
end
def test_methods_can_take_blocks
yielded_result = method_with_block {1 + 2}
assert_equal 3, yielded_result
end
def test_blocks_can_be_definded_with_do_end_too
yielded_result = m... | Ruby |
require "test/unit"
class TC_MyTest<Test::Unit::TestCase
def test_here_documents_can_also_handle_multiple_lines
long_string = <<EOS
It was the best of times,
It was the worst of times.
EOS
assert_equal 53, long_string.size
end
end
| Ruby |
people = 20
cats = 30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed!"
end
if people < cats
puts "Not many cats! The world is saved!"
end
if people < dogs
puts "The world is drooled on!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if people >= dogs
puts "People a... | Ruby |
require "test/unit"
class Test_Koans<Test::Unit::TestCase
def test_creating_arrays
empty_array = Array.new
assert_equal Array, empty_array.class
assert_equal 0, empty_array.size
end
def test_array_literals
array = Array.new
assert_equal [], array
array[0] = 1
assert_equal [1], a... | Ruby |
people = 30
cars = 40
buses = 15
if cars > people
puts "we should take the cars."
elsif cars < people
puts "We should not take the cars."
else
puts "We can't decide."
end
if buses > cars
puts "That's too many buses."
elsif buses < cars
puts "Maybe we could take the buses."
else
puts "We still can't deci... | Ruby |
i = 0
numbers = []
while i < 6
puts "At the top is #{i}"
numbers.push(i)
i += 1
puts "Numbers now: #{numbers}"
puts "At the botton i is #{i}"
end
puts "The numbers:"
for num in numbers
puts num
end
# while 循环必须到最后为false,不然会一直循环下去,while true ,puts "something", end, 如果一直为真,那么就一直puts "something", 就像取... | Ruby |
require "test/unit"
class Test_Class<Test::Unit::TestCase
def test_creating_hases
empty_hash = Hash.new
assert_equal Hash, empty_hash.class
assert_equal({}, empty_hash)
assert_equal 0, empty_hash.size
end
def test_hash_literals
hash = { :one => "uno", :two => "dos"}
assert_equal 2, hash.s... | Ruby |
require "test/unit"
def triangle(a, b, c)
triangle = if (a == b&&a == c)
:equilateral
elsif (a == b && a != c)
:isosceles
elsif (a == c&&a != b)
:isosceles
elsif (b == c&&a != b)
:isosceles
... | Ruby |
require "test/unit"
C = "top level"
class AboutConstants < Test::Unit::TestCase
C = "nested"
def test_nested_constants_may_also_be_referenced_with_relative_paths
assert_equal "nested", C
end
#单独使用常量时作为绝对路径取值
def test_top_level_constants_are_referenced
assert_equal "top level", ... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.