Class: Schai::JsArray

Inherits:
Object
  • Object
show all
Defined in:
lib/schai/json_schema/js_array.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ JsArray

Returns a new instance of JsArray.



9
10
11
12
13
14
# File 'lib/schai/json_schema/js_array.rb', line 9

def initialize params
  @items = JsProperty.parse params['items']
  @description = params["description"]
  @example = params["example"]
  @optional = params["optional"]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/schai/json_schema/js_array.rb', line 3

def description
  @description
end

#exampleObject

Returns the value of attribute example.



3
4
5
# File 'lib/schai/json_schema/js_array.rb', line 3

def example
  @example
end

#itemsObject

Returns the value of attribute items.



3
4
5
# File 'lib/schai/json_schema/js_array.rb', line 3

def items
  @items
end

#optionalObject

Returns the value of attribute optional.



3
4
5
# File 'lib/schai/json_schema/js_array.rb', line 3

def optional
  @optional
end

Class Method Details

.parse(params) ⇒ Object



5
6
7
# File 'lib/schai/json_schema/js_array.rb', line 5

def self.parse params
  self.new params
end

Instance Method Details

#to_schemaObject



16
17
18
19
20
21
22
23
24
# File 'lib/schai/json_schema/js_array.rb', line 16

def to_schema
  schema = {
    type: :array,
  }
  schema[:description] = @description if @description
  schema[:items] = @items.to_schema
  schema[:example] = @example if @example
  schema
end