Class: PryCoolline::ParenMatch::Pair
- Inherits:
-
Struct
- Object
- Struct
- PryCoolline::ParenMatch::Pair
- Defined in:
- lib/pry-coolline/paren_match.rb
Overview
Represents a pair that should be matched.
Instance Attribute Summary collapse
-
#close ⇒ CloseToken?
The current value of close.
-
#open ⇒ OpenToken?
The current value of open.
Instance Method Summary collapse
-
#correctly_matched?(pairs = Pairs) ⇒ Boolean
True if the opening character and the closing characters are both present and match correctly.
-
#insertion_positions ⇒ Array<Array<Integer>>
Positions where the user can insert color indicators, in descending order so that String#insert can be used safely.
Instance Attribute Details
#close ⇒ CloseToken?
Returns the current value of close.
34 35 36 |
# File 'lib/pry-coolline/paren_match.rb', line 34 def close @close end |
#open ⇒ OpenToken?
Returns the current value of open.
34 35 36 |
# File 'lib/pry-coolline/paren_match.rb', line 34 def open @open end |
Instance Method Details
#correctly_matched?(pairs = Pairs) ⇒ Boolean
Returns True if the opening character and the closing characters are both present and match correctly.
37 38 39 |
# File 'lib/pry-coolline/paren_match.rb', line 37 def correctly_matched?(pairs = Pairs) open and close and pairs[open.str] == close.str end |
#insertion_positions ⇒ Array<Array<Integer>>
Returns Positions where the user can insert color indicators, in descending order so that String#insert can be used safely.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pry-coolline/paren_match.rb', line 50 def insertion_positions ary = [] if close ary << [close.code_pos, close.code_pos + close.str.size] end if open ary << [open.code_pos, open.code_pos + open.str.size] end ary end |