Class: JSON::SchemaGenerator::StatementGroup
- Inherits:
-
Object
- Object
- JSON::SchemaGenerator::StatementGroup
- Defined in:
- lib/json/schema_generator/statement_group.rb
Instance Method Summary collapse
- #add(statement) ⇒ Object
-
#initialize(key = nil) ⇒ StatementGroup
constructor
A new instance of StatementGroup.
- #to_s ⇒ Object
Constructor Details
#initialize(key = nil) ⇒ StatementGroup
Returns a new instance of StatementGroup.
4 5 6 7 |
# File 'lib/json/schema_generator/statement_group.rb', line 4 def initialize key = nil @key = key @statements = [] end |
Instance Method Details
#add(statement) ⇒ Object
9 10 11 |
# File 'lib/json/schema_generator/statement_group.rb', line 9 def add statement @statements << statement end |
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/json/schema_generator/statement_group.rb', line 13 def to_s buffer = StringIO.new if @key.nil? buffer.puts "{" else buffer.puts "\"#{@key}\": {" end buffer.puts @statements.join ', ' buffer.puts "}" buffer.string end |