Class: GroupDocs::Document::Annotation
- Inherits:
-
Api::Entity
- Object
- Api::Entity
- GroupDocs::Document::Annotation
- Includes:
- Api::Helpers::AccessMode
- Defined in:
- lib/groupdocs/document/annotation.rb
Defined Under Namespace
Classes: Reply
Constant Summary collapse
- TYPES =
%w(Text Area Point TextStrikeout Polyline)
Instance Attribute Summary collapse
-
#access ⇒ Symbol
Converts access mode to human-readable format.
- #annotationPosition ⇒ Object (also: #annotation_position)
- #box ⇒ Object
- #createdOn ⇒ Object (also: #created_on)
- #creatorGuid ⇒ Object (also: #creator_guid)
- #document ⇒ Object
- #documentGuid ⇒ Object (also: #document_guid)
- #guid ⇒ Object
- #id ⇒ Object
- #replies ⇒ Object
- #replyGuid ⇒ Object (also: #reply_guid)
- #sessionGuid ⇒ Object (also: #session_guid)
-
#type ⇒ Symbol
Returns type in human-readable format.
Instance Method Summary collapse
-
#add_reply(reply) ⇒ Object
Adds reply to annotation.
-
#collaborators!(access = {}) ⇒ Array<GroupDocs::User>
Returns annotation collaborators.
-
#collaborators_set!(emails, access = {}) ⇒ Array<GroupDocs::User>
(also: #collaborators=)
Sets annotation collaborators to given emails.
-
#create!(access = {}) ⇒ Object
Creates new annotation.
-
#initialize(options = {}, &blk) ⇒ Annotation
constructor
Creates new GroupDocs::Document::Annotation.
-
#move!(x, y, access = {}) ⇒ Object
Moves annotation to given coordinates.
-
#remove!(access = {}) ⇒ Object
Removes annotation.
-
#replies!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::Annotation::Reply>
Return an array of replies..
-
#set_access!(mode, access = {}) ⇒ Object
Sets access mode.
Methods inherited from Api::Entity
Constructor Details
#initialize(options = {}, &blk) ⇒ Annotation
Creates new GroupDocs::Document::Annotation.
60 61 62 63 64 |
# File 'lib/groupdocs/document/annotation.rb', line 60 def initialize( = {}, &blk) super(, &blk) document.is_a?(GroupDocs::Document) or raise ArgumentError, "You have to pass GroupDocs::Document object: #{document.inspect}." end |
Instance Attribute Details
#access ⇒ Symbol
Converts access mode to human-readable format.
29 30 31 |
# File 'lib/groupdocs/document/annotation.rb', line 29 def access @access end |
#annotationPosition ⇒ Object Also known as: annotation_position
35 36 37 |
# File 'lib/groupdocs/document/annotation.rb', line 35 def annotationPosition @annotationPosition end |
#box ⇒ Object
31 32 33 |
# File 'lib/groupdocs/document/annotation.rb', line 31 def box @box end |
#createdOn ⇒ Object Also known as: created_on
25 26 27 |
# File 'lib/groupdocs/document/annotation.rb', line 25 def createdOn @createdOn end |
#creatorGuid ⇒ Object Also known as: creator_guid
21 22 23 |
# File 'lib/groupdocs/document/annotation.rb', line 21 def creatorGuid @creatorGuid end |
#document ⇒ Object
11 12 13 |
# File 'lib/groupdocs/document/annotation.rb', line 11 def document @document end |
#documentGuid ⇒ Object Also known as: document_guid
19 20 21 |
# File 'lib/groupdocs/document/annotation.rb', line 19 def documentGuid @documentGuid end |
#guid ⇒ Object
15 16 17 |
# File 'lib/groupdocs/document/annotation.rb', line 15 def guid @guid end |
#id ⇒ Object
13 14 15 |
# File 'lib/groupdocs/document/annotation.rb', line 13 def id @id end |
#replies ⇒ Object
33 34 35 |
# File 'lib/groupdocs/document/annotation.rb', line 33 def replies @replies end |
#replyGuid ⇒ Object Also known as: reply_guid
23 24 25 |
# File 'lib/groupdocs/document/annotation.rb', line 23 def replyGuid @replyGuid end |
#sessionGuid ⇒ Object Also known as: session_guid
17 18 19 |
# File 'lib/groupdocs/document/annotation.rb', line 17 def sessionGuid @sessionGuid end |
#type ⇒ Symbol
Returns type in human-readable format.
27 28 29 |
# File 'lib/groupdocs/document/annotation.rb', line 27 def type @type end |
Instance Method Details
#add_reply(reply) ⇒ Object
Adds reply to annotation.
151 152 153 154 155 156 157 |
# File 'lib/groupdocs/document/annotation.rb', line 151 def add_reply(reply) reply.is_a?(GroupDocs::Document::Annotation::Reply) or raise ArgumentError, "Reply should be GroupDocs::Document::Annotation::Reply object, received: #{reply.inspect}" @replies ||= Array.new @replies << reply end |
#collaborators!(access = {}) ⇒ Array<GroupDocs::User>
Returns annotation collaborators.
192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/groupdocs/document/annotation.rb', line 192 def collaborators!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/ant/{{client_id}}/files/#{document.file.guid}/collaborators" end.execute! json[:collaborators].map do |collaborator| User.new(collaborator) end end |
#collaborators_set!(emails, access = {}) ⇒ Array<GroupDocs::User> Also known as: collaborators=
Sets annotation collaborators to given emails.
213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/groupdocs/document/annotation.rb', line 213 def collaborators_set!(emails, access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/files/#{document.file.guid}/collaborators" request[:request_body] = emails end.execute! json[:collaborators].map do |collaborator| User.new(collaborator) end end |
#create!(access = {}) ⇒ Object
Creates new annotation.
171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/groupdocs/document/annotation.rb', line 171 def create!(access = {}) json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/ant/{{client_id}}/files/#{document.file.guid}/annotations" request[:request_body] = to_hash end.execute! json.each do |field, value| send(:"#{field}=", value) if respond_to?(:"#{field}=") end end |
#move!(x, y, access = {}) ⇒ Object
Moves annotation to given coordinates.
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/groupdocs/document/annotation.rb', line 268 def move!(x, y, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/position" request[:request_body] = { x: x, y: y } end.execute! self.annotation_position = { x: x, y: y } end |
#remove!(access = {}) ⇒ Object
Removes annotation.
235 236 237 238 239 240 241 |
# File 'lib/groupdocs/document/annotation.rb', line 235 def remove!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/ant/{{client_id}}/annotations/#{guid}" end.execute! end |
#replies!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::Annotation::Reply>
Return an array of replies..
255 256 257 |
# File 'lib/groupdocs/document/annotation.rb', line 255 def replies!( = {}, access = {}) Document::Annotation::Reply.get!(self, , access) end |
#set_access!(mode, access = {}) ⇒ Object
Sets access mode.
287 288 289 290 291 292 293 294 295 296 |
# File 'lib/groupdocs/document/annotation.rb', line 287 def set_access!(mode, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/annotationAccess" request[:request_body] = %w(public private).index(mode.to_s) end.execute! self.access = mode end |