Class: PDF::Writer::Object::Action
- Inherits:
-
PDF::Writer::Object
- Object
- PDF::Writer::Object
- PDF::Writer::Object::Action
- Defined in:
- lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb
Overview
An action object, used to link to URLS initially
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from PDF::Writer::Object
Instance Method Summary collapse
-
#initialize(parent, label, type = "URI") ⇒ Action
constructor
A new instance of Action.
- #to_s ⇒ Object
Constructor Details
#initialize(parent, label, type = "URI") ⇒ Action
Returns a new instance of Action.
13 14 15 16 17 18 19 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb', line 13 def initialize(parent, label, type = "URI") super(parent) @type = type @label = label raise TypeError if @label.nil? end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
22 23 24 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb', line 22 def label @label end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb', line 21 def type @type end |
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gems/pdf-writer-1.1.8/lib/pdf/writer/object/action.rb', line 24 def to_s res = "\n#{@oid} 0 obj\n<< /Type /Action" if @type == :ilink res << "\n/S /GoTo\n/D #{@parent.destinations[@label].oid} 0 R" elsif @type == 'URI' res << "\n/S /URI\n/URI (" res << PDF::Writer.escape(@label) res << ")\n" end res << ">>\nendobj" end |