class SoberSwag::Nodes::Enum
Compiler
node to represent an enum value. Enums are special enough to have their own node, as they are basically a constant list of always-string values.
Attributes
values[R]
@return [Array<Symbol,String>] values of the enum.
Public Class Methods
new(values)
click to toggle source
# File lib/sober_swag/nodes/enum.rb, line 7 def initialize(values) @values = values end
Public Instance Methods
cata(&block)
click to toggle source
@see SoberSwag::Nodes::Base#cata
# File lib/sober_swag/nodes/enum.rb, line 40 def cata(&block) block.call(dup) end
deconstruct()
click to toggle source
Deconstructs into the enum values.
@return [Array(Array
<Symbol,String>)] the cases of the enum.
# File lib/sober_swag/nodes/enum.rb, line 27 def deconstruct [values] end
deconstruct_keys(_keys)
click to toggle source
@return [Hash{Symbol => Array
<Symbol,String>}]
the values, wrapped in a `values:` key.
# File lib/sober_swag/nodes/enum.rb, line 34 def deconstruct_keys(_keys) { values: values } end
map()
click to toggle source
Since there is nothing to map over, this node will never actually call the block given.
@see SoberSwag::Nodes::Base#map
# File lib/sober_swag/nodes/enum.rb, line 19 def map dup end