Class: Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/json-schema-reader.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, uri) ⇒ Schema

Returns a new instance of Schema.



15
16
17
18
19
# File 'lib/json-schema-reader.rb', line 15

def initialize data, uri
  @data = JSON.parse data
  @uri = uri
  @data = expand @data
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



13
14
15
# File 'lib/json-schema-reader.rb', line 13

def data
  @data
end

#uriObject

Returns the value of attribute uri.



13
14
15
# File 'lib/json-schema-reader.rb', line 13

def uri
  @uri
end

Class Method Details

.load_from_file(path) ⇒ Object



21
22
23
# File 'lib/json-schema-reader.rb', line 21

def self.load_from_file path
  Schema.new File.read(path), Pathname.new(path).realdirpath
end

Instance Method Details

#pathObject



25
26
27
# File 'lib/json-schema-reader.rb', line 25

def path
  @uri.dirname
end

#pretty_generateObject



33
34
35
36
# File 'lib/json-schema-reader.rb', line 33

def pretty_generate
  puts @data.title
  print_line @data
end

#titleObject



29
30
31
# File 'lib/json-schema-reader.rb', line 29

def title
  @data.title
end