Class: Rubinius::AST::Case
- Defined in:
- lib/compiler/ast/control_flow.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#else ⇒ Object
Returns the value of attribute else.
-
#whens ⇒ Object
Returns the value of attribute whens.
Attributes inherited from Node
Instance Method Summary collapse
-
#initialize(line, whens, else_body) ⇒ Case
constructor
A new instance of Case.
- #receiver_sexp ⇒ Object
- #to_sexp ⇒ Object
Methods inherited from Node
#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk
Constructor Details
#initialize(line, whens, else_body) ⇒ Case
Returns a new instance of Case.
8 9 10 11 12 |
# File 'lib/compiler/ast/control_flow.rb', line 8 def initialize(line, whens, else_body) @line = line @whens = whens @else = else_body || NilLiteral.new(line) end |
Instance Attribute Details
#else ⇒ Object
Returns the value of attribute else.
6 7 8 |
# File 'lib/compiler/ast/control_flow.rb', line 6 def else @else end |
#whens ⇒ Object
Returns the value of attribute whens.
6 7 8 |
# File 'lib/compiler/ast/control_flow.rb', line 6 def whens @whens end |
Instance Method Details
#receiver_sexp ⇒ Object
14 15 16 |
# File 'lib/compiler/ast/control_flow.rb', line 14 def receiver_sexp nil end |
#to_sexp ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/compiler/ast/control_flow.rb', line 18 def to_sexp else_sexp = @else.kind_of?(NilLiteral) ? nil : @else.to_sexp sexp = [:case, receiver_sexp] sexp << [:whens] + @whens.map { |x| x.to_sexp } sexp << else_sexp sexp end |