1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/ostruct.rb: Simplify and fix rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
marcandre 2012-02-15 03:31:30 +00:00
parent 8b4b4032f7
commit 3281b90ecb

View file

@ -30,12 +30,6 @@
# An OpenStruct employs a Hash internally to store the methods and values and # An OpenStruct employs a Hash internally to store the methods and values and
# can even be initialized with one: # can even be initialized with one:
# #
# country_data = { :country => "Australia", :population => 20_000_000 }
# australia = OpenStruct.new(country_data)
# p australia # -> <OpenStruct country="Australia" population=20000000>
#
# You may also define the hash in the initialization call:
#
# australia = OpenStruct.new(:country => "Australia", :population => 20_000_000) # australia = OpenStruct.new(:country => "Australia", :population => 20_000_000)
# p australia # -> <OpenStruct country="Australia" population=20000000> # p australia # -> <OpenStruct country="Australia" population=20000000>
# #
@ -89,12 +83,6 @@ class OpenStruct
# #
# p data # -> <OpenStruct country="Australia" population=20000000> # p data # -> <OpenStruct country="Australia" population=20000000>
# #
# You may also define the hash in the initialization call:
#
# australia = OpenStruct.new(:country => "Australia",
# :population => 20_000_000)
# p australia # -> <OpenStruct country="Australia" population=20000000>
#
def initialize(hash=nil) def initialize(hash=nil)
@table = {} @table = {}
if hash if hash
@ -146,7 +134,7 @@ class OpenStruct
# #
# #modifiable is used internally to check if the OpenStruct is able to be # #modifiable is used internally to check if the OpenStruct is able to be
# modified before granting access to the internal Hash table to be augmented. # modified before granting access to the internal Hash table to be modified.
# #
def modifiable def modifiable
begin begin
@ -190,8 +178,8 @@ class OpenStruct
end end
# #
# Remove the named field from the object. Returning the value that the field # Remove the named field from the object. Returns the value that the field
# contained if it has defined. # contained if it was defined.
# #
# require 'ostruct' # require 'ostruct'
# #