Class: Arrolio::Content::Hyperlink

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/arrolio/content/hyperlink.rb', line 9

def id
  @id
end

#runsObject (readonly)

Returns the value of attribute runs.



9
10
11
# File 'lib/arrolio/content/hyperlink.rb', line 9

def runs
  @runs
end

#targetObject (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

Returns:

  • (Boolean)


37
38
39
# File 'lib/arrolio/content/hyperlink.rb', line 37

def external?
  !internal?
end

#hashObject



29
30
31
# File 'lib/arrolio/content/hyperlink.rb', line 29

def hash
  [self.class, runs, target, internal?, id].hash
end

#internal?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/arrolio/content/hyperlink.rb', line 33

def internal?
  @internal_link
end