Class: Riddl::Protocols::HTTP::Generator
- Inherits:
-
Object
- Object
- Riddl::Protocols::HTTP::Generator
- Defined in:
- lib/ruby/riddl/protocols/http/generator.rb
Instance Method Summary collapse
- #generate(mode = :output) ⇒ Object
-
#initialize(params, headers) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(params, headers) ⇒ Generator
Returns a new instance of Generator.
9 10 11 12 |
# File 'lib/ruby/riddl/protocols/http/generator.rb', line 9 def initialize(params,headers) @params = params @headers = headers end |
Instance Method Details
#generate(mode = :output) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ruby/riddl/protocols/http/generator.rb', line 14 def generate(mode=:output) if @params.is_a?(Array) && @params.length == 1 body(@params[0],mode) elsif @params.class == Riddl::Parameter::Simple || @params.class == Riddl::Parameter::Complex body(@params,mode) elsif @params.is_a?(Array) && @params.length > 1 multipart(mode) else if mode == :output @headers['Content-Type'] = 'text/plain' StringIO.new('','r+b') else StringIO.new('','r+b') end end end |