Class: ApiSketch::ResponseRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/api_sketch/response_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, container_type, elements_count) ⇒ ResponseRenderer

Returns a new instance of ResponseRenderer.



5
6
7
8
9
# File 'lib/api_sketch/response_renderer.rb', line 5

def initialize(params, container_type, elements_count)
  @params = params || {}
  @container_type = container_type
  @elements_count = elements_count > 0 ? elements_count : 3
end

Instance Attribute Details

#container_typeObject (readonly)

Returns the value of attribute container_type.



3
4
5
# File 'lib/api_sketch/response_renderer.rb', line 3

def container_type
  @container_type
end

#elements_countObject (readonly)

Returns the value of attribute elements_count.



3
4
5
# File 'lib/api_sketch/response_renderer.rb', line 3

def elements_count
  @elements_count
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/api_sketch/response_renderer.rb', line 3

def params
  @params
end

Instance Method Details

#to_hObject



11
12
13
# File 'lib/api_sketch/response_renderer.rb', line 11

def to_h
  render_content(params, container_type)
end

#to_jsonObject



15
16
17
# File 'lib/api_sketch/response_renderer.rb', line 15

def to_json
  self.to_h.to_json
end