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
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#identifier ⇒ Object
readonly
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, images = [], description = nil) ⇒ Revision
constructor
A new instance of Revision.
- #submit! ⇒ Object
Constructor Details
#initialize(identifier, images = [], description = nil) ⇒ Revision
Returns a new instance of Revision.
6 7 8 9 10 11 |
# File 'lib/visdiff/revision.rb', line 6 def initialize identifier, images=[], description=nil @identifier = identifier @images = images @description = description @url = @id = nil end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/visdiff/revision.rb', line 4 def client @client end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/visdiff/revision.rb', line 3 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 (readonly)
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/visdiff/revision.rb', line 3 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
13 14 15 16 17 |
# File 'lib/visdiff/revision.rb', line 13 def add_image identifier, filename image = Image.new(identifier, filename) image.client = client @images << image end |
#attributes ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/visdiff/revision.rb', line 38 def attributes { identifier: identifier, image_attributes: images.map do |image| {identifier: image.identifier, description: description, signature: image.signature} end } end |
#submit! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/visdiff/revision.rb', line 19 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 |