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)


722
723
724
725
726
727
728
729
730
731
732
733
734
# File 'lib/udb/obj/portfolio.rb', line 722

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



720
721
722
# File 'lib/udb/obj/portfolio.rb', line 720

def note
  @note
end

#paramParameter (readonly)

Returns Parameter object (from the architecture database).

Returns:

  • (Parameter)

    Parameter object (from the architecture database)



717
718
719
# File 'lib/udb/obj/portfolio.rb', line 717

def param
  @param
end

Instance Method Details

#<=>(other) ⇒ Object

sorts by name

Raises:

  • (ArgumentError)


762
763
764
765
766
# File 'lib/udb/obj/portfolio.rb', line 762

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.



747
748
749
750
751
752
753
754
755
756
757
758
759
# File 'lib/udb/obj/portfolio.rb', line 747

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



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

def idl_type = @param.type

#nameObject



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

def name = @param.name

#single_value?Boolean

Returns:

  • (Boolean)


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

def single_value? = @schema_portfolio.single_value?

#valueObject



740
741
742
743
744
# File 'lib/udb/obj/portfolio.rb', line 740

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

  @schema_portfolio.value
end