Class: Vedeu::Stream
- Inherits:
-
Object
- Object
- Vedeu::Stream
- Includes:
- Coercions, Presentation
- Defined in:
- lib/vedeu/models/stream.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
- #aligned ⇒ String private private
- #data ⇒ String private private
- #defaults ⇒ Hash private private
- #initialize(attributes = {}, &block) ⇒ Stream constructor
-
#method_missing(method, *args, &block) ⇒ Object
private
private
[].
- #to_s ⇒ String
- #width? ⇒ TrueClass|FalseClass private private
Methods included from Presentation
Methods included from Coercions
Constructor Details
#initialize(attributes = {}, &block) ⇒ Stream
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vedeu/models/stream.rb', line 18 def initialize(attributes = {}, &block) @attributes = defaults.merge!(attributes) @align = @attributes[:align] @text = @attributes[:text] @width = @attributes[:width] if block_given? @self_before_instance_eval = eval('self', block.binding) instance_eval(&block) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns [].
74 75 76 |
# File 'lib/vedeu/models/stream.rb', line 74 def method_missing(method, *args, &block) @self_before_instance_eval.send(method, *args, &block) end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
6 7 8 |
# File 'lib/vedeu/models/stream.rb', line 6 def align @align end |
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/vedeu/models/stream.rb', line 6 def attributes @attributes end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/vedeu/models/stream.rb', line 6 def text @text end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/vedeu/models/stream.rb', line 6 def width @width end |
Class Method Details
.build(attributes = {}, &block) ⇒ Hash
11 12 13 |
# File 'lib/vedeu/models/stream.rb', line 11 def self.build(attributes = {}, &block) new(attributes, &block).attributes end |
Instance Method Details
#aligned ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 |
# File 'lib/vedeu/models/stream.rb', line 46 def aligned case align when :right then text.rjust(width, ' ') when :centre then text.center(width, ' ') else text.ljust(width, ' ') end end |
#data ⇒ String (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/vedeu/models/stream.rb', line 40 def data width? ? aligned : text end |
#defaults ⇒ Hash (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 65 66 67 68 69 70 |
# File 'lib/vedeu/models/stream.rb', line 62 def defaults { colour: {}, style: [], text: '', width: nil, align: :left } end |
#to_s ⇒ String
32 33 34 |
# File 'lib/vedeu/models/stream.rb', line 32 def to_s [ colour, style, data ].join end |
#width? ⇒ TrueClass|FalseClass (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/vedeu/models/stream.rb', line 56 def width? !!width end |