Method: HDLRuby::Low::Case#initialize

Defined in:
lib/HDLRuby/hruby_low.rb

#initialize(value, default = nil, whens = []) ⇒ Case

Creates a new case statement whose excution flow is decided from +value+ with a possible cases given in +whens+ and +default

  • (can be set later)


2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
# File 'lib/HDLRuby/hruby_low.rb', line 2996

def initialize(value, default = nil, whens = [])
    # Check and set the value.
    unless value.is_a?(Expression)
        raise AnyError, "Invalid class for a value: #{value.class}"
    end
    @value = value
    # And set its parent.
    value.parent = self
    # Checks and set the default case if any.
    self.default = default if default
    # Check and add the whens.
    @whens = []
    whens.each { |w| self.add_when(w) }
end