Class: AnnouncementObject

Inherits:
Object
  • Object
show all
Includes:
DataFactory, DateFactory, Foundry, StringFactory, Workflows
Defined in:
lib/sambal-cle/data_objects/announcement.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 = {}) ⇒ AnnouncementObject

Returns a new instance of AnnouncementObject.



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

def initialize(browser, opts={})
  @browser = browser

  defaults = {
      :title=>random_alphanums,
      :body=>random_multiline(500, 10, :alpha)
  }
  options = defaults.merge(opts)
  set_options(options)
  requires @site
end

Instance Attribute Details

#accessObject

Returns the value of attribute access.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def access
  @access
end

#availabilityObject

Returns the value of attribute availability.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def availability
  @availability
end

#bodyObject

Returns the value of attribute body.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def body
  @body
end

#creation_dateObject

Returns the value of attribute creation_date.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def creation_date
  @creation_date
end

#dateObject

Returns the value of attribute date.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def date
  @date
end

#groupsObject

Returns the value of attribute groups.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def groups
  @groups
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def id
  @id
end

Returns the value of attribute link.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def link
  @link
end

#messageObject

Returns the value of attribute message.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def message
  @message
end

#message_htmlObject

Returns the value of attribute message_html.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def message_html
  @message_html
end

#saved_byObject

Returns the value of attribute saved_by.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def saved_by
  @saved_by
end

#siteObject

Returns the value of attribute site.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def site
  @site
end

#subjectObject

Returns the value of attribute subject.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def subject
  @subject
end

#titleObject Also known as: name

Returns the value of attribute title.



9
10
11
# File 'lib/sambal-cle/data_objects/announcement.rb', line 9

def title
  @title
end

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sambal-cle/data_objects/announcement.rb', line 27

def create
  open_my_site_by_name @site
  announcements
  on_page Announcements do |page|
    page.add
  end
  on_page AddEditAnnouncements do |page|
    page.title.set @title
    page.enter_source_text page.editor, @body
    page.add_announcement
    @creation_date=make_date Time.now
  end
  on_page Announcements do |page|
    @link = page.href(@title)
    @id = @link[/(?<=msg\/).+(?=\/main\/)/]
  end
end

#edit(opts = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/sambal-cle/data_objects/announcement.rb', line 45

def edit opts={}
  open_my_site_by_name @site
  announcements
  on_page Announcements do |list|
    list.edit @title
  end
  on AddEditAnnouncements do |edit|
    edit.title.fit opts[:title]
    edit.send(opts[:access]) unless opts[:access]==nil
    edit.send(opts[:availability]) unless opts[:availability]==nil
    unless opts[:body]==nil
      edit.enter_source_text edit.editor, opts[:body]
    end
    edit.save_changes
  end
  update_options(opts)
end

#viewObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sambal-cle/data_objects/announcement.rb', line 63

def view
  open_my_site_by_name @site
  announcements
  on Announcements do |list|
    list.view @title
  end
  on ViewAnnouncement do |view|
    @subject=view.subject
    @saved_by=view.saved_by
    @date=view.date
    @groups=view.groups
    @message=view.message
    @message_html=view.message_html
  end
end