Class: Vedeu::API::Interface

Inherits:
Interface show all
Defined in:
lib/vedeu/api/interface.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Interface

#attributes, #geometry, #lines, #to_s

Constructor Details

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



17
18
19
20
21
22
23
24
25
# File 'lib/vedeu/api/interface.rb', line 17

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)



103
104
105
# File 'lib/vedeu/api/interface.rb', line 103

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

Class Method Details

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



9
10
11
# File 'lib/vedeu/api/interface.rb', line 9

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

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



13
14
15
# File 'lib/vedeu/api/interface.rb', line 13

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

Instance Method Details

#centred(value) ⇒ Object



85
86
87
# File 'lib/vedeu/api/interface.rb', line 85

def centred(value)
  attributes[:geometry][:centred] = value
end

#colour(value) ⇒ Object



41
42
43
# File 'lib/vedeu/api/interface.rb', line 41

def colour(value)
  attributes[:colour] = value
end

#cursor(value) ⇒ Object



45
46
47
# File 'lib/vedeu/api/interface.rb', line 45

def cursor(value)
  attributes[:cursor] = value
end

#define(&block) ⇒ Object



27
28
29
30
31
# File 'lib/vedeu/api/interface.rb', line 27

def define(&block)
  instance_eval(&block) if block_given?

  Vedeu::Store.create(attributes)
end

#delay(value) ⇒ Object



49
50
51
# File 'lib/vedeu/api/interface.rb', line 49

def delay(value)
  attributes[:delay] = value
end

#group(value) ⇒ Object



53
54
55
# File 'lib/vedeu/api/interface.rb', line 53

def group(value)
  attributes[:group] = value
end

#height(value) ⇒ Object



79
80
81
82
83
# File 'lib/vedeu/api/interface.rb', line 79

def height(value)
  fail InvalidHeight if y_out_of_bounds?(value)

  attributes[:geometry][:height] = value
end

#line(&block) ⇒ Object



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

def line(&block)
  attributes[:lines] << Line.build(&block)
end

#name(value) ⇒ Object



57
58
59
# File 'lib/vedeu/api/interface.rb', line 57

def name(value)
  attributes[:name] = value
end

#style(value) ⇒ Object



89
90
91
# File 'lib/vedeu/api/interface.rb', line 89

def style(value)
  attributes[:style] = value
end

#use(value) ⇒ Object



37
38
39
# File 'lib/vedeu/api/interface.rb', line 37

def use(value)
  Vedeu.use(value)
end

#width(value) ⇒ Object



73
74
75
76
77
# File 'lib/vedeu/api/interface.rb', line 73

def width(value)
  fail InvalidWidth if x_out_of_bounds?(value)

  attributes[:geometry][:width] = value
end

#x(value) ⇒ Object



61
62
63
64
65
# File 'lib/vedeu/api/interface.rb', line 61

def x(value)
  fail XOutOfBounds if x_out_of_bounds?(value)

  attributes[:geometry][:x] = value
end

#y(value) ⇒ Object



67
68
69
70
71
# File 'lib/vedeu/api/interface.rb', line 67

def y(value)
  fail YOutOfBounds if y_out_of_bounds?(value)

  attributes[:geometry][:y] = value
end