Class: PerseusMatch::Token
Constant Summary collapse
- WC_RE =
%r{[/|]([^/|]*)\z}
- ANY_WC =
'*'.freeze
Instance Attribute Summary collapse
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#wc ⇒ Object
readonly
Returns the value of attribute wc.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(form, wc = nil) ⇒ Token
constructor
A new instance of Token.
- #inspect ⇒ Object (also: #to_s)
- #match?(wcs) ⇒ Boolean
- #unk? ⇒ Boolean
Methods inherited from String
Constructor Details
Instance Attribute Details
#form ⇒ Object (readonly)
Returns the value of attribute form.
9 10 11 |
# File 'lib/perseus_match/token.rb', line 9 def form @form end |
#wc ⇒ Object (readonly)
Returns the value of attribute wc.
9 10 11 |
# File 'lib/perseus_match/token.rb', line 9 def wc @wc end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 |
# File 'lib/perseus_match/token.rb', line 27 def ==(other) other.is_a?(self.class) ? form == other.form : form == other end |
#eql?(other) ⇒ Boolean
31 32 33 |
# File 'lib/perseus_match/token.rb', line 31 def eql?(other) self == other && wc == other.wc end |
#inspect ⇒ Object Also known as: to_s
35 36 37 |
# File 'lib/perseus_match/token.rb', line 35 def inspect "#{super}/#{wc}" end |
#match?(wcs) ⇒ Boolean
18 19 20 21 |
# File 'lib/perseus_match/token.rb', line 18 def match?(wcs) wcs = [*wcs].compact wcs.include?(wc) || wcs.include?(ANY_WC) end |
#unk? ⇒ Boolean
23 24 25 |
# File 'lib/perseus_match/token.rb', line 23 def unk? wc == '?' end |