Class: Vedeu::DSL::Line
- Inherits:
-
Object
- Object
- Vedeu::DSL::Line
- Includes:
- Vedeu::DSL, Presentation, Text
- Defined in:
- lib/vedeu/dsl/line.rb
Overview
Provides methods to be used to define views.
Vedeu.renders do
view :my_interface do
lines do
background '#000000'
foreground '#ffffff'
line 'This is white text on a black background.'
line 'Next is a blank line:'
line ''
streams { stream 'We can define ' }
streams do
foreground '#ff0000'
stream 'parts of a line '
end
streams { stream 'independently using ' }
streams do
foreground '#00ff00'
stream 'streams.'
end
end
end
end
Instance Attribute Summary collapse
-
#client ⇒ Object
included
from Vedeu::DSL
readonly
protected
The object instance where the DSL is being used.
-
#model ⇒ void
included
from Vedeu::DSL
readonly
protected
The new model object which the DSL is constructing.
Instance Method Summary collapse
-
#attributes ⇒ Hash<Symbol => void>
included
from Vedeu::DSL
private
Returns the default attributes for the new model.
-
#background(value = '') ⇒ String
(also: #bg, #bgcolor, #background=, #bg=, #bgcolor=)
included
from Presentation
Define the background colour for an interface, line, or a stream.
- #build_stream(value) ⇒ Vedeu::Views::Stream private
-
#colour(attrs = {}) ⇒ Vedeu::Colours::Colour
(also: #colour=)
included
from Presentation
Define either or both foreground and background colours for an interface, line or a stream.
- #colour_attributes ⇒ Hash<Symbol => String> included from Presentation private
- #foreground(value = '') ⇒ Object (also: #fg, #fgcolor, #foreground=, #fg=, #fgcolor=) included from Presentation
-
#initialize(model, client = nil) ⇒ void
included
from Vedeu::DSL
Returns an instance of the DSL class including Vedeu::DSL.
-
#line(value = '', &block) ⇒ Vedeu::Views::Lines
(also: #line=)
Specify a single line in a view.
-
#method_missing(method, *args, &block) ⇒ void
included
from Vedeu::DSL
private
Attempts to find the missing method on the client object.
-
#streams(&block) ⇒ Vedeu::Views::Streams<Vedeu::Views::Stream>
(also: #stream, #stream=, #streams=)
Define multiple streams (a stream is a subset of a line).
-
#style(value) ⇒ Vedeu::Presentation::Style
(also: #style=, #styles, #styles=)
included
from Presentation
Define a style or styles for an interface, line or a stream.
-
#text(value = '', options = {}) ⇒ String
(also: #text=, #align, #center, #centre, #left, #right, #align=, #center=, #centre=, #left=, #right=)
included
from Text
Specify the content for a view.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Vedeu::DSL
Instance Attribute Details
#client ⇒ Object (readonly, protected) Originally defined in module Vedeu::DSL
#model ⇒ void (readonly, protected) Originally defined in module Vedeu::DSL
Instance Method Details
#attributes ⇒ Hash<Symbol => void> (private) Originally defined in module Vedeu::DSL
Specific DSL classes may be overriding this method.
Returns the default attributes for the new model.
#background(value = '') ⇒ String Also known as: bg, bgcolor, background=, bg=, bgcolor= Originally defined in module Presentation
The last defined background colour for a particular interface, line or stream overrides previously defined entries in the same block.
Define the background colour for an interface, line, or a stream. When called with a block, will create a new stream with the background colour specified. When the block terminates, the background will return to that of the parent.
#build_stream(value) ⇒ Vedeu::Views::Stream (private)
111 112 113 |
# File 'lib/vedeu/dsl/line.rb', line 111 def build_stream(value) Vedeu::Views::Stream.build(client: client, parent: model, value: value) end |
#colour(attrs = {}) ⇒ Vedeu::Colours::Colour Also known as: colour= Originally defined in module Presentation
Rejects invalid keys and empty/nil attributes. Also, the last defined colour for a particular interface, line or stream overrides previously defined entries in the same block.
Define either or both foreground and background colours for an interface, line or a stream. At least one attribute is required.
#colour_attributes ⇒ Hash<Symbol => String> (private) Originally defined in module Presentation
#foreground(value = '') ⇒ Object Also known as: fg, fgcolor, foreground=, fg=, fgcolor= Originally defined in module Presentation
#initialize(model, client = nil) ⇒ void Originally defined in module Vedeu::DSL
Returns an instance of the DSL class including Vedeu::DSL.
#line(value = '', &block) ⇒ Vedeu::Views::Lines Also known as: line=
Specify a single line in a view.
Vedeu.renders do
view :my_interface do
lines do
line 'some text...'
# ... some code
line 'some more text...'
# ... some code
end
end
end
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/vedeu/dsl/line.rb', line 55 def line(value = '', &block) if block_given? content = Vedeu::Views::Line.build(client: client, parent: model.parent, &block) elsif value content = Vedeu::Views::Line.build(client: client, parent: model.parent, value: [build_stream(value)]) else fail Vedeu::Error::RequiresBlock unless block_given? end model.parent.add(content) end |
#streams(&block) ⇒ Vedeu::Views::Streams<Vedeu::Views::Stream> Also known as: stream, stream=, streams=
Define multiple streams (a stream is a subset of a line). Uses Stream for all directives within the required block.
Vedeu.renders do
view :my_interface do
lines do
line do
streams do
# ... some code
end
stream do
# ... some code
end
end
end
end
end
98 99 100 101 102 |
# File 'lib/vedeu/dsl/line.rb', line 98 def streams(&block) fail Vedeu::Error::RequiresBlock unless block_given? model.add(model.member.build(attributes, &block)) end |
#style(value) ⇒ Vedeu::Presentation::Style Also known as: style=, styles, styles= Originally defined in module Presentation
Define a style or styles for an interface, line or a stream.
#text(value = '', options = {}) ⇒ String Also known as: text=, align, center, centre, left, right, align=, center=, centre=, left=, right= Originally defined in module Text
If using the convenience methods; left, centre, center or right, then a specified anchor will be ignored.
Specify the content for a view. Provides the means to align a string (or object responding to ‘to_s`), and add it as a Line or to the Stream.