Class: Jsonapi::Swagger::Json
- Inherits:
- 
      Object
      
        - Object
- Jsonapi::Swagger::Json
 
- Defined in:
- lib/jsonapi/swagger/json.rb
Instance Attribute Summary collapse
- 
  
    
      #path  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Returns the value of attribute path. 
Instance Method Summary collapse
- #base_path ⇒ Object
- 
  
    
      #initialize(path = 'swagger/v1/swagger.json')  ⇒ Json 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Json. 
- #load ⇒ Object
- #parse_doc ⇒ Object
Constructor Details
#initialize(path = 'swagger/v1/swagger.json') ⇒ Json
Returns a new instance of Json.
| 7 8 9 | # File 'lib/jsonapi/swagger/json.rb', line 7 def initialize(path = 'swagger/v1/swagger.json') @path = path end | 
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
| 5 6 7 | # File 'lib/jsonapi/swagger/json.rb', line 5 def path @path end | 
Instance Method Details
#base_path ⇒ Object
| 15 16 17 | # File 'lib/jsonapi/swagger/json.rb', line 15 def base_path Jsonapi::Swagger.base_path end | 
#load ⇒ Object
| 19 20 21 22 23 24 25 26 | # File 'lib/jsonapi/swagger/json.rb', line 19 def load @data ||= if File.exist?(path) IO.read(path) else puts "create swagger.json in #{path}" '{}' end end | 
#parse_doc ⇒ Object
| 11 12 13 | # File 'lib/jsonapi/swagger/json.rb', line 11 def parse_doc @doc ||= JSON.parse(load) rescue Hash.new{ |h, k| h[k]= {} } end |