Class: Visdiff::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/visdiff/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/visdiff/image.rb', line 4

def client
  @client
end

#fullpathObject (readonly)

Returns the value of attribute fullpath.



3
4
5
# File 'lib/visdiff/image.rb', line 3

def fullpath
  @fullpath
end

#identifierObject (readonly)

Returns the value of attribute identifier.



3
4
5
# File 'lib/visdiff/image.rb', line 3

def identifier
  @identifier
end

Instance Method Details

#attributesObject



25
26
27
# File 'lib/visdiff/image.rb', line 25

def attributes
  {image: upload_io}
end

#basenameObject



11
12
13
# File 'lib/visdiff/image.rb', line 11

def basename
  File.basename(fullpath)
end

#signatureObject



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_ioObject



29
30
31
# File 'lib/visdiff/image.rb', line 29

def upload_io
  Faraday::UploadIO.new(fullpath, 'image/png')
end