Class: Ilovepdf::Element
- Inherits:
-
Object
- Object
- Ilovepdf::Element
- Defined in:
- lib/ilovepdf/element.rb
Constant Summary collapse
- FONT_FAMILY_VALUES =
['Arial', 'Arial Unicode MS', 'Verdana', 'Courier', 'Times New Roman', 'Comic Sans MS', 'WenQuanYi Zen Hei', 'Lohit Marathi' ]
- VERTICAL_POSITION_VALUES =
['bottom', 'middle' ,'top']
- HORIZONTAL_POSITION_VALUES =
['left', 'center', 'right']
- LAYER_VALUES =
['above', 'below']
- ATTR_DEFAULT_VALUES =
{ type: 'text', mode: 'text', text: nil, image: nil, pages: 'all', vertical_position: 'middle', horizontal_position: 'center', vertical_adjustment: 0, horizontal_adjustment: 0, rotation: 0, transparency: 100, mosaic: false, font_family: nil, font_style: 'Regular', font_color: '#000000', font_size: 14, image_resize: 1, zoom: 1, gravity: 'center', border: nil, layer: nil, bold: false, server_filename: nil }
Instance Method Summary collapse
-
#font_family=(new_val) ⇒ Object
/initialize.
- #horizontal_position=(new_val) ⇒ Object
-
#initialize(params = {}) ⇒ Element
constructor
A new instance of Element.
- #layer=(new_val) ⇒ Object
- #to_api_hash ⇒ Object
- #vertical_position=(new_val) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Element
Returns a new instance of Element.
41 42 43 44 45 46 47 |
# File 'lib/ilovepdf/element.rb', line 41 def initialize(params={}) init_values = ATTR_DEFAULT_VALUES.merge(params) init_values.delete_if{|k, v| v.nil? } init_values.each_pair do |k, v| public_send(:"#{k}=", v) end # /each_pair end |
Instance Method Details
#font_family=(new_val) ⇒ Object
/initialize
49 50 51 52 |
# File 'lib/ilovepdf/element.rb', line 49 def font_family=(new_val) raise Errors::ArgumentEnumError.new(FONT_FAMILY_VALUES) unless FONT_FAMILY_VALUES.include? new_val @font_family = new_val end |
#horizontal_position=(new_val) ⇒ Object
64 65 66 67 |
# File 'lib/ilovepdf/element.rb', line 64 def horizontal_position=(new_val) raise Errors::ArgumentEnumError.new(HORIZONTAL_POSITION_VALUES) unless HORIZONTAL_POSITION_VALUES.include? new_val @horizontal_position = new_val end |
#layer=(new_val) ⇒ Object
54 55 56 57 |
# File 'lib/ilovepdf/element.rb', line 54 def layer=(new_val) raise Errors::ArgumentEnumError.new(LAYER_VALUES) unless LAYER_VALUES.include? new_val @layer = new_val end |
#to_api_hash ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/ilovepdf/element.rb', line 69 def to_api_hash export_hash = {} ATTR_DEFAULT_VALUES.keys.each do |k| val = send(k) export_hash[k] = val if !val.nil? end export_hash end |
#vertical_position=(new_val) ⇒ Object
59 60 61 62 |
# File 'lib/ilovepdf/element.rb', line 59 def vertical_position=(new_val) raise Errors::ArgumentEnumError.new(VERTICAL_POSITION_VALUES) unless VERTICAL_POSITION_VALUES.include? new_val @vertical_position = new_val end |