Class: Vedeu::DSL::Stream

Inherits:
Object
  • Object
show all
Includes:
Vedeu::DSL, Colour, Style, Text
Defined in:
lib/vedeu/dsl/stream.rb

Overview

Provides methods to be used to define views.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Text

#stream_attributes, #stream_builder, #text

Methods included from Style

#style

Methods included from Colour

#background, #colour, #foreground

Methods included from Vedeu::DSL

#method_missing

Constructor Details

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

Returns an instance of DSL::Stream.

Parameters:



23
24
25
26
# File 'lib/vedeu/dsl/stream.rb', line 23

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)


40
41
42
# File 'lib/vedeu/dsl/stream.rb', line 40

def client
  @client
end

#modelStream (readonly, private)

Returns:



43
44
45
# File 'lib/vedeu/dsl/stream.rb', line 43

def model
  @model
end

Instance Method Details

#attributesHash (private)

Returns:

  • (Hash)


46
47
48
49
50
51
# File 'lib/vedeu/dsl/stream.rb', line 46

def attributes
  {
    client: client,
    parent: model.parent,
  }
end

#stream(&block) ⇒ void

This method returns an undefined value.

Parameters:

  • block (Proc)

Raises:

  • (InvalidSyntax)

    The required block was not given.



31
32
33
34
35
# File 'lib/vedeu/dsl/stream.rb', line 31

def stream(&block)
  fail InvalidSyntax, 'block not given' unless block_given?

  model.add(model.class.build(attributes, &block))
end