Class: Estreet::SwitchCase

Inherits:
Node
  • Object
show all
Defined in:
lib/estreet/switch_statement.rb

Instance Attribute Summary

Attributes inherited from Node

#source_location

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#as_json, #loc, #type

Constructor Details

#initialize(test, consequent) ⇒ SwitchCase

Returns a new instance of SwitchCase.



28
29
30
31
# File 'lib/estreet/switch_statement.rb', line 28

def initialize(test, consequent)
  @test = test.to_expression if test
  @consequent = Array(consequent).map {|c| c.to_statement }
end

Class Method Details

.default(consequent) ⇒ Object



33
34
35
# File 'lib/estreet/switch_statement.rb', line 33

def self.default(consequent)
  self.new(nil, consequent)
end

Instance Method Details

#attributesObject



37
38
39
# File 'lib/estreet/switch_statement.rb', line 37

def attributes
  super.merge(test: @test, consequent: @consequent)
end