LICENSE: Public Domain AUTHOR: ne_Sachirou <utakata.c4se@gmail.com> DATE: 2013-09-23
Install
gem install auto_attr_init
From RubyGems.org/auto_attr_init
AutoAttrInit
Dart and CoffeeScript like "automatic field initialization" in Ruby.
Dart has automatic field initialization.
class Point {
num x, y;
Point(this.x, this.y);
}
CoffeeScript has a same function.
class Point
constructor: (@x, @y) ->
With this gem, you can do like this.
class Point
def initialize x, y; end
attr_reader :x, :y
auto_attr_init
end
Or like this.
class Point
def initialize @x, @y; end
attr_reader :x, :y
end
cf. Idiomatic Dart | Dart: Structured web apps Dart's "automatic field initialization".
cf. CoffeeScript Classes, Inheritance, and Super CoffeeScript has same function.
cf. Dart風のautomatic field initializationをRubyで - c4se記:さっちゃんですよ☆ My blog entry.