Class: Rave::Models::Wave

Inherits:
Component show all
Defined in:
lib/models/wave.rb

Overview

Represents a Wave

Constant Summary

Constants inherited from Component

Component::GENERATED_PATTERN, Component::GENERATED_PREFIX

Instance Attribute Summary

Attributes inherited from Component

#context

Instance Method Summary collapse

Methods inherited from Component

#generated?, #id, #to_s, #unique_id

Methods included from Rave::Mixins::Logger

#logger

Constructor Details

#initialize(options = {}) ⇒ Wave

Options include:

  • :wavelet_ids

  • :id



13
14
15
16
17
18
19
20
21
# File 'lib/models/wave.rb', line 13

def initialize(options = {}) # :nodoc:
  if options[:id].nil? and options[:context]
    super(:id => "#{GENERATED_PREFIX}_wave_#{unique_id}", :context => options[:context])
  else
    super(options)
  end

  @wavelet_ids = options[:wavelet_ids] || []
end

Instance Method Details

:nodoc:



33
34
35
36
37
38
39
40
41
42
# File 'lib/models/wave.rb', line 33

def print_structure(indent = 0) # :nodoc:
  str = ''
  str << "#{'  ' * indent}Wave:#{@id}\n"

  wavelets.each do |wavelet|
    str << wavelet.print_structure(indent + 1)
  end

  str
end

#root_waveletObject

The root wavelet (it will be nil if the event refers to a private subwavelet) [Wavelet]



29
30
31
# File 'lib/models/wave.rb', line 29

def root_wavelet # :nodoc:
  wavelets.find { |wavelet| wavelet and wavelet.root? }
end

#wavelet_idsObject

IDs for all wavelets that are part of the wave [Array of String]



6
7
8
# File 'lib/models/wave.rb', line 6

def wavelet_ids # :nodoc:
  @wavelet_ids.map { |id| id.dup }
end

#waveletsObject

All wavelets that are part of the wave [Array of Wavelet]



24
25
26
# File 'lib/models/wave.rb', line 24

def wavelets # :nodoc:
  @wavelet_ids.map { |id| @context.wavelets[id] }
end