Class: PollObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/poll.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Workflows

menu_link, #open_my_site_by_name, #reset

Constructor Details

#initialize(browser, opts = {}) ⇒ PollObject

Returns a new instance of PollObject.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sambal-cle/data_objects/poll.rb', line 11

def initialize(browser, opts={})
  @browser = browser
  
  defaults = {
    :question=>random_alphanums,
    :options=>[random_alphanums, random_alphanums]
  }
  options = defaults.merge(opts)
  
  set_options(options)
  requires @site
end

Instance Attribute Details

#accessObject

Returns the value of attribute access.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def access
  @access
end

#closing_dateObject

Returns the value of attribute closing_date.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def closing_date
  @closing_date
end

#instructionsObject

Returns the value of attribute instructions.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def instructions
  @instructions
end

#opening_dateObject

Returns the value of attribute opening_date.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def opening_date
  @opening_date
end

#optionsObject

Returns the value of attribute options.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def options
  @options
end

#questionObject

Returns the value of attribute question.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def question
  @question
end

#siteObject

Returns the value of attribute site.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def site
  @site
end

#visibilityObject

Returns the value of attribute visibility.



8
9
10
# File 'lib/sambal-cle/data_objects/poll.rb', line 8

def visibility
  @visibility
end

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sambal-cle/data_objects/poll.rb', line 24

def create
  open_my_site_by_name @site
  polls
  on Polls do |polls|
    polls.add
  end
  on AddEditPoll do |add|
    add.question.set @question
    add.enter_source_text add.editor, @instructions
    # TODO: Need to add the filling out of more fields here
    add.save_and_add_options
  end
  on AddAnOption do |page|
    if @options.length > 1
      @options[0..-2].each do |option|
        page.enter_source_text page.editor, option
        page.save_and_add_options
      end
      page.enter_source_text(page.editor, @options[-1])
      page.save
    else
      page.enter_source_text(page.editor, @options[0])
      page.save
    end
  end
  on AddEditPoll do |poll|
    poll.save
  end
end

#deleteObject



63
64
65
# File 'lib/sambal-cle/data_objects/poll.rb', line 63

def delete
  #TODO: Add stuff here
end

#edit(opts = {}) ⇒ Object



54
55
56
57
# File 'lib/sambal-cle/data_objects/poll.rb', line 54

def edit opts={}
  #TODO: Add stuff here
  set_options(opts)
end

#viewObject



59
60
61
# File 'lib/sambal-cle/data_objects/poll.rb', line 59

def view
  #TODO: Add stuff here
end