Created
November 25, 2011 08:31
-
-
Save ayasuda/1393054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hoge | |
attr_accessor :a | |
attr_accessor :b | |
def initialize(initialize_options = {}) | |
defaults = { | |
:a => "aaaa", | |
:b => "bbbb" | |
} | |
defaults.merge!(initialize_options) | |
defaults.each do |k ,v| | |
send((k.to_s + "="), v) | |
end | |
end | |
end | |
hoge = Hoge.new(:a=>"AAAA") | |
hoge.a #=> AAAA | |
hoge.b #=> bbbb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment