Change syntax format for example returned values

According to our guideline, we leave 1 space between `#` and `=>`, so we
want `# =>` instead of `#=>`.

Thanks to @fxn for the suggestion.

[ci skip]
This commit is contained in:
Prem Sichanugrist 2013-11-11 13:53:54 -05:00
parent 83271a64f9
commit efff6c1fd4
19 changed files with 107 additions and 107 deletions

View File

@ -384,7 +384,7 @@ module ActionDispatch
# The namespace for :controller.
#
# match 'path', to: 'c#a', module: 'sekret', controller: 'posts'
# #=> Sekret::PostsController
# # => Sekret::PostsController
#
# See <tt>Scoping#namespace</tt> for its scope equivalent.
#

View File

@ -262,10 +262,10 @@ module ActiveModel
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.singular_route_key(Blog::Post) #=> "post"
# ActiveModel::Naming.singular_route_key(Blog::Post) # => "post"
#
# # For shared engine:
# ActiveModel::Naming.singular_route_key(Blog::Post) #=> "blog_post"
# ActiveModel::Naming.singular_route_key(Blog::Post) # => "blog_post"
def self.singular_route_key(record_or_class)
model_name_from_record_or_class(record_or_class).singular_route_key
end
@ -274,10 +274,10 @@ module ActiveModel
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.route_key(Blog::Post) #=> "posts"
# ActiveModel::Naming.route_key(Blog::Post) # => "posts"
#
# # For shared engine:
# ActiveModel::Naming.route_key(Blog::Post) #=> "blog_posts"
# ActiveModel::Naming.route_key(Blog::Post) # => "blog_posts"
#
# The route key also considers if the noun is uncountable and, in
# such cases, automatically appends _index.
@ -289,10 +289,10 @@ module ActiveModel
# namespaced models regarding whether it's inside isolated engine.
#
# # For isolated engine:
# ActiveModel::Naming.param_key(Blog::Post) #=> "post"
# ActiveModel::Naming.param_key(Blog::Post) # => "post"
#
# # For shared engine:
# ActiveModel::Naming.param_key(Blog::Post) #=> "blog_post"
# ActiveModel::Naming.param_key(Blog::Post) # => "blog_post"
def self.param_key(record_or_class)
model_name_from_record_or_class(record_or_class).param_key
end

View File

@ -787,12 +787,12 @@ module ActiveRecord
# has_many :pets
# end
#
# person.pets.count #=> 1
# person.pets.many? #=> false
# person.pets.count # => 1
# person.pets.many? # => false
#
# person.pets << Pet.new(name: 'Snoopy')
# person.pets.count #=> 2
# person.pets.many? #=> true
# person.pets.count # => 2
# person.pets.many? # => true
#
# You can also pass a block to define criteria. The
# behavior is the same, it returns true if the collection

View File

@ -83,14 +83,14 @@ module ActiveRecord
# end
#
# If I execute `@physician.patients.to_a` then
# base #=> Physician
# associations #=> []
# joins #=> [#<Arel::Nodes::InnerJoin: ...]
# base # => Physician
# associations # => []
# joins # => [#<Arel::Nodes::InnerJoin: ...]
#
# However if I execute `Physician.joins(:appointments).to_a` then
# base #=> Physician
# associations #=> [:appointments]
# joins #=> []
# base # => Physician
# associations # => [:appointments]
# joins # => []
#
def initialize(base, associations, joins)
@alias_tracker = AliasTracker.new(base.connection, joins)

View File

@ -86,11 +86,11 @@ module ActiveRecord
# end
#
# If I execute `Physician.joins(:appointments).to_a` then
# reflection #=> #<ActiveRecord::Reflection::AssociationReflection @macro=:has_many ...>
# table #=> #<Arel::Table @name="appointments" ...>
# key #=> physician_id
# foreign_table #=> #<Arel::Table @name="physicians" ...>
# foreign_key #=> id
# reflection # => #<ActiveRecord::Reflection::AssociationReflection @macro=:has_many ...>
# table # => #<Arel::Table @name="appointments" ...>
# key # => physician_id
# foreign_table # => #<Arel::Table @name="physicians" ...>
# foreign_key # => id
#
def build_constraint(klass, table, key, foreign_table, foreign_key)
constraint = table[key].eq(foreign_table[foreign_key])

