Class: Simp::Metadata::Components
- Inherits:
-
Object
- Object
- Simp::Metadata::Components
- Includes:
- Enumerable
- Defined in:
- lib/simp/metadata/components.rb
Instance Attribute Summary collapse
-
#engine ⇒ Object
Returns the value of attribute engine.
-
#type ⇒ Object
Returns the value of attribute type.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #create(name, settings = {}) ⇒ Object
- #each ⇒ Object
-
#initialize(engine, version = nil, type = nil) ⇒ Components
constructor
A new instance of Components.
- #key?(name) ⇒ Boolean
- #keys ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(engine, version = nil, type = nil) ⇒ Components
Returns a new instance of Components.
9 10 11 12 13 |
# File 'lib/simp/metadata/components.rb', line 9 def initialize(engine, version = nil, type = nil) @engine = engine @version = version @type = type end |
Instance Attribute Details
#engine ⇒ Object
Returns the value of attribute engine.
5 6 7 |
# File 'lib/simp/metadata/components.rb', line 5 def engine @engine end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/simp/metadata/components.rb', line 7 def type @type end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/simp/metadata/components.rb', line 6 def version @version end |
Instance Method Details
#[](index) ⇒ Object
29 30 31 |
# File 'lib/simp/metadata/components.rb', line 29 def [](index) Simp::Metadata::Component.new(engine, index, version) end |
#create(name, settings = {}) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/simp/metadata/components.rb', line 61 def create(name, settings = {}) unless key?(name) engine.writable_source.components[name] = settings engine.writable_source.dirty = true end end |
#each ⇒ Object
23 24 25 26 27 |
# File 'lib/simp/metadata/components.rb', line 23 def each keys.each do |version| yield self[version] end end |
#key?(name) ⇒ Boolean
33 34 35 |
# File 'lib/simp/metadata/components.rb', line 33 def key?(name) keys.include?(name) end |
#keys ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/simp/metadata/components.rb', line 37 def keys result = {} if version.nil? engine.sources.each do |_name, source| source.components.keys.each do |name| result[name] = true end end else engine.sources.each do |_name, source| if source.releases.key?(version) source.releases[version].each do |component, _data| result[component] = true end else source.release(version).each do |component, _data| result[component] = true end end end end result.keys end |
#size ⇒ Object
19 20 21 |
# File 'lib/simp/metadata/components.rb', line 19 def size keys.size end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/simp/metadata/components.rb', line 15 def to_s keys.to_s end |