lib/vedeu/models/line.rb in vedeu-0.1.18 vs lib/vedeu/models/line.rb in vedeu-0.1.19
- old
+ new
@@ -1,50 +1,66 @@
module Vedeu
+
+ # A Line represents a single row of the terminal. It is a container for
+ # {Vedeu::Stream} objects. A line's width is determined by the
+ # {Vedeu::Interface} it belongs to.
class Line
+
include Coercions
include Presentation
- attr_reader :attributes
+ attr_reader :attributes, :parent
# @param attributes [Hash]
# @param block [Proc]
# @return [Hash]
def self.build(attributes = {}, &block)
new(attributes, &block).attributes
end
+ # Returns a new instance of Line.
+ #
# @param attributes [Hash]
# @param block [Proc]
# @return [Line]
def initialize(attributes = {}, &block)
@attributes = defaults.merge!(attributes)
+ @parent = @attributes[:parent]
if block_given?
@self_before_instance_eval = eval('self', block.binding)
instance_eval(&block)
end
end
+ # Returns a collection of streams associated with this line.
+ #
# @return [Array]
def streams
- @streams ||= Stream.coercer(attributes[:streams])
+ @streams ||= Stream.coercer(attributes[:streams], parent)
end
- # @return [String]
- def to_s
- [ colour, style, streams ].join
- end
-
private
+ # Convenience method to provide Presentation with a consistent interface.
+ #
# @api private
+ # @return [Array]
+ def data
+ streams
+ end
+
+ # The default values for a new instance of Line.
+ #
+ # @api private
# @return [Hash]
def defaults
{
colour: {},
streams: [],
- style: []
+ style: [],
+ parent: nil,
}
end
# @api private
# @return []