View File

@ -552,9 +552,9 @@ module ActiveRecord
# Allows you to change a previously set where condition for a given attribute, instead of appending to that condition.
#
# Post.where(trashed: true).where(trashed: false) #=> WHERE `trashed` = 1 AND `trashed` = 0
# Post.where(trashed: true).rewhere(trashed: false) #=> WHERE `trashed` = 0
# Post.where(active: true).where(trashed: true).rewhere(trashed: false) #=> WHERE `active` = 1 AND `trashed` = 0
# Post.where(trashed: true).where(trashed: false) # => WHERE `trashed` = 1 AND `trashed` = 0
# Post.where(trashed: true).rewhere(trashed: false) # => WHERE `trashed` = 0
# Post.where(active: true).where(trashed: true).rewhere(trashed: false) # => WHERE `active` = 1 AND `trashed` = 0
#
# This is short-hand for unscope(where: conditions.keys).where(conditions). Note that unlike reorder, we're only unscoping
# the named conditions -- not the entire where statement.
@ -701,7 +701,7 @@ module ActiveRecord
# Specifies table from which the records will be fetched. For example:
#
# Topic.select('title').from('posts')
# #=> SELECT title FROM posts
# # => SELECT title FROM posts
#
# Can accept other relation objects. For example:
#

View File

@ -361,7 +361,7 @@ module ActiveSupport
#
# cache.write("bim", "bam")
# cache.fetch_multi("bim", "boom") {|key| key * 2 }
# #=> ["bam", "boomboom"]
# # => ["bam", "boomboom"]
#
def fetch_multi(*names)
options = names.extract_options!

View File

@ -162,7 +162,7 @@ class Class
# end
# end
#
# Person.class_variable_get("@@hair_colors") #=> [:brown, :black, :blonde, :red]
# Person.class_variable_get("@@hair_colors") # => [:brown, :black, :blonde, :red]
def cattr_accessor(*syms, &blk)
cattr_reader(*syms)
cattr_writer(*syms, &blk)

View File

@ -4,10 +4,10 @@ class Hash
# h1 = { x: { y: [4,5,6] }, z: [7,8,9] }
# h2 = { x: { y: [7,8,9] }, z: 'xyz' }
#
# h1.deep_merge(h2) #=> {x: {y: [7, 8, 9]}, z: "xyz"}
# h2.deep_merge(h1) #=> {x: {y: [4, 5, 6]}, z: [7, 8, 9]}
# h1.deep_merge(h2) # => {x: {y: [7, 8, 9]}, z: "xyz"}
# h2.deep_merge(h1) # => {x: {y: [4, 5, 6]}, z: [7, 8, 9]}
# h1.deep_merge(h2) { |key, old, new| Array.wrap(old) + Array.wrap(new) }
# #=> {:x=>{:y=>[4, 5, 6, 7, 8, 9]}, :z=>[7, 8, 9, "xyz"]}
# # => {:x=>{:y=>[4, 5, 6, 7, 8, 9]}, :z=>[7, 8, 9, "xyz"]}
def deep_merge(other_hash, &block)
dup.deep_merge!(other_hash, &block)
end

View File

@ -27,7 +27,7 @@ class Hash
# hash = { name: 'Rob', age: '28' }
#
# hash.stringify_keys
# #=> { "name" => "Rob", "age" => "28" }
# # => { "name" => "Rob", "age" => "28" }
def stringify_keys
transform_keys{ |key| key.to_s }
end
@ -44,7 +44,7 @@ class Hash
# hash = { 'name' => 'Rob', 'age' => '28' }
#
# hash.symbolize_keys
# #=> { name: "Rob", age: "28" }
# # => { name: "Rob", age: "28" }
def symbolize_keys
transform_keys{ |key| key.to_sym rescue key }
end

