Class: Visdiff::Image
- Inherits:
-
Object
- Object
- Visdiff::Image
- Defined in:
- lib/visdiff/image.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#fullpath ⇒ Object
readonly
Returns the value of attribute fullpath.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #attributes ⇒ Object
- #basename ⇒ Object
-
#initialize(identifier, fullpath) ⇒ Image
constructor
A new instance of Image.
- #signature ⇒ Object
- #submit! ⇒ Object
- #upload_io ⇒ Object
Constructor Details
#initialize(identifier, fullpath) ⇒ Image
Returns a new instance of Image.
6 7 8 9 |
# File 'lib/visdiff/image.rb', line 6 def initialize identifier, fullpath @identifier = identifier @fullpath = fullpath end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
4 5 6 |
# File 'lib/visdiff/image.rb', line 4 def client @client end |
#fullpath ⇒ Object (readonly)
Returns the value of attribute fullpath.
3 4 5 |
# File 'lib/visdiff/image.rb', line 3 def fullpath @fullpath end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
3 4 5 |
# File 'lib/visdiff/image.rb', line 3 def identifier @identifier end |
Instance Method Details
#attributes ⇒ Object
25 26 27 |
# File 'lib/visdiff/image.rb', line 25 def attributes {image: upload_io} end |
#basename ⇒ Object
11 12 13 |
# File 'lib/visdiff/image.rb', line 11 def basename File.basename(fullpath) end |
#signature ⇒ Object
15 16 17 18 19 |
# File 'lib/visdiff/image.rb', line 15 def signature @signature ||= IO.popen(["identify", "-format", "%#", '--', fullpath]) do |f| f.read end.strip end |
#submit! ⇒ Object
21 22 23 |
# File 'lib/visdiff/image.rb', line 21 def submit! @client.submit_image self end |
#upload_io ⇒ Object
29 30 31 |
# File 'lib/visdiff/image.rb', line 29 def upload_io Faraday::UploadIO.new(fullpath, 'image/png') end |