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.
Instance Attribute Summary collapse
- #client ⇒ Object readonly protected
- #model ⇒ Line readonly protected
Instance Method Summary collapse
- #attributes ⇒ Hash private
- #build_stream(value) ⇒ Vedeu::Stream private
-
#initialize(model, client = nil) ⇒ Vedeu::DSL::Line
constructor
Returns an instance of DSL::Line.
-
#line(value = '', &block) ⇒ Vedeu::Lines
Specify a single line in a view.
-
#streams(&block) ⇒ Vedeu::Streams<Vedeu::Stream>
(also: #stream)
Define multiple streams (a stream is a subset of a line).
Methods included from Text
Methods included from Presentation
#background, #colour, #foreground, #style
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Line
Returns an instance of DSL::Line.
46 47 48 49 |
# File 'lib/vedeu/dsl/line.rb', line 46 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
#client ⇒ Object (readonly, protected)
111 112 113 |
# File 'lib/vedeu/dsl/line.rb', line 111 def client @client end |
#model ⇒ Line (readonly, protected)
115 116 117 |
# File 'lib/vedeu/dsl/line.rb', line 115 def model @model end |
Instance Method Details
#attributes ⇒ Hash (private)
120 121 122 123 124 125 |
# File 'lib/vedeu/dsl/line.rb', line 120 def attributes { client: client, parent: model, } end |
#build_stream(value) ⇒ Vedeu::Stream (private)
129 130 131 |
# File 'lib/vedeu/dsl/line.rb', line 129 def build_stream(value) Vedeu::Stream.build(client: client, parent: model, value: value) end |
#line(value = '', &block) ⇒ Vedeu::Lines
Specify a single line in a view.
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::Line.build({ client: client, parent: model.parent }, &block) elsif value content = Vedeu::Line.build(client: client, parent: model.parent, streams: [build_stream(value)]) else fail InvalidSyntax, 'block not given' end model.parent.add(content) end |
#streams(&block) ⇒ Vedeu::Streams<Vedeu::Stream> Also known as: stream
Define multiple streams (a stream is a subset of a line). Uses Stream for all directives within the required block.
100 101 102 103 104 |
# File 'lib/vedeu/dsl/line.rb', line 100 def streams(&block) fail InvalidSyntax, 'block not given' unless block_given? model.add(model.member.build(attributes, &block)) end |