View File

@ -1,9 +1,9 @@
class Integer
# Check whether the integer is evenly divisible by the argument.
#
# 0.multiple_of?(0) #=> true
# 6.multiple_of?(5) #=> false
# 10.multiple_of?(2) #=> true
# 0.multiple_of?(0) # => true
# 6.multiple_of?(5) # => false
# 10.multiple_of?(2) # => true
def multiple_of?(number)
number != 0 ? self % number == 0 : zero?
end

View File

@ -8,8 +8,8 @@ class Object
# dup = object.deep_dup
# dup.instance_variable_set(:@a, 1)
#
# object.instance_variable_defined?(:@a) #=> false
# dup.instance_variable_defined?(:@a) #=> true
# object.instance_variable_defined?(:@a) # => false
# dup.instance_variable_defined?(:@a) # => true
def deep_dup
duplicable? ? dup : self
end
@ -22,8 +22,8 @@ class Array
# dup = array.deep_dup
# dup[1][2] = 4
#
# array[1][2] #=> nil
# dup[1][2] #=> 4
# array[1][2] # => nil
# dup[1][2] # => 4
def deep_dup
map { |it| it.deep_dup }
end
@ -36,8 +36,8 @@ class Hash
# dup = hash.deep_dup
# dup[:a][:c] = 'c'
#
# hash[:a][:c] #=> nil
# dup[:a][:c] #=> "c"
# hash[:a][:c] # => nil
# dup[:a][:c] # => "c"
def deep_dup
each_with_object(dup) do |(key, value), hash|
hash[key.deep_dup] = value.deep_dup

View File

@ -8,22 +8,22 @@ class String
# the beginning of the range is greater than the end of the string.
#
# str = "hello"
# str.at(0) #=> "h"
# str.at(1..3) #=> "ell"
# str.at(-2) #=> "l"
# str.at(-2..-1) #=> "lo"
# str.at(5) #=> nil
# str.at(5..-1) #=> ""
# str.at(0) # => "h"
# str.at(1..3) # => "ell"
# str.at(-2) # => "l"
# str.at(-2..-1) # => "lo"
# str.at(5) # => nil
# str.at(5..-1) # => ""
#
# If a Regexp is given, the matching portion of the string is returned.
# If a String is given, that given string is returned if it occurs in
# the string. In both cases, nil is returned if there is no match.
#
# str = "hello"
# str.at(/lo/) #=> "lo"
# str.at(/ol/) #=> nil
# str.at("lo") #=> "lo"
# str.at("ol") #=> nil
# str.at(/lo/) # => "lo"
# str.at(/ol/) # => nil
# str.at("lo") # => "lo"
# str.at("ol") # => nil
def at(position)
self[position]
end
@ -32,15 +32,15 @@ class String
# If the position is negative, it is counted from the end of the string.
#
# str = "hello"
# str.from(0) #=> "hello"
# str.from(3) #=> "lo"
# str.from(-2) #=> "lo"
# str.from(0) # => "hello"
# str.from(3) # => "lo"
# str.from(-2) # => "lo"
#
# You can mix it with +to+ method and do fun things like:
#
# str = "hello"
# str.from(0).to(-1) #=> "hello"
# str.from(1).to(-2) #=> "ell"
# str.from(0).to(-1) # => "hello"
# str.from(1).to(-2) # => "ell"
def from(position)
self[position..-1]
end
@ -49,15 +49,15 @@ class String
# If the position is negative, it is counted from the end of the string.
#
# str = "hello"
# str.to(0) #=> "h"
# str.to(3) #=> "hell"
# str.to(-2) #=> "hell"
# str.to(0) # => "h"
# str.to(3) # => "hell"
# str.to(-2) # => "hell"
#
# You can mix it with +from+ method and do fun things like:
#
# str = "hello"
# str.from(0).to(-1) #=> "hello"
# str.from(1).to(-2) #=> "ell"
# str.from(0).to(-1) # => "hello"
# str.from(1).to(-2) # => "ell"
def to(position)
self[0, position + 1]
end
@ -67,11 +67,11 @@ class String
# given limit is greater than or equal to the string length, returns self.
#
# str = "hello"
# str.first #=> "h"
# str.first(1) #=> "h"
# str.first(2) #=> "he"
# str.first(0) #=> ""
# str.first(6) #=> "hello"
# str.first # => "h"
# str.first(1) # => "h"
# str.first(2) # => "he"
# str.first(0) # => ""
# str.first(6) # => "hello"
def first(limit = 1)
if limit == 0
''
@ -87,11 +87,11 @@ class String
# the given limit is greater than or equal to the string length, returns self.
#
# str = "hello"
# str.last #=> "o"
# str.last(1) #=> "o"
# str.last(2) #=> "lo"
# str.last(0) #=> ""
# str.last(6) #=> "hello"
# str.last # => "o"
# str.last(1) # => "o"
# str.last(2) # => "lo"
# str.last(0) # => ""
# str.last(6) # => "hello"
def last(limit = 1)
if limit == 0
''

