Class: DynamicPDFApi::ConverterInput

Inherits:
Input
  • Object
show all
Defined in:
lib/ruby_client/ConverterInput.rb

Overview

Represents the base class for inputs.

Direct Known Subclasses

ExcelInput, HtmlInput, WordInput

Instance Attribute Summary collapse

Attributes inherited from Input

#_resources, #_template_id, #_type, #id, #resource_name

Instance Method Summary collapse

Methods inherited from Input

#get_template, #set_template

Constructor Details

#initialize(resource, size, orientation, margins) ⇒ ConverterInput

Returns a new instance of ConverterInput.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_client/ConverterInput.rb', line 7

def initialize(resource, size, orientation, margins)
  super(resource)

  if (size != nil)
    self.page_size = size
  end
  if (orientation != nil)
    self.page_orientation = orientation
  end

  if (margins != nil)
    @top_margin = margins
    @bottom_margin = margins
    @right_margin = margins
    @left_margin = margins
  end
end

Instance Attribute Details

#_largerObject

attr_accessor :page_size



57
58
59
# File 'lib/ruby_client/ConverterInput.rb', line 57

def _larger
  @_larger
end

#_smallerObject

attr_accessor :page_size



57
58
59
# File 'lib/ruby_client/ConverterInput.rb', line 57

def _smaller
  @_smaller
end

#bottom_marginObject

Gets or sets the bottom margin.



38
39
40
# File 'lib/ruby_client/ConverterInput.rb', line 38

def bottom_margin
  @bottom_margin
end

#left_marginObject

Gets or sets the left margin.



33
34
35
# File 'lib/ruby_client/ConverterInput.rb', line 33

def left_margin
  @left_margin
end

#page_heightObject

Gets or sets the page height.



53
54
55
# File 'lib/ruby_client/ConverterInput.rb', line 53

def page_height
  @page_height
end

#page_widthObject

Gets or sets the page width.



48
49
50
# File 'lib/ruby_client/ConverterInput.rb', line 48

def page_width
  @page_width
end

#right_marginObject

Gets or sets the right margin.



43
44
45
# File 'lib/ruby_client/ConverterInput.rb', line 43

def right_margin
  @right_margin
end

#top_marginObject

Gets or sets the top margin.



28
29
30
# File 'lib/ruby_client/ConverterInput.rb', line 28

def top_margin
  @top_margin
end

Instance Method Details

#page_orientation=(value) ⇒ Object

Gets or sets page orientation.



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ruby_client/ConverterInput.rb', line 81

def page_orientation=(value)
  @page_orientation = value

  if(@page_width != nil && @page_height != nil)
    if @page_width > @page_height
      @_smaller = @page_height
      @_larger = @page_width
    else
      @_smaller = @page_width
      @_larger = @page_height
    end

    if @page_orientation == PageOrientation::LANDSCAPE
      @page_height = @_smaller
      @page_width = @_larger
    else
      @page_height = @_larger
      @page_width = @_smaller
    end
  end
end

#page_size=(value) ⇒ Object

Gets or sets the page size.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ruby_client/ConverterInput.rb', line 61

def page_size=(value)
  @page_size = value

  output_size = UnitConverter.get_paper_size(value)

  @_larger = output_size.larger
  @_smaller = output_size.smaller

  if @page_orientation == PageOrientation::LANDSCAPE
    @page_height = @_smaller
    @page_width = @_larger
  else
    @page_height = @_larger
    @page_width = @_smaller
  end
end

#to_json(_options = {}) ⇒ Object



103
104
105
# File 'lib/ruby_client/ConverterInput.rb', line 103

def to_json(_options = {})
  JSON.pretty_generate({})
end