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)


45
46
47
48
# File 'lib/vedeu/dsl/group.rb', line 45

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, protected)

Returns:

  • (Object)


62
63
64
# File 'lib/vedeu/dsl/group.rb', line 62

def client
  @client
end

#modelGroup (readonly, protected)

Returns:



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

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.



34
35
36
37
38
# File 'lib/vedeu/dsl/group.rb', line 34

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)


54
55
56
# File 'lib/vedeu/dsl/group.rb', line 54

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