View File

@ -36,20 +36,20 @@ class String
# Converts a string to a Date value.
#
# "1-1-2012".to_date #=> Sun, 01 Jan 2012
# "01/01/2012".to_date #=> Sun, 01 Jan 2012
# "2012-12-13".to_date #=> Thu, 13 Dec 2012
# "12/13/2012".to_date #=> ArgumentError: invalid date
# "1-1-2012".to_date # => Sun, 01 Jan 2012
# "01/01/2012".to_date # => Sun, 01 Jan 2012
# "2012-12-13".to_date # => Thu, 13 Dec 2012
# "12/13/2012".to_date # => ArgumentError: invalid date
def to_date
::Date.parse(self, false) unless blank?
end
# Converts a string to a DateTime value.
#
# "1-1-2012".to_datetime #=> Sun, 01 Jan 2012 00:00:00 +0000
# "01/01/2012 23:59:59".to_datetime #=> Sun, 01 Jan 2012 23:59:59 +0000
# "2012-12-13 12:50".to_datetime #=> Thu, 13 Dec 2012 12:50:00 +0000
# "12/13/2012".to_datetime #=> ArgumentError: invalid date
# "1-1-2012".to_datetime # => Sun, 01 Jan 2012 00:00:00 +0000
# "01/01/2012 23:59:59".to_datetime # => Sun, 01 Jan 2012 23:59:59 +0000
# "2012-12-13 12:50".to_datetime # => Thu, 13 Dec 2012 12:50:00 +0000
# "12/13/2012".to_datetime # => ArgumentError: invalid date
def to_datetime
::DateTime.parse(self, false) unless blank?
end

View File

@ -2,9 +2,9 @@ class String
# The inverse of <tt>String#include?</tt>. Returns true if the string
# does not include the other string.
#
# "hello".exclude? "lo" #=> false
# "hello".exclude? "ol" #=> true
# "hello".exclude? ?h #=> false
# "hello".exclude? "lo" # => false
# "hello".exclude? "ol" # => true
# "hello".exclude? ?h # => false
def exclude?(string)
!include?(string)
end

View File

@ -39,8 +39,8 @@ class Thread
# Thread.current.thread_variable_set(:cat, 'meow')
# Thread.current.thread_variable_set("dog", 'woof')
# end
# thr.join #=> #<Thread:0x401b3f10 dead>
# thr.thread_variables #=> [:dog, :cat]
# thr.join # => #<Thread:0x401b3f10 dead>
# thr.thread_variables # => [:dog, :cat]
#
# Note that these are not fiber local variables. Please see Thread#thread_variable_get
# for more details.
@ -53,8 +53,8 @@ class Thread
#
# me = Thread.current
# me.thread_variable_set(:oliver, "a")
# me.thread_variable?(:oliver) #=> true
# me.thread_variable?(:stanley) #=> false
# me.thread_variable?(:oliver) # => true
# me.thread_variable?(:stanley) # => false
#
# Note that these are not fiber local variables. Please see Thread#thread_variable_get
# for more details.

