Class: Ikku::BracketState

Inherits:
Object
  • Object
show all
Defined in:
lib/ikku/bracket_state.rb

Constant Summary collapse

BRACKETS_TABLE =
{
  "" => "",
  "" => "",
  "" => "",
  "(" => ")",
  "" => "",
  "[" => "]",
  "{" => "}",
  "" => "",
  "" => "",
  "" => "",
  "" => "",
  "" => "",
  "" => "",
  "" => "",
  "<" => ">",
  "" => "",
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.brackets_indexObject



23
24
25
26
27
# File 'lib/ikku/bracket_state.rb', line 23

def brackets_index
  @brackets_index ||= BRACKETS_TABLE.to_a.flatten.inject({}) do |hash, bracket|
    hash.merge(bracket => true)
  end
end

.inverted_brackets_tableObject



29
30
31
# File 'lib/ikku/bracket_state.rb', line 29

def inverted_brackets_table
  @inverted_brackets_table ||= BRACKETS_TABLE.invert
end

Instance Method Details

#consume_all(surfaces) ⇒ Object



34
35
36
37
38
39
# File 'lib/ikku/bracket_state.rb', line 34

def consume_all(surfaces)
  surfaces.each do |surface|
    consume(surface)
  end
  self
end

#odd?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ikku/bracket_state.rb', line 41

def odd?
  !even?
end