Class: Vedeu::Stream

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/models/stream.rb

Direct Known Subclasses

API::Stream

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, &block) ⇒ Stream

Returns a new instance of Stream.



7
8
9
10
11
12
13
14
15
# File 'lib/vedeu/models/stream.rb', line 7

def initialize(attributes = {}, &block)
  @attributes = attributes

  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)



73
74
75
# File 'lib/vedeu/models/stream.rb', line 73

def method_missing(method, *args, &block)
  @self_before_instance_eval.send(method, *args, &block)
end

Class Method Details

.build(attributes = {}, &block) ⇒ Object



3
4
5
# File 'lib/vedeu/models/stream.rb', line 3

def self.build(attributes = {}, &block)
  new(attributes, &block).attributes
end

Instance Method Details

#alignObject



37
38
39
# File 'lib/vedeu/models/stream.rb', line 37

def align
  @align ||= attributes[:align]
end

#attributesObject



17
18
19
# File 'lib/vedeu/models/stream.rb', line 17

def attributes
  @_attributes ||= defaults.merge!(@attributes)
end

#colourObject



21
22
23
# File 'lib/vedeu/models/stream.rb', line 21

def colour
  @colour ||= Colour.new(attributes[:colour])
end

#styleObject



25
26
27
# File 'lib/vedeu/models/stream.rb', line 25

def style
  @style ||= Attributes.coerce_styles(attributes[:style])
end

#textObject



29
30
31
# File 'lib/vedeu/models/stream.rb', line 29

def text
  @text ||= attributes[:text]
end

#to_sObject



41
42
43
# File 'lib/vedeu/models/stream.rb', line 41

def to_s
  [ colour, style, data ].join
end

#widthObject



33
34
35
# File 'lib/vedeu/models/stream.rb', line 33

def width
  @width ||= attributes[:width]
end