View File

@ -207,7 +207,7 @@ module ActiveSupport
# Replaces the contents of this hash with other_hash.
#
# h = { "a" => 100, "b" => 200 }
# h.replace({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}
# h.replace({ "c" => 300, "d" => 400 }) # => {"c"=>300, "d"=>400}
def replace(other_hash)
super(self.class.new_from_hash_copying_default(other_hash))
end

View File

@ -52,21 +52,21 @@ module ActiveSupport
# into a non-delimited single lowercase word when passed to +underscore+.
#
# acronym 'HTML'
# titleize 'html' #=> 'HTML'
# camelize 'html' #=> 'HTML'
# underscore 'MyHTML' #=> 'my_html'
# titleize 'html' # => 'HTML'
# camelize 'html' # => 'HTML'
# underscore 'MyHTML' # => 'my_html'
#
# The acronym, however, must occur as a delimited unit and not be part of
# another word for conversions to recognize it:
#
# acronym 'HTTP'
# camelize 'my_http_delimited' #=> 'MyHTTPDelimited'
# camelize 'https' #=> 'Https', not 'HTTPs'
# underscore 'HTTPS' #=> 'http_s', not 'https'
# camelize 'my_http_delimited' # => 'MyHTTPDelimited'
# camelize 'https' # => 'Https', not 'HTTPs'
# underscore 'HTTPS' # => 'http_s', not 'https'
#
# acronym 'HTTPS'
# camelize 'https' #=> 'HTTPS'
# underscore 'HTTPS' #=> 'https'
# camelize 'https' # => 'HTTPS'
# underscore 'HTTPS' # => 'https'
#
# Note: Acronyms that are passed to +pluralize+ will no longer be
# recognized, since the acronym will not occur as a delimited unit in the
@ -74,25 +74,25 @@ module ActiveSupport
# form as an acronym as well:
#
# acronym 'API'
# camelize(pluralize('api')) #=> 'Apis'
# camelize(pluralize('api')) # => 'Apis'
#
# acronym 'APIs'
# camelize(pluralize('api')) #=> 'APIs'
# camelize(pluralize('api')) # => 'APIs'
#
# +acronym+ may be used to specify any word that contains an acronym or
# otherwise needs to maintain a non-standard capitalization. The only
# restriction is that the word must begin with a capital letter.
#
# acronym 'RESTful'
# underscore 'RESTful' #=> 'restful'
# underscore 'RESTfulController' #=> 'restful_controller'
# titleize 'RESTfulController' #=> 'RESTful Controller'
# camelize 'restful' #=> 'RESTful'
# camelize 'restful_controller' #=> 'RESTfulController'
# underscore 'RESTful' # => 'restful'
# underscore 'RESTfulController' # => 'restful_controller'
# titleize 'RESTfulController' # => 'RESTful Controller'
# camelize 'restful' # => 'RESTful'
# camelize 'restful_controller' # => 'RESTfulController'
#
# acronym 'McDonald'
# underscore 'McDonald' #=> 'mcdonald'
# camelize 'mcdonald' #=> 'McDonald'
# underscore 'McDonald' # => 'mcdonald'
# camelize 'mcdonald' # => 'McDonald'
def acronym(word)
@acronyms[word.downcase] = word
@acronym_regex = /#{@acronyms.values.join("|")}/

View File

@ -260,7 +260,7 @@ module Rails
#
# class FooController < ApplicationController
# def index
# my_engine.root_url #=> /my_engine/
# my_engine.root_url # => /my_engine/
# end
# end
#
@ -269,7 +269,7 @@ module Rails
# module MyEngine
# class BarController
# def index
# main_app.foo_path #=> /foo
# main_app.foo_path # => /foo
# end
# end
# end