Class: Vedeu::DSL::Group

Inherits:
Object
  • Object
show all
Includes:
Vedeu::DSL
Defined in:
lib/vedeu/dsl/group.rb

Overview

DSL for adding interfaces to a group.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Vedeu::DSL

#method_missing

Constructor Details

#initialize(model, client = nil) ⇒ Vedeu::DSL::Group

Returns an instance of DSL::Group.

Parameters:

  • model (Group)
  • client (Object) (defaults to: nil)


48
49
50
51
# File 'lib/vedeu/dsl/group.rb', line 48

def initialize(model, client = nil)
  @model  = model
  @client = client
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Vedeu::DSL

Instance Attribute Details

#clientObject (readonly, private)

Returns:

  • (Object)


64
65
66
# File 'lib/vedeu/dsl/group.rb', line 64

def client
  @client
end

#modelGroup (readonly, private)

Returns:



67
68
69
# File 'lib/vedeu/dsl/group.rb', line 67

def model
  @model
end

Class Method Details

.group(name, &block) ⇒ Vedeu::Group

Note:

Creating a group with the same name as an existing group overwrites the existing group.

Specify a new group of interfaces with a simple DSL.

The example below resembles ‘vim’ (the popular terminal-based text editor):

Examples:

Vedeu.group 'title_screen' do
  add 'welcome_interface'
  # ...

Vedeu.group 'main_screen' do
  add 'editor_interface'
  add 'status_interface'
  add 'command_interface'
  # ...

Parameters:

  • name (String)

    The name of this group.

  • block (Proc)

Returns:

Raises:

  • (InvalidSyntax)

    The required block was not given.



37
38
39
40
41
# File 'lib/vedeu/dsl/group.rb', line 37

def self.group(name, &block)
  fail InvalidSyntax, 'block not given' unless block_given?

  Vedeu::Group.build({ name: name }, &block).store
end

Instance Method Details

#add(interface_name) ⇒ void

This method returns an undefined value.

Add the named interface to this group.

Parameters:

  • interface_name (String)


57
58
59
# File 'lib/vedeu/dsl/group.rb', line 57

def add(interface_name)
  model.add(interface_name)
end