Class: Chelsy::Declaration
- Inherits:
-
Declarative
- Object
- Node
- Element
- Declarative
- Chelsy::Declaration
- Defined in:
- lib/chelsy/ast.rb
Overview
6.7 Declarations
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Declarative
Attributes inherited from Element
Instance Method Summary collapse
- #init ⇒ Object
-
#initialize(name, type, init = nil, **rest) ⇒ Declaration
constructor
A new instance of Declaration.
Methods inherited from Declarative
Constructor Details
#initialize(name, type, init = nil, **rest) ⇒ Declaration
Returns a new instance of Declaration.
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
# File 'lib/chelsy/ast.rb', line 1105 def initialize(name, type, init=nil, **rest) @name = Syntax::Ident.ensure(name) @type = Syntax::Type.ensure(type) @init = case init when nil nil when Enumerable InitializerList.new(init) else Syntax::Expr.ensure(init) end super(**rest) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
1103 1104 1105 |
# File 'lib/chelsy/ast.rb', line 1103 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
1103 1104 1105 |
# File 'lib/chelsy/ast.rb', line 1103 def type @type end |
Instance Method Details
#init ⇒ Object
1120 |
# File 'lib/chelsy/ast.rb', line 1120 def init; @init end |