Class: OpenAPISourceTools::ConfigLoader::ConfigFileInfo

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/openapi/sourcetools/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pieces, path) ⇒ ConfigFileInfo

Returns a new instance of ConfigFileInfo.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/openapi/sourcetools/config.rb', line 54

def initialize(pieces, path)
  @keys = []
  @root = nil
  pieces.each do |p|
    if p.is_a?(String)
      if @root.nil?
        @root = p
      else
        @keys.push(p)
      end
    else
      break if p == :extension
    end
  end
  @path = path
  @content = nil
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



52
53
54
# File 'lib/openapi/sourcetools/config.rb', line 52

def content
  @content
end

#keysObject (readonly)

Returns the value of attribute keys.



52
53
54
# File 'lib/openapi/sourcetools/config.rb', line 52

def keys
  @keys
end

#pathObject (readonly)

Returns the value of attribute path.



52
53
54
# File 'lib/openapi/sourcetools/config.rb', line 52

def path
  @path
end

#rootObject (readonly)

Returns the value of attribute root.



52
53
54
# File 'lib/openapi/sourcetools/config.rb', line 52

def root
  @root
end

Instance Method Details

#<=>(other) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/openapi/sourcetools/config.rb', line 81

def <=>(other)
  d = @root <=> other.root
  return d unless d.zero?
  d = @keys.size <=> other.keys.size
  return d unless d.zero?
  d = @keys <=> other.keys
  return d unless d.zero?
  @path <=> other.path
end

#bury_content(content) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/openapi/sourcetools/config.rb', line 72

def bury_content(content)
  # Turns chain of keys into nested Hashes.
  @keys.reverse.each do |key|
    c = { key => content }
    content = c
  end
  @content = content
end