Class: RLSM::RE::Position
- Inherits:
-
Object
- Object
- RLSM::RE::Position
- Includes:
- Comparable
- Defined in:
- lib/rlsm/regexp_parser.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#letter ⇒ Object
readonly
Returns the value of attribute letter.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(char, index = nil) ⇒ Position
constructor
A new instance of Position.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #weight ⇒ Object
Constructor Details
#initialize(char, index = nil) ⇒ Position
Returns a new instance of Position.
76 77 78 79 |
# File 'lib/rlsm/regexp_parser.rb', line 76 def initialize(char, index = nil) @letter = char @index = index end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
81 82 83 |
# File 'lib/rlsm/regexp_parser.rb', line 81 def index @index end |
#letter ⇒ Object (readonly)
Returns the value of attribute letter.
81 82 83 |
# File 'lib/rlsm/regexp_parser.rb', line 81 def letter @letter end |
Instance Method Details
#<=>(other) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rlsm/regexp_parser.rb', line 83 def <=>(other) case other when String @letter <=> other when Numeric @index <=> other when Position @letter == other.letter ? @index <=> other.index : @letter <=> other.letter else nil end end |
#inspect ⇒ Object
107 108 109 |
# File 'lib/rlsm/regexp_parser.rb', line 107 def inspect "P(#@letter,#@index)" end |
#to_s ⇒ Object
103 104 105 |
# File 'lib/rlsm/regexp_parser.rb', line 103 def to_s @letter end |
#weight ⇒ Object
96 97 98 99 100 101 |
# File 'lib/rlsm/regexp_parser.rb', line 96 def weight return 1 if Parser.open_bracket?(@letter) return -1 if Parser.close_bracket?(@letter) 0 end |