Class: Gecko::Widget::Line

Inherits:
Gecko::Widget show all
Includes:
Enumerable
Defined in:
lib/gecko/graph/line.rb

Instance Attribute Summary collapse

Attributes inherited from Gecko::Widget

#data, #keys

Instance Method Summary collapse

Methods inherited from Gecko::Widget

#config, #config!, #on_update, #payload, #push_requests, #push_url, #update

Constructor Details

#initialize(*args, &block) ⇒ Line

Returns a new instance of Line.



8
9
10
11
12
13
# File 'lib/gecko/graph/line.rb', line 8

def initialize(*args, &block)
  super
  @x_axis = []
  @y_axis = []
  @items = []
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/gecko/graph/line.rb', line 6

def color
  @color
end

#x_axisObject

Returns the value of attribute x_axis.



6
7
8
# File 'lib/gecko/graph/line.rb', line 6

def x_axis
  @x_axis
end

#y_axisObject

Returns the value of attribute y_axis.



6
7
8
# File 'lib/gecko/graph/line.rb', line 6

def y_axis
  @y_axis
end

Instance Method Details

#[](index) ⇒ Object



36
37
38
# File 'lib/gecko/graph/line.rb', line 36

def [](index)
  @items[index]
end

#[]=(index, *args) ⇒ Object



40
41
42
# File 'lib/gecko/graph/line.rb', line 40

def []=(index, *args)
  @items[index] = *args
end

#add(*args) ⇒ Object



19
20
21
# File 'lib/gecko/graph/line.rb', line 19

def add(*args)
  @items.push(*args)
end

#add_x_axis(*args) ⇒ Object



28
29
30
# File 'lib/gecko/graph/line.rb', line 28

def add_x_axis(*args)
  @x_axis.push(*args)
end

#add_y_axis(*args) ⇒ Object



32
33
34
# File 'lib/gecko/graph/line.rb', line 32

def add_y_axis(*args)
  @y_axis.push(*args)
end

#data_payloadObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/gecko/graph/line.rb', line 52

def data_payload
  {
    :item => self.to_a,
    :settings => {
      :axisx => self.x_axis,
      :axisy => self.y_axis,
      :colour => self.color
    }
  }
end

#delete(index) ⇒ Object



48
49
50
# File 'lib/gecko/graph/line.rb', line 48

def delete(index)
  @items.delete_at(index)
end

#each(&block) ⇒ Object



15
16
17
# File 'lib/gecko/graph/line.rb', line 15

def each(&block)
  @items.each(&block)
end

#items=(array) ⇒ Object



44
45
46
# File 'lib/gecko/graph/line.rb', line 44

def items=(array)
  @items = array
end

#resetObject



23
24
25
26
# File 'lib/gecko/graph/line.rb', line 23

def reset
  @items.clear
  self
end