Class: Viewpoint::SPWS::Types::List
- Inherits:
-
Object
- Object
- Viewpoint::SPWS::Types::List
- Includes:
- Viewpoint::SPWS::Types
- Defined in:
- lib/viewpoint/spws/types/list.rb
Overview
This class represents a Sharepoint List returned from the Lists Web Service
Direct Known Subclasses
Constant Summary
Constants included from Viewpoint::SPWS::Types
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#feature_id ⇒ Object
readonly
Returns the value of attribute feature_id.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
-
#modified ⇒ Object
readonly
Returns the value of attribute modified.
-
#root_folder ⇒ Object
readonly
Returns the value of attribute root_folder.
-
#server_template ⇒ Object
readonly
Returns the value of attribute server_template.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#add_item!(opts) ⇒ Object
Add a ListItem.
-
#delete! ⇒ Object
Delete this List.
- #get_item(item_id) ⇒ Object
- #hidden? ⇒ Boolean
-
#initialize(ws, xml) ⇒ List
constructor
A new instance of List.
-
#items ⇒ Object
Return the items in this List.
-
#path ⇒ Object
Return the full-qualified path of this List.
Constructor Details
#initialize(ws, xml) ⇒ List
Returns a new instance of List.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/viewpoint/spws/types/list.rb', line 29 def initialize(ws, xml) @ws = ws @guid = xml['ID'] @title = xml['Title'] @description = xml['Description'] @hidden = (xml['Hidden'] == 'True') @created = DateTime.parse(xml['Created']) @modified = DateTime.parse(xml['Modified']) @last_deleted = DateTime.parse(xml['LastDeleted']) @item_count = xml['ItemCount'] @server_template= xml['ServerTemplate'].to_i @feature_id = xml['FeatureId'] @root_folder = xml['RootFolder'] #@xmldoc = xml @list_path = nil end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def created @created end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def description @description end |
#feature_id ⇒ Object (readonly)
Returns the value of attribute feature_id.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def feature_id @feature_id end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def guid @guid end |
#modified ⇒ Object (readonly)
Returns the value of attribute modified.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def modified @modified end |
#root_folder ⇒ Object (readonly)
Returns the value of attribute root_folder.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def root_folder @root_folder end |
#server_template ⇒ Object (readonly)
Returns the value of attribute server_template.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def server_template @server_template end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
24 25 26 |
# File 'lib/viewpoint/spws/types/list.rb', line 24 def title @title end |
Instance Method Details
#add_item!(opts) ⇒ Object
Add a ListItem
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/viewpoint/spws/types/list.rb', line 57 def add_item!(opts) op = { :command => 'New', :id => 'New' } opts.keys.each do |k| case k when :priority op[k] = PRIORITY[opts[:priority]] when :status op[k] = STATUS[opts[:status]] when :percent_complete op[k] = opts[k] * 0.01 else op[k] = opts[k] end end resp = @ws.update_list_items(@guid, :item_updates => [op]) resp[:new].first end |
#delete! ⇒ Object
Delete this List
77 78 79 |
# File 'lib/viewpoint/spws/types/list.rb', line 77 def delete! @ws.delete_list(@guid) end |
#get_item(item_id) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/viewpoint/spws/types/list.rb', line 87 def get_item(item_id) addl_fields = %w{LinkTitle Body AssignedTo Status Priority DueDate PercentComplete} i = @ws.get_list_items(@guid, :recursive => true, :view_fields => addl_fields) do |b| b.Query { b.Where { b.Eq { b.FieldRef(:Name => 'ID') b.Value(item_id, :Type => 'Counter') } } } end raise "Returned more than one item for #get_item" if(i.length > 1) i.first end |
#hidden? ⇒ Boolean
104 105 106 |
# File 'lib/viewpoint/spws/types/list.rb', line 104 def hidden? @hidden end |
#items ⇒ Object
Return the items in this List
82 83 84 |
# File 'lib/viewpoint/spws/types/list.rb', line 82 def items @ws.get_list_items(@guid) end |
#path ⇒ Object
Return the full-qualified path of this List
47 48 49 50 51 52 53 |
# File 'lib/viewpoint/spws/types/list.rb', line 47 def path return @list_path if @list_path site = @ws.spcon.site_base @list_path = "#{site.scheme}://#{site.host}" @list_path << ":#{site.port}" unless(site.port == 80 || site.port == 443) @list_path << @root_folder end |