Class: FN::SWF::Struct
- Inherits:
-
Hash
- Object
- Hash
- FN::SWF::Struct
- Defined in:
- lib/fn/swf/struct.rb
Constant Summary collapse
- TAB =
" "
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
Instance Method Summary collapse
- #<<(s, omit_end_tag = false, &b) ⇒ Object
- #break ⇒ Object
- #indent ⇒ Object
-
#initialize ⇒ Struct
constructor
A new instance of Struct.
- #tabs ⇒ Object
- #undent ⇒ Object
Constructor Details
#initialize ⇒ Struct
Returns a new instance of Struct.
8 9 10 11 |
# File 'lib/fn/swf/struct.rb', line 8 def initialize @buffer = "" @indent_level = 0 end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
6 7 8 |
# File 'lib/fn/swf/struct.rb', line 6 def buffer @buffer end |
Instance Method Details
#<<(s, omit_end_tag = false, &b) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fn/swf/struct.rb', line 17 def <<(s, omit_end_tag = false, &b) @buffer << "#{tabs}#{s}\n" if block_given? indent(&b) @buffer << "#{tabs}.end\n" unless omit_end_tag end end |
#break ⇒ Object
13 14 15 |
# File 'lib/fn/swf/struct.rb', line 13 def break self << "" end |
#indent ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/fn/swf/struct.rb', line 29 def indent @indent_level += 1 if block_given? yield @indent_level -= 1 end end |
#tabs ⇒ Object
25 26 27 |
# File 'lib/fn/swf/struct.rb', line 25 def tabs TAB * @indent_level end |
#undent ⇒ Object
37 38 39 40 |
# File 'lib/fn/swf/struct.rb', line 37 def undent @indent_level -= 1 raise "can't indent < 0" if @indent_level < 0 end |