Class: PortfolioInstance::InScopeExtensionParameter
- Inherits:
-
Object
- Object
- PortfolioInstance::InScopeExtensionParameter
- Defined in:
- lib/arch_obj_models/portfolio.rb
Overview
Holds extension parameter information from the portfolio.
Instance Attribute Summary collapse
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#param ⇒ Object
readonly
ExtensionParameter object (from the architecture database).
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
sorts by name.
-
#allowed_values ⇒ String
-
# What parameter values are allowed by the portfolio.
-
- #idl_type ⇒ Object
-
#initialize(param, schema_hash, note) ⇒ InScopeExtensionParameter
constructor
A new instance of InScopeExtensionParameter.
- #name ⇒ Object
- #single_value? ⇒ Boolean
- #value ⇒ Object
Constructor Details
#initialize(param, schema_hash, note) ⇒ InScopeExtensionParameter
Returns a new instance of InScopeExtensionParameter.
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
#note ⇒ Object (readonly)
Returns the value of attribute note.
213 214 215 |
# File 'lib/arch_obj_models/portfolio.rb', line 213 def note @note end |
#param ⇒ Object (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
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_values ⇒ String
Returns - # 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_type ⇒ Object
230 |
# File 'lib/arch_obj_models/portfolio.rb', line 230 def idl_type = @param.type |
#name ⇒ Object
229 |
# File 'lib/arch_obj_models/portfolio.rb', line 229 def name = @param.name |
#single_value? ⇒ Boolean
231 |
# File 'lib/arch_obj_models/portfolio.rb', line 231 def single_value? = @schema_portfolio.single_value? |
#value ⇒ Object
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 |