Class: Tutorial::FileLoader
- Inherits:
-
Object
- Object
- Tutorial::FileLoader
- Defined in:
- lib/nexmo_developer/app/models/tutorial/file_loader.rb
Instance Attribute Summary collapse
-
#code_language ⇒ Object
readonly
Returns the value of attribute code_language.
-
#doc_name ⇒ Object
readonly
Returns the value of attribute doc_name.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #content ⇒ Object
- #doc ⇒ Object
-
#initialize(root:, code_language:, doc_name:, format: 'yml') ⇒ FileLoader
constructor
A new instance of FileLoader.
- #path ⇒ Object
- #yaml ⇒ Object
Constructor Details
#initialize(root:, code_language:, doc_name:, format: 'yml') ⇒ FileLoader
Returns a new instance of FileLoader.
4 5 6 7 8 9 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 4 def initialize(root:, code_language:, doc_name:, format: 'yml') @root = root @code_language = code_language @doc_name = doc_name @format = format end |
Instance Attribute Details
#code_language ⇒ Object (readonly)
Returns the value of attribute code_language.
2 3 4 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 2 def code_language @code_language end |
#doc_name ⇒ Object (readonly)
Returns the value of attribute doc_name.
2 3 4 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 2 def doc_name @doc_name end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
2 3 4 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 2 def format @format end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
2 3 4 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 2 def root @root end |
Instance Method Details
#content ⇒ Object
15 16 17 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 15 def content @content ||= File.read(path) end |
#doc ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 23 def doc @doc ||= Nexmo::Markdown::DocFinder.find( root: root, document: doc_name, language: ::I18n.locale, code_language: code_language, format: format ) end |
#path ⇒ Object
11 12 13 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 11 def path @path ||= doc.path end |
#yaml ⇒ Object
19 20 21 |
# File 'lib/nexmo_developer/app/models/tutorial/file_loader.rb', line 19 def yaml @yaml ||= YAML.safe_load(content) end |