class Jdoc::Resource

Attributes

schema[R]

Public Class Methods

new(schema) click to toggle source

@param schema [JsonSchema::Schema]

# File lib/jdoc/resource.rb, line 6
def initialize(schema)
  @schema = schema
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/jdoc/resource.rb, line 55
def <=>(other)
  title <=> other.title
end
anchor() click to toggle source

@return [String] Href anchor for putting link in ToC @example

resource.anchor #=> "#app"
# File lib/jdoc/resource.rb, line 20
def anchor
  "#" + title.gsub(" ", "-").gsub(/[:\/]/, "").downcase
end
description() click to toggle source

@return [String] Description for this schema, defined in description property @example

resource.description #=> "An app is a program to be deployed."
# File lib/jdoc/resource.rb, line 13
def description
  @schema.description
end
eql?(other) click to toggle source

Defined to change uniqueness in Hash key

# File lib/jdoc/resource.rb, line 51
def eql?(other)
  title == other.title
end
hash() click to toggle source

Defined to change uniqueness in Hash key

# File lib/jdoc/resource.rb, line 46
def hash
  title.hash
end
properties() click to toggle source

@return [Array<Jdoc::Property>]

# File lib/jdoc/resource.rb, line 39
def properties
  @schema.properties.map do |name, schema|
    Property.new(name: name, schema: schema)
  end
end
title() click to toggle source

@return [String] Title defined in title property @example

resource.title #=> "App"
# File lib/jdoc/resource.rb, line 34
def title
  @title ||= @schema.title || @schema.pointer.split("/").last.camelize
end