Class: Schai::JsProperty
- Inherits:
-
Object
- Object
- Schai::JsProperty
- Defined in:
- lib/schai/json_schema/js_property.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#example ⇒ Object
Returns the value of attribute example.
-
#format ⇒ Object
Returns the value of attribute format.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ JsProperty
constructor
A new instance of JsProperty.
- #to_schema ⇒ Object
Constructor Details
#initialize(params) ⇒ JsProperty
Returns a new instance of JsProperty.
13 14 15 16 17 18 |
# File 'lib/schai/json_schema/js_property.rb', line 13 def initialize params params.each do |k, v| setter = "#{k}=".to_sym self.send(setter, v) end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/schai/json_schema/js_property.rb', line 3 def description @description end |
#example ⇒ Object
Returns the value of attribute example.
3 4 5 |
# File 'lib/schai/json_schema/js_property.rb', line 3 def example @example end |
#format ⇒ Object
Returns the value of attribute format.
3 4 5 |
# File 'lib/schai/json_schema/js_property.rb', line 3 def format @format end |
#optional ⇒ Object
Returns the value of attribute optional.
3 4 5 |
# File 'lib/schai/json_schema/js_property.rb', line 3 def optional @optional end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/schai/json_schema/js_property.rb', line 3 def type @type end |
Class Method Details
.parse(params) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/schai/json_schema/js_property.rb', line 5 def self.parse params if params.has_key? 'include' Schai.parse_file(params['include']).schema else self.new params end end |
Instance Method Details
#to_schema ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/schai/json_schema/js_property.rb', line 20 def to_schema ret = {} ret[:type] = (@type || 'null').to_sym ret[:format] = @format if @format ret[:description] = @description if @description ret[:example] = @example if @example ret end |