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
hyperlink()
click to toggle source
@return [String] Markdown styled link text for this resource @example
resource.hyperlink #=> "[App](#apps)"
# File lib/jdoc/resource.rb, line 27 def hyperlink "[#{title}](#{anchor})" end
links()
click to toggle source
# File lib/jdoc/resource.rb, line 59 def links @links ||= @schema.links.map do |link| if link.method && link.href Link.new(link) end end.compact 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