Class: PortfolioInstance::InScopeExtensionParameter

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

Overview

Holds extension parameter information from the portfolio.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, schema_hash, note) ⇒ InScopeExtensionParameter

Returns a new instance of InScopeExtensionParameter.

Raises:

  • (ArgumentError)


215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/arch_obj_models/portfolio.rb', line 215

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

  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

#noteObject (readonly)

Returns the value of attribute note.



213
214
215
# File 'lib/arch_obj_models/portfolio.rb', line 213

def note
  @note
end

#paramObject (readonly)

ExtensionParameter object (from the architecture database)



212
213
214
# File 'lib/arch_obj_models/portfolio.rb', line 212

def param
  @param
end

Instance Method Details

#<=>(other) ⇒ Object

sorts by name

Raises:

  • (ArgumentError)


255
256
257
258
259
# File 'lib/arch_obj_models/portfolio.rb', line 255

def <=>(other)
  raise ArgumentError,
    "InScopeExtensionParameter are only comparable to other parameter constraints" unless other.is_a?(InScopeExtensionParameter)
  @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.



240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/arch_obj_models/portfolio.rb', line 240

def allowed_values
  if (@schema_portfolio.empty?)
    # PortfolioInstance 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



230
# File 'lib/arch_obj_models/portfolio.rb', line 230

def idl_type = @param.type

#nameObject



229
# File 'lib/arch_obj_models/portfolio.rb', line 229

def name = @param.name

#single_value?Boolean

Returns:

  • (Boolean)


231
# File 'lib/arch_obj_models/portfolio.rb', line 231

def single_value? = @schema_portfolio.single_value?

#valueObject



233
234
235
236
237
# File 'lib/arch_obj_models/portfolio.rb', line 233

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

  @schema_portfolio.value
end