Class: Gecko::Widget::Funnel

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

Defined Under Namespace

Classes: Item

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) ⇒ Funnel

Returns a new instance of Funnel.



10
11
12
13
14
15
# File 'lib/gecko/graph/funnel.rb', line 10

def initialize(*args, &block)
  super
  self.standard
  self.show_percentage
  @items = []
end

Instance Attribute Details

#reverseObject (readonly)

Returns the value of attribute reverse.



8
9
10
# File 'lib/gecko/graph/funnel.rb', line 8

def reverse
  @reverse
end

Instance Method Details

#[](index) ⇒ Object



46
47
48
# File 'lib/gecko/graph/funnel.rb', line 46

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

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



50
51
52
# File 'lib/gecko/graph/funnel.rb', line 50

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

#add(*args) ⇒ Object



42
43
44
# File 'lib/gecko/graph/funnel.rb', line 42

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

#data_payloadObject



58
59
60
61
62
63
64
# File 'lib/gecko/graph/funnel.rb', line 58

def data_payload
  {
    :type => @reverse,
    :percentage => @percentage,
    :item => self.map{|item| {:value => item.value, :label => item.label} }
  }
end

#delete(index) ⇒ Object



54
55
56
# File 'lib/gecko/graph/funnel.rb', line 54

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

#each(&block) ⇒ Object



38
39
40
# File 'lib/gecko/graph/funnel.rb', line 38

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

#hide_percentageObject



34
35
36
# File 'lib/gecko/graph/funnel.rb', line 34

def hide_percentage
  @percentage = :hide
end

#resetObject



17
18
19
20
# File 'lib/gecko/graph/funnel.rb', line 17

def reset
  @items.clear
  self
end

#show_percentageObject



30
31
32
# File 'lib/gecko/graph/funnel.rb', line 30

def show_percentage
  @percentage = :show
end

#standardObject



22
23
24
# File 'lib/gecko/graph/funnel.rb', line 22

def standard
  @reverse = :standard
end