Class: Card::Content::Chunk::Reference

Inherits:
Abstract
  • Object
show all
Defined in:
mod/core/chunk/reference.rb

Direct Known Subclasses

QueryReference

Instance Attribute Summary collapse

Attributes inherited from Abstract

#process_chunk, #text

Instance Method Summary collapse

Methods inherited from Abstract

#as_json, #card, context_ok?, #format, full_match, full_re, #initialize, #inspect, #interpret, #reference_code, #to_s

Constructor Details

This class inherits a constructor from Card::Content::Chunk::Abstract

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'mod/core/chunk/reference.rb', line 6

def name
  @name
end

#referee_nameObject

Returns the value of attribute referee_name.



6
7
8
# File 'mod/core/chunk/reference.rb', line 6

def referee_name
  @referee_name
end

Instance Method Details

#referee_cardObject



18
19
20
# File 'mod/core/chunk/reference.rb', line 18

def referee_card
  @referee_card ||= referee_name && Card.fetch(referee_name)
end

#render_obj(raw) ⇒ Object



39
40
41
42
43
44
45
# File 'mod/core/chunk/reference.rb', line 39

def render_obj raw
  if format && raw.is_a?(Card::Content)
    format.process_content raw
  else
    raw
  end
end

#replace_name_reference(old_name, new_name) ⇒ Object

FIXME: if we need this, then it should be faster, using fetch_id def referee_id referee_card and referee_card.id end



27
28
29
30
31
32
33
34
35
36
37
# File 'mod/core/chunk/reference.rb', line 27

def replace_name_reference old_name, new_name
  @referee_card = nil
  @referee_name = nil
  if name.is_a? Card::Content
    name.find_chunks(Chunk::Reference).each do |chunk|
      chunk.replace_reference old_name, new_name
    end
  else
    @name = name.to_name.replace(old_name, new_name)
  end
end