Class: Chelsy::Switch
Overview
=== 6.8.4.2 Theswitchstatement
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
Returns the value of attribute expr.
-
#stmt ⇒ Object
readonly
Returns the value of attribute stmt.
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(expr, stmt = nil, **rest, &block) ⇒ Switch
constructor
A new instance of Switch.
Constructor Details
#initialize(expr, stmt = nil, **rest, &block) ⇒ Switch
Returns a new instance of Switch.
985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
# File 'lib/chelsy/ast.rb', line 985 def initialize(expr, stmt=nil, **rest, &block) @expr = Syntax::Expr.ensure(expr) if stmt @stmt = Syntax::Stmt.ensure(stmt) elsif block @stmt = Block.new block.call(@stmt) else raise ArgumentError, "missing body statement" end super **rest end |
Instance Attribute Details
#expr ⇒ Object (readonly)
Returns the value of attribute expr.
983 984 985 |
# File 'lib/chelsy/ast.rb', line 983 def expr @expr end |
#stmt ⇒ Object (readonly)
Returns the value of attribute stmt.
983 984 985 |
# File 'lib/chelsy/ast.rb', line 983 def stmt @stmt end |