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
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
- #box ⇒ Object
- #createdOn ⇒ Object
- #creatorGuid ⇒ Object
- #document ⇒ Object
- #documentGuid ⇒ Object
- #fieldText ⇒ Object
- #fontColor ⇒ Object
-
#fontFamily ⇒ Object
Returns the value of attribute fontFamily.
-
#fontSize ⇒ Object
Returns the value of attribute fontSize.
- #guid ⇒ Object
-
#height ⇒ Object
Returns the value of attribute height.
- #id ⇒ Object
- #replies ⇒ Object
- #replyGuid ⇒ Object
- #sessionGuid ⇒ Object
-
#type ⇒ Symbol
Returns type in human-readable format.
- #width ⇒ Object
Class Method Summary collapse
-
.remove!(guid, access = {}) ⇒ Object
Removes annotation.
Instance Method Summary collapse
-
#add_reply(reply) ⇒ Object
Adds reply to annotation.
-
#create!(info, access = {}) ⇒ Object
Creates new annotation.
-
#created_on ⇒ Time
Converts timestamp which is return by API server to Time object.
-
#initialize(options = {}, &blk) ⇒ Annotation
constructor
Creates new GroupDocs::Document::Annotation.
-
#move!(x, y, access = {}) ⇒ Object
Moves annotation to given coordinates.
-
#move_marker!(x, y, access = {}) ⇒ Object
Moves annotation marker to given coordinates.
-
#replies!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::Annotation::Reply>
Return an array of replies..
-
#resize!(x, y, access = {}) ⇒ Object
Resize annotation.
-
#set_access!(mode, access = {}) ⇒ Object
Sets access mode.
-
#text_color!(font_color, access = {}) ⇒ Object
Save Text Of Text Color.
-
#text_info!(fieldText, fontFamily, fontSize, access = {}) ⇒ Object
Save Text Of Text Field.
Methods inherited from Api::Entity
Methods included from Api::Helpers::Accessor
Constructor Details
#initialize(options = {}, &blk) ⇒ Annotation
Creates new GroupDocs::Document::Annotation.
65 66 67 68 69 |
# File 'lib/groupdocs/document/annotation.rb', line 65 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.
30 31 32 |
# File 'lib/groupdocs/document/annotation.rb', line 30 def access @access end |
#annotationPosition ⇒ Object
36 37 38 |
# File 'lib/groupdocs/document/annotation.rb', line 36 def annotationPosition @annotationPosition end |
#box ⇒ Object
32 33 34 |
# File 'lib/groupdocs/document/annotation.rb', line 32 def box @box end |
#createdOn ⇒ Object
26 27 28 |
# File 'lib/groupdocs/document/annotation.rb', line 26 def createdOn @createdOn end |
#creatorGuid ⇒ Object
22 23 24 |
# File 'lib/groupdocs/document/annotation.rb', line 22 def creatorGuid @creatorGuid end |
#document ⇒ Object
12 13 14 |
# File 'lib/groupdocs/document/annotation.rb', line 12 def document @document end |
#documentGuid ⇒ Object
20 21 22 |
# File 'lib/groupdocs/document/annotation.rb', line 20 def documentGuid @documentGuid end |
#fieldText ⇒ Object
41 42 43 |
# File 'lib/groupdocs/document/annotation.rb', line 41 def fieldText @fieldText end |
#fontColor ⇒ Object
45 46 47 |
# File 'lib/groupdocs/document/annotation.rb', line 45 def fontColor @fontColor end |
#fontFamily ⇒ Object
Returns the value of attribute fontFamily.
42 43 44 |
# File 'lib/groupdocs/document/annotation.rb', line 42 def fontFamily @fontFamily end |
#fontSize ⇒ Object
Returns the value of attribute fontSize.
43 44 45 |
# File 'lib/groupdocs/document/annotation.rb', line 43 def fontSize @fontSize end |
#guid ⇒ Object
16 17 18 |
# File 'lib/groupdocs/document/annotation.rb', line 16 def guid @guid end |
#height ⇒ Object
Returns the value of attribute height.
39 40 41 |
# File 'lib/groupdocs/document/annotation.rb', line 39 def height @height end |
#id ⇒ Object
14 15 16 |
# File 'lib/groupdocs/document/annotation.rb', line 14 def id @id end |
#replies ⇒ Object
34 35 36 |
# File 'lib/groupdocs/document/annotation.rb', line 34 def replies @replies end |
#replyGuid ⇒ Object
24 25 26 |
# File 'lib/groupdocs/document/annotation.rb', line 24 def replyGuid @replyGuid end |
#sessionGuid ⇒ Object
18 19 20 |
# File 'lib/groupdocs/document/annotation.rb', line 18 def sessionGuid @sessionGuid end |
#type ⇒ Symbol
Returns type in human-readable format.
28 29 30 |
# File 'lib/groupdocs/document/annotation.rb', line 28 def type @type end |
#width ⇒ Object
38 39 40 |
# File 'lib/groupdocs/document/annotation.rb', line 38 def width @width end |
Class Method Details
.remove!(guid, access = {}) ⇒ Object
Removes annotation.
199 200 201 202 203 204 205 |
# File 'lib/groupdocs/document/annotation.rb', line 199 def self.remove!(guid, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/ant/{{client_id}}/annotations/#{guid}" end.execute! end |
Instance Method Details
#add_reply(reply) ⇒ Object
Adds reply to annotation.
156 157 158 159 160 161 162 |
# File 'lib/groupdocs/document/annotation.rb', line 156 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 |
#create!(info, access = {}) ⇒ Object
Creates new annotation.
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/groupdocs/document/annotation.rb', line 179 def create!(info, 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] = info end.execute! json.each do |field, value| send(:"#{field}=", value) if respond_to?(:"#{field}=") end end |
#created_on ⇒ Time
Converts timestamp which is return by API server to Time object.
118 119 120 |
# File 'lib/groupdocs/document/annotation.rb', line 118 def created_on Time.at(@createdOn / 1000) end |
#move!(x, y, access = {}) ⇒ Object
Moves annotation to given coordinates.
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/groupdocs/document/annotation.rb', line 232 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 |
#move_marker!(x, y, access = {}) ⇒ Object
Moves annotation marker to given coordinates.
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/groupdocs/document/annotation.rb', line 252 def move_marker!(x, y, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/markerPosition" request[:request_body] = { :x => x, :y => y } end.execute! if box box.x = x box.y = y else self.box = { :x => x, :y => y } end end |
#replies!(options = {}, access = {}) ⇒ Array<GroupDocs::Document::Annotation::Reply>
Return an array of replies..
219 220 221 |
# File 'lib/groupdocs/document/annotation.rb', line 219 def replies!( = {}, access = {}) Document::Annotation::Reply.get!(self, , access) end |
#resize!(x, y, access = {}) ⇒ Object
Resize annotation.
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/groupdocs/document/annotation.rb', line 296 def resize!(x, y, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/size" request[:request_body] = { :width => x, :height => y } end.execute! self.width = x self.height = y end |
#set_access!(mode, access = {}) ⇒ Object
Sets access mode.
276 277 278 279 280 281 282 283 284 285 |
# File 'lib/groupdocs/document/annotation.rb', line 276 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 |
#text_color!(font_color, access = {}) ⇒ Object
Save Text Of Text Color.
339 340 341 342 343 344 345 346 347 348 |
# File 'lib/groupdocs/document/annotation.rb', line 339 def text_color!(font_color, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/size" request[:request_body] = { :fontColor => font_color } end.execute! self.fontColor = font_color end |
#text_info!(fieldText, fontFamily, fontSize, access = {}) ⇒ Object
Save Text Of Text Field.
318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/groupdocs/document/annotation.rb', line 318 def text_info!(fieldText, fontFamily, fontSize, access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:path] = "/ant/{{client_id}}/annotations/#{guid}/size" request[:request_body] = { :fieldText => fieldText, :fontFamily => fontFamily, :fontSize => fontSize } end.execute! self.fieldText = fieldText self.fontFamily = fontFamily self.fontSize = fontSize end |