Class: Vedeu::DSL::Line
- Inherits:
-
Object
- Object
- Vedeu::DSL::Line
- Includes:
- Vedeu::DSL, Colour, Style, Text
- Defined in:
- lib/vedeu/dsl/line.rb
Overview
Provides methods to be used to define views.
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
- #model ⇒ Line readonly private
Instance Method Summary collapse
- #attributes ⇒ Hash 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
#stream_attributes, #stream_builder, #text
Methods included from Style
Methods included from Colour
#background, #colour, #foreground
Methods included from Vedeu::DSL
Constructor Details
#initialize(model, client = nil) ⇒ Vedeu::DSL::Line
Returns an instance of DSL::Line.
50 51 52 53 |
# File 'lib/vedeu/dsl/line.rb', line 50 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, private)
117 118 119 |
# File 'lib/vedeu/dsl/line.rb', line 117 def client @client end |
#model ⇒ Line (readonly, private)
120 121 122 |
# File 'lib/vedeu/dsl/line.rb', line 120 def model @model end |
Instance Method Details
#attributes ⇒ Hash (private)
123 124 125 126 127 128 |
# File 'lib/vedeu/dsl/line.rb', line 123 def attributes { client: client, parent: model, } end |
#line(value = '', &block) ⇒ Vedeu::Lines
Specify a single line in a view.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/vedeu/dsl/line.rb', line 68 def line(value = '', &block) content = if block_given? Vedeu::Line.build({ client: client, parent: model.parent }, &block) elsif value stream = Vedeu::Stream.build({ client: client, parent: model, value: value }) Vedeu::Line.build({ client: client, parent: model.parent, streams: [stream] }) 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.
107 108 109 110 111 |
# File 'lib/vedeu/dsl/line.rb', line 107 def streams(&block) fail InvalidSyntax, 'block not given' unless block_given? model.add(model.member.build(attributes, &block)) end |