Class: Docks::Containers::Demo

Inherits:
Object
  • Object
show all
Defined in:
lib/docks/containers/demo_container.rb

Overview

Public: a container for demos. This is a special type of container in that it does not correspond directly to a symbol from the parse results. Instead, it encapsulates and provides helper methods for sets of components that require a demo.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ Demo

Public: initializes a new demo.



25
26
27
28
# File 'lib/docks/containers/demo_container.rb', line 25

def initialize(component)
  @component = component
  @name = component.name
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component.



21
22
23
# File 'lib/docks/containers/demo_container.rb', line 21

def component
  @component
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/docks/containers/demo_container.rb', line 21

def name
  @name
end

Class Method Details

.typeObject

Public: the type of symbols that should be encapsulated by this container. This is compared against a symbol’s ‘symbol_type` to determine which container to use.

Returns the type String.



19
# File 'lib/docks/containers/demo_container.rb', line 19

def self.type; Docks::Types::Symbol::DEMO end

Instance Method Details

#joint_variationsObject

Public: collects all the variations of the demo’ed components that should be presented as joint demos.

Returns an Array of “joint”-type variations.



51
52
53
# File 'lib/docks/containers/demo_container.rb', line 51

def joint_variations
  variations_of_type(Docks::Types::Demo::JOINT)
end

#select_variations(options = {}) ⇒ Object

Public: collects all variations on the components that are being demo’ed that were specified to be “select” types. The optional options Hash allows you to choose whether or not to group the result by base class (using the ‘group_by_component` key of `true`), in which case the result will be a Hash of Arrays where the keys are the base classes. Otherwise, a simple Array of variation symbols is returned.

options - A hash of options. Defaults to {}.

Returns a Hash or Array of “select”-type variations, depending on the value of the ‘group_by_component` option.



42
43
44
# File 'lib/docks/containers/demo_container.rb', line 42

def select_variations(options = {})
  variations_of_type(Docks::Types::Demo::SELECT, options)
end