Class: Schai::Array

Inherits:
Object
  • Object
show all
Includes:
Metadata, Optional
Defined in:
lib/schai/hoge.rb

Instance Attribute Summary collapse

Attributes included from Metadata

#description, #example

Attributes included from Optional

#optional

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Array

Returns a new instance of Array.



108
109
110
111
112
113
# File 'lib/schai/hoge.rb', line 108

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

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



103
104
105
# File 'lib/schai/hoge.rb', line 103

def items
  @items
end

Class Method Details

.parse(params) ⇒ Object



104
105
106
# File 'lib/schai/hoge.rb', line 104

def self.parse params
  self.new params
end

Instance Method Details

#to_schemaObject



115
116
117
118
119
120
121
122
123
# File 'lib/schai/hoge.rb', line 115

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