Class: Pdfrb::Model::Type::Action

Inherits:
Cos::Dictionary show all
Defined in:
lib/pdfrb/model/type/action.rb

Overview

Action base class (s12.6). Like annotations, action subtypes each have their own TSV (ActionGoTo, ActionURI, ...) so the common fields are hand-coded here.

Instance Attribute Summary

Attributes inherited from Object

#document, #gen, #oid, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Dictionary

Class Method Details

.for_subtype(symbol) ⇒ Object



67
68
69
# File 'lib/pdfrb/model/type/action.rb', line 67

def for_subtype(symbol)
  subtype_map[symbol]
end

.register_subtype(symbol, klass = self) ⇒ Object



63
64
65
# File 'lib/pdfrb/model/type/action.rb', line 63

def register_subtype(symbol, klass = self)
  subtype_map[symbol] = klass
end

.subtype_mapObject



59
60
61
# File 'lib/pdfrb/model/type/action.rb', line 59

def subtype_map
  @subtype_map ||= {}
end

Instance Method Details

#dObject



52
53
54
55
56
# File 'lib/pdfrb/model/type/action.rb', line 52

def d
  return nil unless goto?

  self[:D]
end

#goto?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/pdfrb/model/type/action.rb', line 26

def goto?
  subtype&.to_sym == :GoTo
end

#javascript?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/pdfrb/model/type/action.rb', line 38

def javascript?
  subtype&.to_sym == :JavaScript
end

#launch?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/pdfrb/model/type/action.rb', line 34

def launch?
  subtype&.to_sym == :Launch
end

#named?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/pdfrb/model/type/action.rb', line 42

def named?
  subtype&.to_sym == :Named
end

#next_actionObject



17
# File 'lib/pdfrb/model/type/action.rb', line 17

def next_action; self[:Next]; end

#next_actionsObject



19
20
21
22
23
24
# File 'lib/pdfrb/model/type/action.rb', line 19

def next_actions
  value = self[:Next]
  return [] unless value

  value.is_a?(Pdfrb::Model::PdfArray) ? value.to_a : value
end

#subtypeObject



16
# File 'lib/pdfrb/model/type/action.rb', line 16

def subtype; self[:S]; end

#uriObject



46
47
48
49
50
# File 'lib/pdfrb/model/type/action.rb', line 46

def uri
  return nil unless uri?

  self[:URI]
end

#uri?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pdfrb/model/type/action.rb', line 30

def uri?
  subtype&.to_sym == :URI
end