Class: HtmlToHaml::NonHtmlSelectorBlocks::IndentationTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indented:, adjust_whitespace:) ⇒ IndentationTracker

Returns a new instance of IndentationTracker.



6
7
8
9
10
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 6

def initialize(indented:, adjust_whitespace:)
  @indented = indented
  @reset_adjust_whitespace = false
  @adjust_whitespace = adjust_whitespace
end

Instance Attribute Details

#adjust_whitespaceObject (readonly)

Returns the value of attribute adjust_whitespace.



4
5
6
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 4

def adjust_whitespace
  @adjust_whitespace
end

#indentedObject (readonly)

Returns the value of attribute indented.



4
5
6
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 4

def indented
  @indented
end

Instance Method Details

#adjust_whitespace?(reset_value: adjust_whitespace) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 25

def adjust_whitespace?(reset_value: adjust_whitespace)
  if @reset_adjust_whitespace
    @reset_adjust_whitespace = false
    @adjust_whitespace = reset_value
  else
    @adjust_whitespace
  end
end

#indentObject



12
13
14
15
16
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 12

def indent
  return if indented
  @indented = true
  @reset_adjust_whitespace = true
end

#outdentObject



18
19
20
21
22
23
# File 'lib/html_to_haml/tools/non_html_selector_blocks/indentation_tracker.rb', line 18

def outdent
  return unless indented
  @indented = false
  @adjust_whitespace = false
  @reset_adjust_whitespace = false
end