Class: Treedent::IndentedLine
- Inherits:
-
Struct
- Object
- Struct
- Treedent::IndentedLine
- Defined in:
- lib/treedent/indented_line.rb
Constant Summary collapse
- WHITESPACE_PATTERN =
/[ \t]*/.freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#indentation ⇒ Object
Returns the value of attribute indentation.
Class Method Summary collapse
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content
4 5 6 |
# File 'lib/treedent/indented_line.rb', line 4 def content @content end |
#indentation ⇒ Object
Returns the value of attribute indentation
4 5 6 |
# File 'lib/treedent/indented_line.rb', line 4 def indentation @indentation end |
Class Method Details
.from(line_string) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/treedent/indented_line.rb', line 7 def self.from(line_string) scanner = StringScanner.new(line_string) scan = scanner.scan(WHITESPACE_PATTERN) indentation = (scan && scan.length) || 0 content = scanner.rest new(indentation, content) end |