Class: RBeautify::Line
- Defined in:
- lib/ruby-beautify/lib/ruby-beautify/line.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#indent_character ⇒ Object
readonly
Returns the value of attribute indent_character.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#original_block ⇒ Object
readonly
Returns the value of attribute original_block.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(language, content, line_number, original_block = nil, use_tabs = false) ⇒ Line
constructor
A new instance of Line.
Constructor Details
#initialize(language, content, line_number, original_block = nil, use_tabs = false) ⇒ Line
Returns a new instance of Line.
6 7 8 9 10 11 12 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 6 def initialize(language, content, line_number, original_block = nil, use_tabs = false) @language = language @content = content @original_block = original_block @indent_character = use_tabs ? "\t" : " " @block = BlockMatcher.parse(language, original_block, line_number, stripped, 0) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def block @block end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def content @content end |
#indent_character ⇒ Object (readonly)
Returns the value of attribute indent_character.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def indent_character @indent_character end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def language @language end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def line_number @line_number end |
#original_block ⇒ Object (readonly)
Returns the value of attribute original_block.
4 5 6 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 4 def original_block @original_block end |
Instance Method Details
#format ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby-beautify/lib/ruby-beautify/line.rb', line 14 def format if @formatted.nil? if format? if stripped.length == 0 @formatted = "" else @formatted = tab_string + stripped end else @formatted = content end end @formatted end |