Class: Vedeu::Line

Inherits:
Object
  • Object
show all
Includes:
Coercions, Presentation
Defined in:
lib/vedeu/models/line.rb

Direct Known Subclasses

API::Line

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Presentation

#colour, #style

Methods included from Coercions

included

Constructor Details

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

Parameters:

  • attributes (Hash) (defaults to: {})
  • block (Proc)


18
19
20
21
22
23
24
25
26
# File 'lib/vedeu/models/line.rb', line 18

def initialize(attributes = {}, &block)
  @attributes = defaults.merge!(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)

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 [].

Returns:



52
53
54
# File 'lib/vedeu/models/line.rb', line 52

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/vedeu/models/line.rb', line 6

def attributes
  @attributes
end

Class Method Details

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

Parameters:

  • attributes (Hash) (defaults to: {})
  • block (Proc)

Returns:

  • (Hash)


11
12
13
# File 'lib/vedeu/models/line.rb', line 11

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

Instance Method Details

#defaultsHash (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:

  • (Hash)


42
43
44
45
46
47
48
# File 'lib/vedeu/models/line.rb', line 42

def defaults
  {
    colour:  {},
    streams: [],
    style:   []
  }
end

#streamsArray

Returns:

  • (Array)


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

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

#to_sString

Returns:

  • (String)


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

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