Class: Brujula::Raml::Definition
- Inherits:
-
Object
- Object
- Brujula::Raml::Definition
- Defined in:
- lib/brujula/raml/definition.rb
Instance Attribute Summary collapse
-
#base_dir ⇒ Object
readonly
Returns the value of attribute base_dir.
-
#raw_content ⇒ Object
readonly
Returns the value of attribute raw_content.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content:, base_dir:) ⇒ Definition
constructor
A new instance of Definition.
- #root ⇒ Object
Constructor Details
#initialize(content:, base_dir:) ⇒ Definition
Returns a new instance of Definition.
19 20 21 22 |
# File 'lib/brujula/raml/definition.rb', line 19 def initialize(content:, base_dir:) @base_dir = Pathname.new(base_dir) @raw_content = content end |
Instance Attribute Details
#base_dir ⇒ Object (readonly)
Returns the value of attribute base_dir.
17 18 19 |
# File 'lib/brujula/raml/definition.rb', line 17 def base_dir @base_dir end |
#raw_content ⇒ Object (readonly)
Returns the value of attribute raw_content.
17 18 19 |
# File 'lib/brujula/raml/definition.rb', line 17 def raw_content @raw_content end |
Class Method Details
.from_file(file) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/brujula/raml/definition.rb', line 5 def from_file(file) new(content: File.read(file), base_dir: File.dirname(file)) rescue Errno::ENOENT => exception $stderr.puts "** Invalid file path #{ file }" raise exception end |
.from_string(string) ⇒ Object
12 13 14 |
# File 'lib/brujula/raml/definition.rb', line 12 def from_string(string) new(content: string, base_dir: Dir.pwd) end |
Instance Method Details
#root ⇒ Object
24 25 26 |
# File 'lib/brujula/raml/definition.rb', line 24 def root @root ||= load_raml_objects end |