Class: Cutaneous::Compiler::BlockSet
- Inherits:
-
Object
- Object
- Cutaneous::Compiler::BlockSet
- Defined in:
- lib/cutaneous/compiler.rb
Overview
Represents the block structure of a top-level master template, i.e. one with no ‘extends` call.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current_block ⇒ Object
readonly
Returns the value of attribute current_block.
-
#loader ⇒ Object
Returns the value of attribute loader.
Instance Method Summary collapse
- #block(name) ⇒ Object
- #block_end ⇒ Object
- #block_order ⇒ Object
- #block_start(name = Object.new) ⇒ Object
- #each_block ⇒ Object
-
#initialize ⇒ BlockSet
constructor
A new instance of BlockSet.
- #push(tag) ⇒ Object
- #super_block ⇒ Object
- #to_script ⇒ Object
Constructor Details
#initialize ⇒ BlockSet
35 36 37 38 39 |
# File 'lib/cutaneous/compiler.rb', line 35 def initialize @block_order = [] @block_store = {} block_start end |
Instance Attribute Details
#current_block ⇒ Object (readonly)
Returns the value of attribute current_block.
32 33 34 |
# File 'lib/cutaneous/compiler.rb', line 32 def current_block @current_block end |
#loader ⇒ Object
Returns the value of attribute loader.
33 34 35 |
# File 'lib/cutaneous/compiler.rb', line 33 def loader @loader end |
Instance Method Details
#block(name) ⇒ Object
63 64 65 |
# File 'lib/cutaneous/compiler.rb', line 63 def block(name) @block_store[name] end |
#block_end ⇒ Object
47 48 49 |
# File 'lib/cutaneous/compiler.rb', line 47 def block_end block_start end |
#block_order ⇒ Object
55 56 57 |
# File 'lib/cutaneous/compiler.rb', line 55 def block_order @block_order end |
#block_start(name = Object.new) ⇒ Object
41 42 43 44 45 |
# File 'lib/cutaneous/compiler.rb', line 41 def block_start(name = Object.new) @current_block = Block.new(name) @block_order << name @block_store[name] = @current_block end |
#each_block ⇒ Object
67 68 69 70 71 |
# File 'lib/cutaneous/compiler.rb', line 67 def each_block block_order.each do |block_name| yield block(block_name) end end |
#push(tag) ⇒ Object
51 52 53 |
# File 'lib/cutaneous/compiler.rb', line 51 def push(tag) @current_block << tag end |
#super_block ⇒ Object
59 60 61 |
# File 'lib/cutaneous/compiler.rb', line 59 def super_block raise CompilationError.new("Invalid 'blocksuper' call from top-level template") end |
#to_script ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/cutaneous/compiler.rb', line 73 def to_script script = "" each_block do |block| script << block.to_script end script end |