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
Returns a new instance of Snippet.
57 58 59 60 61 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 57 def initialize(name:, indent:) @name = name @indent = indent @lines = [] end |
Instance Attribute Details
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
55 56 57 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 55 def indent @indent end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
55 56 57 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 55 def lines @lines end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
55 56 57 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 55 def name @name end |
Instance Method Details
#dedent(line) ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 70 def dedent(line) if line.length >= indent line[indent..-1] else line end end |
#dedented_text ⇒ Object
63 64 65 66 67 68 |
# File 'lib/jekyll/include_snippet/extractor.rb', line 63 def dedented_text lines .map { |line| dedent(line) } .join .rstrip end |