Class: Schai::Property
- Inherits:
-
Object
- Object
- Schai::Property
- Defined in:
- lib/schai/hoge.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes included from Metadata
Attributes included from Optional
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ Property
constructor
A new instance of Property.
- #to_schema ⇒ Object
Constructor Details
#initialize(params) ⇒ Property
Returns a new instance of Property.
140 141 142 143 144 145 |
# File 'lib/schai/hoge.rb', line 140 def initialize params params.each do |k, v| setter = "#{k}=".to_sym self.send(setter, v) end end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
130 131 132 |
# File 'lib/schai/hoge.rb', line 130 def format @format end |
#type ⇒ Object
Returns the value of attribute type.
130 131 132 |
# File 'lib/schai/hoge.rb', line 130 def type @type end |
Class Method Details
.parse(params) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/schai/hoge.rb', line 132 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
147 148 149 150 151 152 153 154 |
# File 'lib/schai/hoge.rb', line 147 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 |