Class: JSON::Schema
- Inherits:
-
Object
- Object
- JSON::Schema
- Defined in:
- lib/json-schema/schema.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #base_uri ⇒ Object
-
#initialize(schema, uri) ⇒ Schema
constructor
A new instance of Schema.
- #to_s ⇒ Object
Constructor Details
#initialize(schema, uri) ⇒ Schema
Returns a new instance of Schema.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/json-schema/schema.rb', line 10 def initialize(schema,uri) @schema = schema @uri = uri # If there is an ID on this schema, use it to generate the URI if @schema['id'] temp_uri = URI.parse(@schema['id']) if temp_uri.relative? uri.path = (Pathname.new(uri.path).parent + @schema['id']).cleanpath temp_uri = uri end @uri = temp_uri end @uri.fragment = nil end |
Instance Attribute Details
#schema ⇒ Object
Returns the value of attribute schema.
8 9 10 |
# File 'lib/json-schema/schema.rb', line 8 def schema @schema end |
#uri ⇒ Object
Returns the value of attribute uri.
8 9 10 |
# File 'lib/json-schema/schema.rb', line 8 def uri @uri end |
Instance Method Details
#base_uri ⇒ Object
26 27 28 29 30 |
# File 'lib/json-schema/schema.rb', line 26 def base_uri parts = @uri.to_s.split('/') parts.pop parts.join('/') + '/' end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/json-schema/schema.rb', line 32 def to_s @schema.to_json end |