Module: Pdfrb::Action

Defined in:
lib/pdfrb/action.rb,
lib/pdfrb/action/base.rb,
lib/pdfrb/action/types.rb

Overview

Actions (ISO 32000-2 ยง12.6). An action specifies an interactive behavior: jump to a destination, open a URI, launch an app, etc.

Each action type is a value object that serializes to a PDF action dictionary with /S (action type) and type-specific keys.

Defined Under Namespace

Classes: Base, GoTo, GoToE, GoToR, Hide, ImportData, JavaScript, Launch, Named, ResetForm, SetOCGState, SubmitForm, Trans, URI

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/pdfrb/action.rb', line 36

def [](name)
  key = name.to_sym
  result = registry[key]
  return result if result

  # Lazy-load on miss: trigger autoload of GoTo which loads
  # the entire types.rb file and registers all subtypes.
  GoTo unless @loaded
  @loaded = true
  registry[key]
end

.register(name, klass) ⇒ Object



32
33
34
# File 'lib/pdfrb/action.rb', line 32

def register(name, klass)
  registry[name.to_sym] = klass
end

.registryObject



28
29
30
# File 'lib/pdfrb/action.rb', line 28

def registry
  @registry ||= {}
end

.typesObject



48
49
50
51
52
# File 'lib/pdfrb/action.rb', line 48

def types
  GoTo unless @loaded
  @loaded = true
  registry.keys
end