Class: Loom::Pattern::ReferenceSet
- Inherits:
-
Object
- Object
- Loom::Pattern::ReferenceSet
- Defined in:
- lib/loom/pattern/reference_set.rb
Overview
A collection of Pattern::Reference objects
Defined Under Namespace
Classes: Builder
Class Method Summary collapse
Instance Method Summary collapse
- #add_pattern_refs(refs) ⇒ Object
- #get_pattern_ref(slug) ⇒ Object (also: #[])
-
#initialize ⇒ ReferenceSet
constructor
A new instance of ReferenceSet.
- #merge!(ref_set) ⇒ Object
- #pattern_refs ⇒ Object
- #slugs ⇒ Object
Constructor Details
#initialize ⇒ ReferenceSet
Returns a new instance of ReferenceSet.
30 31 32 |
# File 'lib/loom/pattern/reference_set.rb', line 30 def initialize @slug_to_ref_map = {} end |
Class Method Details
Instance Method Details
#add_pattern_refs(refs) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/loom/pattern/reference_set.rb', line 53 def add_pattern_refs(refs) refs.each do |ref| Loom.log.debug2(self) { "adding ref to set => #{ref.slug}" } raise DuplicatePatternRef, ref.slug if @slug_to_ref_map[ref.slug] @slug_to_ref_map[ref.slug] = ref end end |
#get_pattern_ref(slug) ⇒ Object Also known as: []
42 43 44 45 46 |
# File 'lib/loom/pattern/reference_set.rb', line 42 def get_pattern_ref(slug) ref = @slug_to_ref_map[slug] raise NoReferenceForSlug, slug unless ref ref end |
#merge!(ref_set) ⇒ Object
49 50 51 |
# File 'lib/loom/pattern/reference_set.rb', line 49 def merge!(ref_set) add_pattern_refs(ref_set.pattern_refs) end |
#pattern_refs ⇒ Object
38 39 40 |
# File 'lib/loom/pattern/reference_set.rb', line 38 def pattern_refs @slug_to_ref_map.values end |
#slugs ⇒ Object
34 35 36 |
# File 'lib/loom/pattern/reference_set.rb', line 34 def slugs @slug_to_ref_map.keys end |