lib/vedeu/models/stream.rb in vedeu-0.1.15 vs lib/vedeu/models/stream.rb in vedeu-0.1.16
- old
+ new
@@ -1,45 +1,36 @@
module Vedeu
class Stream
+ include Coercions
+ include Presentation
+
+ attr_reader :attributes, :align, :text, :width
+
+ # @param attributes [Hash]
+ # @param block [Proc]
+ # @return [Hash]
def self.build(attributes = {}, &block)
new(attributes, &block).attributes
end
+ # @param attributes [Hash]
+ # @param block [Proc]
+ # @return [Stream]
def initialize(attributes = {}, &block)
- @attributes = attributes
+ @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
- def attributes
- @_attributes ||= defaults.merge!(@attributes)
- end
-
- def colour
- @colour ||= Colour.new(attributes[:colour])
- end
-
- def style
- @style ||= Attributes.coerce_styles(attributes[:style])
- end
-
- def text
- @text ||= attributes[:text]
- end
-
- def width
- @width ||= attributes[:width]
- end
-
- def align
- @align ||= attributes[:align]
- end
-
+ # @return [String]
def to_s
[ colour, style, data ].join
end
private
@@ -71,7 +62,8 @@
end
def method_missing(method, *args, &block)
@self_before_instance_eval.send(method, *args, &block)
end
+
end
end