Class: Opencdd::EffectiveProperties
- Inherits:
-
Object
- Object
- Opencdd::EffectiveProperties
- Defined in:
- lib/opencdd/effective_properties.rb
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #codes_for(klass) ⇒ Object
- #for(klass) ⇒ Object
-
#initialize(database) ⇒ EffectiveProperties
constructor
A new instance of EffectiveProperties.
Constructor Details
#initialize(database) ⇒ EffectiveProperties
Returns a new instance of EffectiveProperties.
40 41 42 |
# File 'lib/opencdd/effective_properties.rb', line 40 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
38 39 40 |
# File 'lib/opencdd/effective_properties.rb', line 38 def database @database end |
Instance Method Details
#codes_for(klass) ⇒ Object
53 54 55 56 |
# File 'lib/opencdd/effective_properties.rb', line 53 def codes_for(klass) result = self.for(klass) result.properties.map(&:code) end |
#for(klass) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/opencdd/effective_properties.rb', line 44 def for(klass) k = resolve_klass(klass) return Result.new(properties: [], sources: {}) unless k acc = [] sources = Hash.new { |h, kk| h[kk] = [] } accumulate(k, Set.new, acc, sources) Result.new(properties: acc.uniq { |p| p.irdi }, sources: sources) end |