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
Attributes included from Vedeu::DSL
Instance Method Summary collapse
- #build_stream(value) ⇒ Vedeu::Views::Stream private
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Line
constructor
Returns an instance of DSL::Line.
-
#line(value = '', &block) ⇒ Vedeu::Views::Lines
(also: #line=)
Specify a single line in a view.
-
#streams(&block) ⇒ Vedeu::Views::Streams<Vedeu::Views::Stream>
(also: #stream, #stream=, #streams=)
Define multiple streams (a stream is a subset of a line).
Methods included from Text
Methods included from Presentation
#background, #colour, #colour_attributes, #foreground, #style
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Line
Returns an instance of DSL::Line.
44 45 46 47 |
# File 'lib/vedeu/dsl/line.rb', line 44 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 Method Details
#build_stream(value) ⇒ Vedeu::Views::Stream (private)
117 118 119 |
# File 'lib/vedeu/dsl/line.rb', line 117 def build_stream(value) Vedeu::Views::Stream.build(client: client, parent: model, value: value) end |
#line(value = '', &block) ⇒ Vedeu::Views::Lines Also known as: line=
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vedeu/dsl/line.rb', line 64 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::InvalidSyntax, 'block not given' end model.parent.add(content) end |
#streams(&block) ⇒ Vedeu::Views::Streams<Vedeu::Views::Stream> Also known as: stream, stream=, streams=
104 105 106 107 108 |
# File 'lib/vedeu/dsl/line.rb', line 104 def streams(&block) fail Vedeu::Error::InvalidSyntax, 'block not given' unless block_given? model.add(model.member.build(attributes, &block)) end |