Class: Jekyll::IncludeSnippet::Extractor::Snippet
- Inherits:
-
Object
- Object
- Jekyll::IncludeSnippet::Extractor::Snippet
- Defined in:
- lib/jekyll/include_snippet/extractor.rb
Instance Attribute Summary collapse
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #dedent(line) ⇒ Object
- #dedented_text ⇒ Object
-
#initialize(name:, indent:) ⇒ Snippet
constructor
A new instance of Snippet.
Constructor Details
#initialize(name:, indent:) ⇒ Snippet
43 44 45 46 47 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 43 def initialize(name:, indent:) @name = name @indent = indent @lines = [] end |
Instance Attribute Details
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
41 42 43 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 41 def indent @indent end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
41 42 43 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 41 def lines @lines end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41 42 43 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 41 def name @name end |
Instance Method Details
#dedent(line) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 56 def dedent(line) if line.length >= indent line[indent..-1] else line end end |
#dedented_text ⇒ Object
49 50 51 52 53 54 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 49 def dedented_text lines .map { |line| dedent(line) } .join .rstrip end |