Class: Vedeu::API::Stream

Inherits:
Stream
  • Object
show all
Includes:
Helpers
Defined in:
lib/vedeu/api/stream.rb

Instance Attribute Summary

Attributes inherited from Stream

#attributes

Instance Method Summary collapse

Methods included from Helpers

#colour, #style

Methods inherited from Stream

#aligned, build, #data, #defaults, #initialize, #method_missing, #to_s, #width?

Methods included from Presentation

#colour, #style

Methods included from Coercions

included

Constructor Details

This class inherits a constructor from Vedeu::Stream

Dynamic Method Handling

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

Instance Method Details

#align(value) ⇒ Symbol

Specify the alignment of the stream within the line. Useful in combination with #width to provide simple formatting effects.

Examples:

...
  stream do
    align :right
    ...

Parameters:

  • value (Symbol)

    ‘:left`, `:centre` and `right` are valid values and will align accordingly. If not value is specified, the stream will left align.

Returns:

  • (Symbol)


21
22
23
24
25
26
27
28
# File 'lib/vedeu/api/stream.rb', line 21

def align(value)
  unless [:left, :right, :centre].include?(value.to_sym)
    fail InvalidSyntax, '`align` requires a value of `:left`, `:right` ' \
                        'or `centre`.'
  end

  attributes[:align] = value.to_sym
end

#text(value) ⇒ String

Add textual data to the stream via this method.

Examples:

...
  stream do
    text 'Some text to display...'
    ...

Parameters:

  • value (String)

    The text to be added to the stream. If the length of the text is greater than the interface’s width, it will be truncated and ellipsized.

Returns:

  • (String)


44
45
46
# File 'lib/vedeu/api/stream.rb', line 44

def text(value)
  attributes[:text] = value
end

#width(value) ⇒ Fixnum

Provides the ability to arbitrarily set the width of content for a stream. Useful in combination with #align to provide simple formatting effects.

Examples:

...
  stream do
    width 20
    ...

Parameters:

  • value (Fixnum)

    The width in characters.

Returns:



62
63
64
# File 'lib/vedeu/api/stream.rb', line 62

def width(value)
  attributes[:width] = value
end