Class: Card::Content::Chunk::ViewStub
- Inherits:
-
Abstract
show all
- Defined in:
- mod/content/lib/card/content/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, #initialize, #inspect, #reference_code, #to_s
Instance Method Details
#hex_to_bin(string) ⇒ Object
22
23
24
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 22
def hex_to_bin string
string.scan(/../).map { |x| x.hex.chr }.join
end
|
#initial_stub_hash(string) ⇒ Object
17
18
19
20
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 17
def initial_stub_hash string
JSON.parse(string).symbolize_keys
end
|
#interpret(match, _content) ⇒ Object
12
13
14
15
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 12
def interpret match, _content
@stub_hash = initial_stub_hash match[1]
interpret_hash_values
end
|
#interpret_cast ⇒ Object
32
33
34
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 32
def interpret_cast
@stub_hash[:cast].symbolize_keys!
end
|
40
41
42
43
44
45
46
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 40
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_values ⇒ Object
26
27
28
29
30
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 26
def interpret_hash_values
@stub_hash.each_key do |key|
send "interpret_#{key}"
end
end
|
#interpret_view_opts ⇒ Object
36
37
38
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 36
def interpret_view_opts
@stub_hash[:view_opts].symbolize_keys!
end
|
#process_chunk ⇒ Object
48
49
50
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 48
def process_chunk
@processed = format.stub_nest @stub_hash
end
|
52
53
54
|
# File 'mod/content/lib/card/content/chunk/view_stub.rb', line 52
def result
@processed
end
|