Class: Visdiff::Revision
- Inherits:
-
Object
- Object
- Visdiff::Revision
- Defined in:
- lib/visdiff/revision.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #add_image(identifier, filename) ⇒ Object
- #attributes ⇒ Object
-
#initialize(identifier = nil, images = [], description = nil) ⇒ Revision
constructor
A new instance of Revision.
- #submit! ⇒ Object
Constructor Details
#initialize(identifier = nil, images = [], description = nil) ⇒ Revision
Returns a new instance of Revision.
7 8 9 10 11 12 |
# File 'lib/visdiff/revision.rb', line 7 def initialize(identifier=nil, images=[], description=nil) @identifier = identifier @images = images @description = description @url = @id = nil end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/visdiff/revision.rb', line 5 def client @client end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/visdiff/revision.rb', line 4 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/visdiff/revision.rb', line 3 def id @id end |
#identifier ⇒ Object
Returns the value of attribute identifier.
4 5 6 |
# File 'lib/visdiff/revision.rb', line 4 def identifier @identifier end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
3 4 5 |
# File 'lib/visdiff/revision.rb', line 3 def images @images end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/visdiff/revision.rb', line 3 def url @url end |
Instance Method Details
#add_image(identifier, filename) ⇒ Object
14 15 16 17 18 |
# File 'lib/visdiff/revision.rb', line 14 def add_image identifier, filename image = Image.new(identifier, filename) image.client = client @images << image end |
#attributes ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/visdiff/revision.rb', line 39 def attributes { identifier: identifier, image_attributes: images.map do |image| {identifier: image.identifier, description: description, signature: image.signature} end } end |
#submit! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/visdiff/revision.rb', line 20 def submit! response = client.submit_revision(self) @id = response['id'] @url = response['url'] missing_images = [] response['images'].each do |rimg| missing_images << rimg['signature'] unless rimg['url'] end puts "Uploading #{missing_images.length} new images (#{response['images'].length} total)" images.each do |image| next unless missing_images.include?(image.signature) client.submit_image(image) end puts @url end |