Module: Babeltrace2Gen::BTPrinter
- Included in:
- BTEntryClass, BTEnvironmentClass, BTEventClass, BTFieldClass, Babeltrace2Gen::BTFieldClass::Enumeration::Mapping, BTStreamClass, BTTraceClass, Babeltrace2Gen::BTValueCLass::Map, Babeltrace2Gen::BTValueCLass::Scalar
- Defined in:
- lib/metababel/bt2_generator_utils.rb
Constant Summary collapse
- INDENT_INCREMENT =
' '.freeze
- @@output =
''
- @@indent =
0
Class Method Summary collapse
Instance Method Summary collapse
-
#name_sanitized ⇒ Object
Maybe not the best place.
- #scope ⇒ Object
Class Method Details
.context(output: '', indent: 0) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/metababel/bt2_generator_utils.rb', line 20 def self.context(output: '', indent: 0) @@output = output @@indent = indent yield @@output end |
.pr(str) ⇒ Object
7 8 9 |
# File 'lib/metababel/bt2_generator_utils.rb', line 7 def pr(str) @@output << (INDENT_INCREMENT * @@indent) << str << "\n" end |
Instance Method Details
#name_sanitized ⇒ Object
Maybe not the best place
28 29 30 31 32 |
# File 'lib/metababel/bt2_generator_utils.rb', line 28 def name_sanitized raise unless @name @name.gsub(/[^0-9A-Za-z-]/, '_') end |
#scope ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/metababel/bt2_generator_utils.rb', line 12 def scope pr '{' @@indent += 1 yield @@indent -= 1 pr '}' end |