Class: Udb::Portfolio::InScopeParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/udb/obj/portfolio.rb

Overview

InScopeParameter Class #

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, schema_hash, note) ⇒ InScopeParameter

Returns a new instance of InScopeParameter.

Raises:

  • (ArgumentError)


839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/udb/obj/portfolio.rb', line 839

def initialize(param, schema_hash, note)
  raise ArgumentError, "Expecting Parameter" unless param.is_a?(Parameter)

  if schema_hash.nil?
    schema_hash = {}
  else
    raise ArgumentError, "Expecting schema_hash to be a hash" unless schema_hash.is_a?(Hash)
  end

  @param = param
  @schema_portfolio = Schema.new(schema_hash)
  @note = note
end

Instance Attribute Details

#noteString (readonly)

Returns Optional note associated with the parameter.

Returns:

  • (String)

    Optional note associated with the parameter



837
838
839
# File 'lib/udb/obj/portfolio.rb', line 837

def note
  @note
end

#paramParameter (readonly)

Returns Parameter object (from the architecture database).

Returns:

  • (Parameter)

    Parameter object (from the architecture database)



834
835
836
# File 'lib/udb/obj/portfolio.rb', line 834

def param
  @param
end

Instance Method Details

#<=>(other) ⇒ Object

sorts by name

Raises:

  • (ArgumentError)


879
880
881
882
883
# File 'lib/udb/obj/portfolio.rb', line 879

def <=>(other)
  raise ArgumentError,
    "InScopeParameter are only comparable to other parameter constraints" unless other.is_a?(InScopeParameter)
  @param.name <=> other.param.name
end

#allowed_valuesString

Returns - # What parameter values are allowed by the portfolio.

Returns:

  • (String)
    • # What parameter values are allowed by the portfolio.



864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/udb/obj/portfolio.rb', line 864

def allowed_values
  if (@schema_portfolio.empty?)
    # Portfolio doesn't add any constraints on parameter's value.
    return "Any"
  end

  # Create a Schema object just using information in the parameter database.
  schema_obj = @param.schema

  # Merge in constraints imposed by the portfolio on the parameter and then
  # create string showing allowed values of parameter with portfolio constraints added.
  schema_obj.merge(@schema_portfolio).to_pretty_s
end

#idl_typeObject



854
# File 'lib/udb/obj/portfolio.rb', line 854

def idl_type = @param.type

#nameObject



853
# File 'lib/udb/obj/portfolio.rb', line 853

def name = @param.name

#single_value?Boolean

Returns:

  • (Boolean)


855
# File 'lib/udb/obj/portfolio.rb', line 855

def single_value? = @schema_portfolio.single_value?

#valueObject



857
858
859
860
861
# File 'lib/udb/obj/portfolio.rb', line 857

def value
  raise "Parameter schema_portfolio for #{name} is not a single value" unless single_value?

  @schema_portfolio.value
end