Class: Card::Content::Chunk::ViewStub

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

Instance Attribute Summary

Attributes inherited from Abstract

#text

Instance Method Summary collapse

Methods inherited from Abstract

#as_json, #burn_after_reading, #burn_read, #card, context_ok?, #format, full_match, full_re, #inspect, #reference_code, #to_s

Constructor Details

#initialize(text, content) ⇒ ViewStub

Returns a new instance of ViewStub.



14
15
16
# File 'mod/core/chunk/view_stub.rb', line 14

def initialize text, content
  super
end

Instance Method Details

#interpret(match, _content) ⇒ Object



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

def interpret match, _content
  @stub_hash = JSON.parse(match[1]).symbolize_keys
  interpret_hash_values
end

#interpret_castObject



29
30
31
# File 'mod/core/chunk/view_stub.rb', line 29

def interpret_cast
  @stub_hash[:cast].symbolize_keys!
end

#interpret_format_optsObject



37
38
39
40
41
42
43
# File 'mod/core/chunk/view_stub.rb', line 37

def interpret_format_opts
  hash = @stub_hash[:format_opts]
  hash.symbolize_keys!
  hash[:nest_mode] = hash[:nest_mode].to_sym
  hash[:override] = hash[:override] == "true"
  hash[:context_names].map!(&:to_name)
end

#interpret_hash_valuesObject



23
24
25
26
27
# File 'mod/core/chunk/view_stub.rb', line 23

def interpret_hash_values
  @stub_hash.keys.each do |key|
    send "interpret_#{key}"
  end
end

#interpret_view_optsObject



33
34
35
# File 'mod/core/chunk/view_stub.rb', line 33

def interpret_view_opts
  @stub_hash[:view_opts].symbolize_keys!
end

#process_chunkObject



45
46
47
# File 'mod/core/chunk/view_stub.rb', line 45

def process_chunk
  @processed = format.stub_nest @stub_hash
end

#resultObject



49
50
51
# File 'mod/core/chunk/view_stub.rb', line 49

def result
  @processed
end