Class: Card::Content::Chunk::Link

Inherits:
Reference show all
Defined in:
mod/content/lib/card/content/chunk/link.rb

Constant Summary collapse

CODE =

L for “Link”

"L".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Reference

clean, insert_in_slices, map_referees, recreate_all, #referee, #referer, repair_all, unmap_referees

Instance Attribute Details

Returns the value of attribute link_text.



10
11
12
# File 'mod/content/lib/card/content/chunk/link.rb', line 10

def link_text
  @link_text
end

Instance Method Details

#explicit_link?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'mod/content/lib/card/content/chunk/link.rb', line 41

def explicit_link?
  @explicit_link
end

#inspectObject



24
25
26
27
# File 'mod/content/lib/card/content/chunk/link.rb', line 24

def inspect
  "<##{self.class}:e[#{@explicit_link}]n[#{@name}]l[#{@link_text}]" \
  "p[#{@process_chunk}] txt:#{@text}>"
end


55
56
57
58
59
60
61
# File 'mod/content/lib/card/content/chunk/link.rb', line 55

def link_target
  if @explicit_link
    render_obj @explicit_link
  elsif @name
    referee_name
  end
end

#optionsObject

view options



30
31
32
# File 'mod/content/lib/card/content/chunk/link.rb', line 30

def options
  { title: link_text || @name.to_name.fully_stripped }
end

#process_chunkObject



20
21
22
# File 'mod/content/lib/card/content/chunk/link.rb', line 20

def process_chunk
  @process_chunk ||= render_link
end

#reference_codeObject



16
17
18
# File 'mod/content/lib/card/content/chunk/link.rb', line 16

def reference_code
  CODE
end


45
46
47
48
49
50
51
52
53
# File 'mod/content/lib/card/content/chunk/link.rb', line 45

def render_link view: :link, explicit_link_opts: {}
  @link_text = render_obj @link_text

  if @explicit_link
    render_explicit_link explicit_link_opts
  elsif @name
    render_name_link view
  end
end

#swap_name(old_name, new_name) ⇒ Object



34
35
36
37
38
39
# File 'mod/content/lib/card/content/chunk/link.rb', line 34

def swap_name old_name, new_name
  replace_name_reference old_name, new_name
  replace_link_text old_name, new_name
  link_text_syntax = "|#{@link_text}" if @link_text.present?
  @text = "[[#{referee_name}#{link_text_syntax}]]"
end