Module: PdfTempura::Document::DefaultCommands

Included in:
FieldSet, Page
Defined in:
lib/pdf_tempura/document/default_commands.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/pdf_tempura/document/default_commands.rb', line 4

def self.included(base)
  base.send(:attr_accessor, :fields)
end

Instance Method Details

#boxed_characters(name, coordinates, height, options = {}, &block) ⇒ Object



20
21
22
# File 'lib/pdf_tempura/document/default_commands.rb', line 20

def boxed_characters(name, coordinates, height, options = {}, &block)
  fields << Document::BoxedCharacters.new(name, coordinates, height, @options.merge(options), &block)
end

#checkbox_field(name, coordinates, dimensions, options = {}) ⇒ Object



12
13
14
# File 'lib/pdf_tempura/document/default_commands.rb', line 12

def checkbox_field(name, coordinates, dimensions, options = {})
  fields << Document::CheckboxField.new(name, coordinates, dimensions, @options.merge(options))
end

#field_set(name, options = {}, &block) ⇒ Object



24
25
26
# File 'lib/pdf_tempura/document/default_commands.rb', line 24

def field_set(name, options = {}, &block)
  fields << Document::FieldSet.new(name, @options.merge(options), &block)
end

#table(name, coordinates, options = {}, &block) ⇒ Object



16
17
18
# File 'lib/pdf_tempura/document/default_commands.rb', line 16

def table(name, coordinates, options = {}, &block)
  fields << Document::Table.new(name, coordinates, @options.merge(options), &block)
end

#text_field(name, coordinates, dimensions, options = {}) ⇒ Object



8
9
10
# File 'lib/pdf_tempura/document/default_commands.rb', line 8

def text_field(name, coordinates, dimensions, options = {})
  fields << Document::TextField.new(name, coordinates, dimensions, @options.merge(options))
end

#with_default_options(options = {}, &block) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/pdf_tempura/document/default_commands.rb', line 28

def with_default_options(options = {}, &block)
  previous_options = @options

  begin
    @options = @options.merge(options)
    instance_eval(&block)
  ensure
    @options = previous_options
  end
end