Permalink
Browse files

Minor formatting fixes for code comments

  • Loading branch information...
1 parent 73221af commit c1cb306ed7fa2d3345f296d57e49afa079878184 @dkubb dkubb committed Jul 8, 2011
View
@@ -25,20 +25,20 @@ attributes that require typecasting and/or validations.
end
# setting attributes in the constructor
- user = User.new(:age => 28)
+ user = User.new(:name => 'Piotr', :age => 28)
# attribute readers
- user.name # => "Piotr"
+ user.name # => "Piotr"
# hash of attributes
- user.attributes # => { :name => "Piotr" }
+ user.attributes # => { :name => "Piotr" }
# automatic typecasting
user.age = '28'
- user.age # => 28
+ user.age # => 28
user.birthday = 'November 18th, 1983'
- user.birthday # => #<DateTime: 1983-11-18T00:00:00+00:00 (4891313/2,0/1,2299161)>
+ user.birthday # => #<DateTime: 1983-11-18T00:00:00+00:00 (4891313/2,0/1,2299161)>
## Custom Attributes
@@ -65,8 +65,8 @@ attributes that require typecasting and/or validations.
user = MyApp::User.new
- user.info = '{"email" : "john@domain.com" }'
- user.info # => {"email"=>"john@domain.com"}
+ user.info = '{"email":"john@domain.com"}'
+ user.info # => {"email"=>"john@domain.com"}
## Note on Patches/Pull Requests
View
@@ -9,7 +9,7 @@ class Attribute
# Returns a Virtus::Attribute::Object descendant based on a name or class
#
# @example
- # Attribute.determine_type('String') # => Virtus::Attribute::String
+ # Attribute.determine_type('String') # => Virtus::Attribute::String
#
# @param [Class, #to_s] class_or_name
# name of a class or a class itself
@@ -188,7 +188,7 @@ def self.inherited(descendant)
# Returns if the given value's class is an attribute's primitive
#
# @example
- # Virtus::Attribute::String.primitive?('String') # => true
+ # Virtus::Attribute::String.primitive?('String') # => true
#
# @return [Boolean]
#
@@ -200,7 +200,7 @@ def self.primitive?(value)
# Returns name of the attribute
#
# @example
- # User.attributes[:age].name # => :age
+ # User.attributes[:age].name # => :age
#
# @return [Symbol]
#
@@ -263,8 +263,8 @@ def initialize(name, options = {})
# Returns if an attribute is a complex one
#
# @example
- # Virtus::Attribute::String.complex? # => false
- # Virtus::Attribute::Array.complex? # => true
+ # Virtus::Attribute::String.complex? # => false
+ # Virtus::Attribute::Array.complex? # => true
#
# @return [Boolean]
#
@@ -13,18 +13,18 @@ class Attribute
# end
#
# post = Post.new(:published => false)
- # post.published? # => false
+ # post.published? # => false
#
class Boolean < Object
primitive TrueClass
# Returns if the given value is either true or false
#
# @example
- # Virtus::Attribute::Boolean.primitive?(true) # => true
- # Virtus::Attribute::Boolean.primitive?(false) # => true
- # Virtus::Attribute::Boolean.primitive?(1) # => false
- # Virtus::Attribute::Boolean.primitive?('true') # => false
+ # Virtus::Attribute::Boolean.primitive?(true) # => true
+ # Virtus::Attribute::Boolean.primitive?(false) # => true
+ # Virtus::Attribute::Boolean.primitive?(1) # => false
+ # Virtus::Attribute::Boolean.primitive?('true') # => false
#
# @return [Boolean]
#
@@ -49,7 +49,7 @@ def attribute(name, type, options = {})
# attribute :age, Integer
# end
#
- # User.attributes # =>
+ # User.attributes # => { name_attribute, age_attribute }
#
# TODO: implement inspect so the output is not cluttered - solnic
#
@@ -25,7 +25,7 @@ def initialize(attributes = {})
# end
#
# user = User.new(:name => 'John')
- # user[:name] # => "john"
+ # user[:name] # => "John"
#
# @param [Symbol] name
# a name of an attribute
@@ -48,8 +48,8 @@ def [](name)
# end
#
# user = User.new
- # user[:name] = "john" # => "john"
- # user.name # => "john"
+ # user[:name] = "John" # => "John"
+ # user.name # => "John"
#
# @param [Symbol] name
# a name of an attribute
@@ -76,7 +76,7 @@ def []=(name, value)
# end
#
# user = User.new(:name => 'John', :age => 28)
- # user.attributes # => { :name => 'John', :age => 28 }
+ # user.attributes # => { :name => 'John', :age => 28 }
#
# @return [Hash]
# the attributes
@@ -12,8 +12,8 @@ class Boolean
# Typecast value to TrueClass or FalseClass
#
# @example
- # Virtus::Typecast::Boolean.call('T') # => true
- # Virtus::Typecast::Boolean.call('F') # => false
+ # Virtus::Typecast::Boolean.call('T') # => true
+ # Virtus::Typecast::Boolean.call('F') # => false
#
# @param [Integer, String]
#
@@ -9,8 +9,8 @@ class Numeric
# Typecast value to integer
#
# @example
- # Virtus::Typecast::Numeric.to_i('1') # => 1
- # Virtus::Typecast::Numeric.to_i(1.2) # => 1
+ # Virtus::Typecast::Numeric.to_i('1') # => 1
+ # Virtus::Typecast::Numeric.to_i(1.2) # => 1
#
# @param [Object] value
#
@@ -24,8 +24,8 @@ def self.to_i(value)
# Typecast value to float
#
# @example
- # Virtus::Typecast::Numeric.to_f('1.2') # => 1.2
- # Virtus::Typecast::Numeric.to_f(1) # => 1.0
+ # Virtus::Typecast::Numeric.to_f('1.2') # => 1.2
+ # Virtus::Typecast::Numeric.to_f(1) # => 1.0
#
# @param [Object] value
#
@@ -39,8 +39,8 @@ def self.to_f(value)
# Typecast value to decimal
#
# @example
- # Virtus::Typecast::Numeric.to_d('1.2') # => #<BigDecimal:b72157d4,'0.12E1',8(8)>
- # Virtus::Typecast::Numeric.to_d(1) # => #<BigDecimal:b7212e08,'0.1E1',4(8)>
+ # Virtus::Typecast::Numeric.to_d('1.2') # => #<BigDecimal:b72157d4,'0.12E1',8(8)>
+ # Virtus::Typecast::Numeric.to_d(1) # => #<BigDecimal:b7212e08,'0.1E1',4(8)>
#
# @param [Object] value
#
@@ -7,8 +7,8 @@ class String
# Typecast value to a string
#
# @example
- # Virtus::Typecast::String.call(1) # => '1'
- # Virtus::Typecast::String.call([]) # => '[]'
+ # Virtus::Typecast::String.call(1) # => "1"
+ # Virtus::Typecast::String.call([]) # => "[]"
#
# @param [Object] value
#

0 comments on commit c1cb306

Please sign in to comment.