Class: Arrolio::Content::Hyperlink
- Inherits:
-
Object
- Object
- Arrolio::Content::Hyperlink
- Defined in:
- lib/arrolio/content/hyperlink.rb
Overview
Inline runs wrapped with a hyperlink target. The renderer emits a PDF /Annot of subtype /Link with the URI (external) or /Dest reference (internal cross-reference).
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#runs ⇒ Object
readonly
Returns the value of attribute runs.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #external? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(runs, target:, internal: false, id: nil) ⇒ Hyperlink
constructor
A new instance of Hyperlink.
- #internal? ⇒ Boolean
Constructor Details
#initialize(runs, target:, internal: false, id: nil) ⇒ Hyperlink
Returns a new instance of Hyperlink.
11 12 13 14 15 16 17 |
# File 'lib/arrolio/content/hyperlink.rb', line 11 def initialize(runs, target:, internal: false, id: nil) @runs = Array(runs).freeze @target = target.to_s @internal_link = internal ? true : false @id = id&.to_s freeze end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/arrolio/content/hyperlink.rb', line 9 def id @id end |
#runs ⇒ Object (readonly)
Returns the value of attribute runs.
9 10 11 |
# File 'lib/arrolio/content/hyperlink.rb', line 9 def runs @runs end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
9 10 11 |
# File 'lib/arrolio/content/hyperlink.rb', line 9 def target @target end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
19 20 21 22 23 24 25 |
# File 'lib/arrolio/content/hyperlink.rb', line 19 def ==(other) other.is_a?(self.class) && runs == other.runs && target == other.target && internal? == other.internal? && id == other.id end |
#external? ⇒ Boolean
37 38 39 |
# File 'lib/arrolio/content/hyperlink.rb', line 37 def external? !internal? end |
#hash ⇒ Object
29 30 31 |
# File 'lib/arrolio/content/hyperlink.rb', line 29 def hash [self.class, runs, target, internal?, id].hash end |
#internal? ⇒ Boolean
33 34 35 |
# File 'lib/arrolio/content/hyperlink.rb', line 33 def internal? @internal_link end |