Class: PkiExpress::PadesVisualImage

Inherits:
Object
  • Object
show all
Defined in:
lib/pki_express/pades_visual_image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_content = nil, image_url = nil, image_mime_type = nil) ⇒ PadesVisualImage

Returns a new instance of PadesVisualImage.



7
8
9
10
11
12
13
14
# File 'lib/pki_express/pades_visual_image.rb', line 7

def initialize(image_content=nil, image_url = nil, image_mime_type=nil)
  @opacity = 100
  @horizontal_align = PadesHorizontalAlign::CENTER
  @vertical_align = PadesVerticalAlign::CENTER
  @content = image_content
  @url = image_url
  @mime_type = image_mime_type
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/pki_express/pades_visual_image.rb', line 4

def content
  @content
end

#horizontal_alignObject

Returns the value of attribute horizontal_align.



3
4
5
# File 'lib/pki_express/pades_visual_image.rb', line 3

def horizontal_align
  @horizontal_align
end

#mime_typeObject

Returns the value of attribute mime_type.



4
5
6
# File 'lib/pki_express/pades_visual_image.rb', line 4

def mime_type
  @mime_type
end

#opacityObject

Returns the value of attribute opacity.



4
5
6
# File 'lib/pki_express/pades_visual_image.rb', line 4

def opacity
  @opacity
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/pki_express/pades_visual_image.rb', line 4

def url
  @url
end

#vertical_alignObject

Returns the value of attribute vertical_align.



3
4
5
# File 'lib/pki_express/pades_visual_image.rb', line 3

def vertical_align
  @vertical_align
end

Instance Method Details

#to_modelObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pki_express/pades_visual_image.rb', line 32

def to_model
  resource_model = {
      'mimeType': @mime_type,
  }
  if @content
    resource_model['content'] = Base64.encode64(@content)
  elsif @url
    resource_model['url'] = @url
  else
    raise 'The image content was not set, neither its URL'
  end

  {
      resource: resource_model,
      opacity: @opacity,
      horizontal_align: @horizontal_align,
      vertical_align: @vertical_align,
  }
end