Class: Vedeu::Line

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

Direct Known Subclasses

API::Line

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Line.



7
8
9
10
11
12
13
14
15
# File 'lib/vedeu/models/line.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)



47
48
49
# File 'lib/vedeu/models/line.rb', line 47

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/line.rb', line 3

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

Instance Method Details

#attributesObject



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

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

#colourObject



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

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

#streamsObject



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

def streams
  @streams ||= Attributes.coercer(attributes[:streams], Stream, :text)
end

#styleObject



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

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

#to_sObject



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

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