Class: MarkdownIncluder::Inclusion
- Inherits:
-
Object
- Object
- MarkdownIncluder::Inclusion
- Defined in:
- lib/markdown_helper/markdown_includer.rb
Instance Attribute Summary collapse
-
#cited_includee_file_path ⇒ Object
Returns the value of attribute cited_includee_file_path.
-
#include_pragma ⇒ Object
Returns the value of attribute include_pragma.
-
#includee_absolute_file_path ⇒ Object
Returns the value of attribute includee_absolute_file_path.
-
#includer_absolute_file_path ⇒ Object
Returns the value of attribute includer_absolute_file_path.
-
#includer_file_path ⇒ Object
Returns the value of attribute includer_file_path.
-
#includer_line_number ⇒ Object
Returns the value of attribute includer_line_number.
-
#treatment ⇒ Object
Returns the value of attribute treatment.
Instance Method Summary collapse
- #includee_real_file_path ⇒ Object
- #includer_real_file_path ⇒ Object
- #indentation(level) ⇒ Object
-
#initialize(includer_file_path:, include_pragma:, includer_line_number:, treatment:, cited_includee_file_path:, inclusions:) ⇒ Inclusion
constructor
A new instance of Inclusion.
- #to_lines(indentation_level) ⇒ Object
Constructor Details
#initialize(includer_file_path:, include_pragma:, includer_line_number:, treatment:, cited_includee_file_path:, inclusions:) ⇒ Inclusion
Returns a new instance of Inclusion.
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/markdown_helper/markdown_includer.rb', line 298 def initialize( includer_file_path:, include_pragma:, includer_line_number:, treatment:, cited_includee_file_path:, inclusions: ) self.includer_file_path = includer_file_path self.include_pragma = include_pragma self.includer_line_number = includer_line_number self.treatment = treatment self.cited_includee_file_path = cited_includee_file_path self.includer_absolute_file_path = File.absolute_path(includer_file_path) unless File.exist?(self.includer_absolute_file_path) fail self.includer_absolute_file_path end self.includee_absolute_file_path = File.absolute_path(File.join( File.dirname(includer_file_path), cited_includee_file_path, )) end |
Instance Attribute Details
#cited_includee_file_path ⇒ Object
Returns the value of attribute cited_includee_file_path.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def cited_includee_file_path @cited_includee_file_path end |
#include_pragma ⇒ Object
Returns the value of attribute include_pragma.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def include_pragma @include_pragma end |
#includee_absolute_file_path ⇒ Object
Returns the value of attribute includee_absolute_file_path.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def includee_absolute_file_path @includee_absolute_file_path end |
#includer_absolute_file_path ⇒ Object
Returns the value of attribute includer_absolute_file_path.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def includer_absolute_file_path @includer_absolute_file_path end |
#includer_file_path ⇒ Object
Returns the value of attribute includer_file_path.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def includer_file_path @includer_file_path end |
#includer_line_number ⇒ Object
Returns the value of attribute includer_line_number.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def includer_line_number @includer_line_number end |
#treatment ⇒ Object
Returns the value of attribute treatment.
289 290 291 |
# File 'lib/markdown_helper/markdown_includer.rb', line 289 def treatment @treatment end |
Instance Method Details
#includee_real_file_path ⇒ Object
327 328 329 |
# File 'lib/markdown_helper/markdown_includer.rb', line 327 def includee_real_file_path Pathname.new(includee_absolute_file_path).realpath.to_s end |
#includer_real_file_path ⇒ Object
323 324 325 |
# File 'lib/markdown_helper/markdown_includer.rb', line 323 def includer_real_file_path Pathname.new(includer_absolute_file_path).realpath.to_s end |
#indentation(level) ⇒ Object
331 332 333 |
# File 'lib/markdown_helper/markdown_includer.rb', line 331 def indentation(level) ' ' * level end |
#to_lines(indentation_level) ⇒ Object
335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/markdown_helper/markdown_includer.rb', line 335 def to_lines(indentation_level) relative_inluder_file_path = MarkdownHelper.path_in_project(includer_file_path) relative_inludee_file_path = MarkdownHelper.path_in_project(includee_absolute_file_path) text = <<EOT #{indentation(indentation_level)}Includer: #{indentation(indentation_level+1)}Location: #{relative_inluder_file_path}:#{includer_line_number} #{indentation(indentation_level+1)}Include pragma: #{include_pragma} #{indentation(indentation_level)}Includee: #{indentation(indentation_level+1)}File path: #{relative_inludee_file_path} EOT text.split("\n") end |